arangamani/jenkins_api_client

View on GitHub

Showing 76 of 76 total issues

Method get_build_params has a Cognitive Complexity of 147 (exceeds 5 allowed). Consider refactoring.
Open

      def get_build_params(job_name)
        @logger.info "Obtaining the build params of '#{job_name}'"
        xml = get_config(job_name)
        n_xml = Nokogiri::XML(xml)
        params = n_xml.xpath("//parameterDefinitions").first
Severity: Minor
Found in lib/jenkins_api_client/job.rb - About 2 days 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

File job.rb has 1112 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'jenkins_api_client/urihelper'

module JenkinsApi
  class Client
    # This class communicates with the Jenkins "/job" API to obtain details
Severity: Major
Found in lib/jenkins_api_client/job.rb - About 2 days to fix

    Method get_build_id_from_queue has a Cognitive Complexity of 74 (exceeds 5 allowed). Consider refactoring.
    Open

          def get_build_id_from_queue(response, expected_build_id, opts)
            # If we get this far the API hasn't detected an error response (it would raise Exception)
            # So no need to check response code
            # Obtain the queue ID from the location
            # header and wait till the build is moved to one of the executors and a
    Severity: Minor
    Found in lib/jenkins_api_client/job.rb - About 1 day 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

    Class Job has 78 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class Job
          include JenkinsApi::UriHelper
    
          # Version that jenkins started to include queued build info in build response
          JENKINS_QUEUE_ID_SUPPORT_VERSION = '1.519'
    Severity: Major
    Found in lib/jenkins_api_client/job.rb - About 1 day to fix

      Method build_freestyle_config has a Cognitive Complexity of 62 (exceeds 5 allowed). Consider refactoring.
      Open

            def build_freestyle_config(params)
              # Supported SCM providers
              supported_scm = ["git", "subversion", "cvs"]
      
              # Set default values for params that are not specified.
      Severity: Minor
      Found in lib/jenkins_api_client/job.rb - About 1 day 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

      File client.rb has 485 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require 'rubygems'
      require 'json'
      require 'net/http'
      require 'net/https'
      require 'nokogiri'
      Severity: Minor
      Found in lib/jenkins_api_client/client.rb - About 7 hrs to fix

        Method initialize has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
        Open

            def initialize(args)
              args = symbolize_keys(args)
              args.each do |key, value|
                if value && VALID_PARAMS.include?(key.to_s)
                  instance_variable_set("@#{key}", value)
        Severity: Minor
        Found in lib/jenkins_api_client/client.rb - About 6 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

        Class Client has 35 methods (exceeds 20 allowed). Consider refactoring.
        Open

          class Client
            attr_accessor :timeout, :logger
            # Default port to be used to connect to Jenkins
            DEFAULT_SERVER_PORT = 8080
            # Default timeout in seconds to be used while performing operations
        Severity: Minor
        Found in lib/jenkins_api_client/client.rb - About 4 hrs to fix

          Method build_freestyle_config has 99 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def build_freestyle_config(params)
                  # Supported SCM providers
                  supported_scm = ["git", "subversion", "cvs"]
          
                  # Set default values for params that are not specified.
          Severity: Major
          Found in lib/jenkins_api_client/job.rb - About 3 hrs to fix

            Method get_build_params has 96 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def get_build_params(job_name)
                    @logger.info "Obtaining the build params of '#{job_name}'"
                    xml = get_config(job_name)
                    n_xml = Nokogiri::XML(xml)
                    params = n_xml.xpath("//parameterDefinitions").first
            Severity: Major
            Found in lib/jenkins_api_client/job.rb - About 3 hrs to fix

              Method get_build_id_the_old_way has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
              Open

                    def get_build_id_the_old_way(expected_build_id, opts)
                      # Try to wait until the build starts so we can mimic queue
                      # Wait for the build to start
                      build_start_timeout = opts['build_start_timeout']
                      poll_interval = opts['poll_interval'] || 2
              Severity: Minor
              Found in lib/jenkins_api_client/job.rb - About 3 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 create_list_view has 62 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def create_list_view(params)
                      # Name is a required parameter. Raise an error if not specified
                      raise ArgumentError, "Name is required for creating view" \
                        unless params.is_a?(Hash) && params[:name]
                      create(params[:name], "listview")
              Severity: Major
              Found in lib/jenkins_api_client/view.rb - About 2 hrs to fix

                Method get_build_id_from_queue has 61 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def get_build_id_from_queue(response, expected_build_id, opts)
                        # If we get this far the API hasn't detected an error response (it would raise Exception)
                        # So no need to check response code
                        # Obtain the queue ID from the location
                        # header and wait till the build is moved to one of the executors and a
                Severity: Major
                Found in lib/jenkins_api_client/job.rb - About 2 hrs to fix

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

                      def make_http_request(request, follow_redirect = @follow_redirects)
                        request.basic_auth @username, @password if @username
                        request['Cookie'] = @cookies if @cookies
                  
                        if @proxy_ip
                  Severity: Minor
                  Found in lib/jenkins_api_client/client.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 skype_notification has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                        def skype_notification(params, xml)
                          params[:skype_strategy] = case params[:skype_strategy]
                          when "all"
                            "ALL"
                          when "failure"
                  Severity: Major
                  Found in lib/jenkins_api_client/job.rb - About 2 hrs to fix

                    Method build has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def build(job_name, params={}, opts = {})
                            if opts.nil? || opts.is_a?(FalseClass)
                              opts = {}
                            elsif opts.is_a?(TrueClass)
                              opts = { 'build_start_timeout' => @client_timeout }
                    Severity: Minor
                    Found in lib/jenkins_api_client/job.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 create_dumb_slave has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          def create_dumb_slave(params)
                            unless params[:name] && params[:slave_host] && params[:private_key_file]
                              raise ArgumentError, "Name, slave host, and private key file are" +
                                " required for creating a slave."
                            end
                    Severity: Minor
                    Found in lib/jenkins_api_client/node.rb - About 1 hr to fix

                      Method initialize has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          def initialize(args)
                            args = symbolize_keys(args)
                            args.each do |key, value|
                              if value && VALID_PARAMS.include?(key.to_s)
                                instance_variable_set("@#{key}", value)
                      Severity: Minor
                      Found in lib/jenkins_api_client/client.rb - About 1 hr to fix

                        Method handle_exception has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            def handle_exception(response, to_send = "code", send_json = false)
                              msg = "HTTP Code: #{response.code}, Response Body: #{response.body}"
                              @logger.debug msg
                              case response.code.to_i
                              # As of Jenkins version 1.519, the job builds return a 201 status code
                        Severity: Minor
                        Found in lib/jenkins_api_client/client.rb - About 1 hr to fix

                          Method handle_exception has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def handle_exception(response, to_send = "code", send_json = false)
                                msg = "HTTP Code: #{response.code}, Response Body: #{response.body}"
                                @logger.debug msg
                                case response.code.to_i
                                # As of Jenkins version 1.519, the job builds return a 201 status code
                          Severity: Minor
                          Found in lib/jenkins_api_client/client.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

                          Severity
                          Category
                          Status
                          Source
                          Language