cleanup if statements in snippet generator

XMLWordPrintable

      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

            Assignee:
            Abhishek Gautam
            Reporter:
            J Knurek
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: