sensu-plugins/sensu-plugins-jenkins

View on GitHub

Showing 9 of 11 total issues

Method run has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

  def run
    https ||= config[:https] ? 'https' : 'http'
    testurl = "#{https}://#{config[:server]}:#{config[:port]}#{config[:uri]}"

    begin
Severity: Minor
Found in bin/check-jenkins-health.rb - About 2 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method run has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  def run
    @now = Time.now
    critical_jobs = []

    jobs = parse_jobs_param
Severity: Minor
Found in bin/check-jenkins-build-time.rb - About 2 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method run has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def run
    https ||= config[:https] ? 'https' : 'http'
    testurl = "#{https}://#{config[:server]}:#{config[:port]}#{config[:uri]}"

    begin
Severity: Minor
Found in bin/check-jenkins-health.rb - About 1 hr to fix

    Method run has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

      def run
        @start = DateTime.now
        @stop = nil
        begin
          https ||= config[:https] ? 'https' : 'http'
    Severity: Minor
    Found in bin/metrics-jenkins.rb - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method run has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def run
        @start = DateTime.now
        @stop = nil
        begin
          https ||= config[:https] ? 'https' : 'http'
    Severity: Minor
    Found in bin/metrics-jenkins.rb - About 1 hr to fix

      Method run has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def run
          @now = Time.now
          critical_jobs = []
      
          jobs = parse_jobs_param
      Severity: Minor
      Found in bin/check-jenkins-build-time.rb - About 1 hr to fix

        Method run has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          def run
            https ||= config[:https] ? 'https' : 'http'
            testurl = "#{https}://#{config[:server]}:#{config[:port]}#{config[:uri]}"
        
            r = if config[:https] && config[:insecure]
        Severity: Minor
        Found in bin/check-jenkins.rb - About 1 hr to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Method job_status has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def job_status(job_name)
            status = jenkins_api_client.job.get_current_build_status(job_name)
            # If the job is currently running, get the status of the last build instead
            if status == 'running'
              build = jenkins_api_client.job.get_build_details(job_name, 'lastCompletedBuild')
        Severity: Minor
        Found in bin/check-jenkins-job-status.rb - About 35 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Method run has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def run
            begin
              https ||= config[:https] ? 'https' : 'http'
              r = RestClient::Resource.new("#{https}://#{config[:server]}:#{config[:port]}#{config[:uri]}", timeout: 5).get
              all_metrics = ::JSON.parse(r)
        Severity: Minor
        Found in bin/metrics-jenkins-jqs.rb - About 25 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Severity
        Category
        Status
        Source
        Language