-
Task
-
Resolution: Fixed
-
Minor
-
None
in relation to JENKINS-51813, and the improvement of code, the PipelineSnippetGenerator code use some tests. But also, maybe even more important than the tests is to make the code more readable.
this if statement in particular:
https://github.com/jenkinsci/simple-pull-request-job-plugin/blob/4705792fa0fae8f047a7824b40e46c0ef314adcc/src/main/java/io/jenkins/plugins/sprp/PipelineSnippetGenerator.java#L143
if(stage.getFailure() != null || stage.getSuccess() != null || stage.getAlways() != null || (stage.getName().equals("Build") && (archiveArtifacts != null || buildResultPaths != null || findbugs != null)) || stage.getName().equals("Tests") && (testResultPaths != null || gitConfig.getGitUrl() != null))
is hard to follow.
These articles don't directly solve that example but should be reviewed on the different techniques that can be applied to make the code more readable.
http://www.christianschenk.org/blog/ideas-clean-if-statements/
https://dzone.com/articles/code-smells-if-statements