arangamani/jenkins_api_client

View on GitHub

Showing 76 of 76 total issues

Avoid deeply nested control flow statements.
Open

                    progress_proc.call(build_start_timeout, (Time.now.to_i - start), attempts) if progress_proc
Severity: Major
Found in lib/jenkins_api_client/job.rb - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            choices << choice_child.content.strip \
                              unless choice_child.content.strip.empty?
    Severity: Major
    Found in lib/jenkins_api_client/job.rb - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          completion_proc.call(build_number, false) if completion_proc
      Severity: Major
      Found in lib/jenkins_api_client/job.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                          completion_proc.call(nil, true) if completion_proc
        Severity: Major
        Found in lib/jenkins_api_client/job.rb - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                          rescue JenkinsApi::Exceptions::ApiException => e
                            completion_proc.call(nil, false) if completion_proc
                            @logger.warn "Error while attempting to cancel pending job for '#{job_name}'. #{e.class} #{e}"
                            raise
          Severity: Major
          Found in lib/jenkins_api_client/job.rb - About 45 mins to fix

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                    if n_xml.xpath("//hudson.tasks.Mailer").empty?
                      p_xml = Nokogiri::XML::Builder.new(:encoding => "UTF-8") do |b_xml|
                        notification_email(params, b_xml)
                      end
                      email_xml = Nokogiri::XML(p_xml.to_xml).xpath(
            Severity: Minor
            Found in lib/jenkins_api_client/job.rb and 1 other location - About 45 mins to fix
            lib/jenkins_api_client/job.rb on lines 433..441

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 39.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                    if n_xml.xpath("//hudson.plugins.skype.im.transport.SkypePublisher").empty?
                      p_xml = Nokogiri::XML::Builder.new(:encoding => "UTF-8") do |b_xml|
                        skype_notification(params, b_xml)
                      end
                      skype_xml = Nokogiri::XML(p_xml.to_xml).xpath(
            Severity: Minor
            Found in lib/jenkins_api_client/job.rb and 1 other location - About 45 mins to fix
            lib/jenkins_api_client/job.rb on lines 395..403

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 39.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Consider simplifying this complex logical expression.
            Open

                    if version_a_d[0] > version_b_d[0] ||
                      (version_a_d[0] == version_b_d[0] && version_a_d[1] > version_b_d[1]) ||
                      (version_a_d[0] == version_b_d[0] && version_a_d[1] == version_b_d[1] && version_a_d[2] > version_b_d[2])
                      return 1
                    else
            Severity: Major
            Found in lib/jenkins_api_client/client.rb - About 40 mins to fix

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                    def list_views(view_name)
                      @logger.info "Obtaining the views present in view '#{view_name}'"
                      view_names = []
                      raise "The view #{view_name} doesn't exists on the server"\
                        unless exists?(view_name)
              Severity: Minor
              Found in lib/jenkins_api_client/view.rb and 1 other location - About 40 mins to fix
              lib/jenkins_api_client/view.rb on lines 212..221

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 37.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 4 locations. Consider refactoring.
              Open

                    def unblock_build_when_upstream_building(job_name)
                      @logger.info "Unblocking builds of '#{job_name}' when upstream" +
                        " projects are building"
                      xml = get_config(job_name)
                      n_xml = Nokogiri::XML(xml)
              Severity: Major
              Found in lib/jenkins_api_client/job.rb and 3 other locations - About 40 mins to fix
              lib/jenkins_api_client/job.rb on lines 1169..1178
              lib/jenkins_api_client/job.rb on lines 1188..1197
              lib/jenkins_api_client/job.rb on lines 1207..1216

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 37.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 4 locations. Consider refactoring.
              Open

                    def block_build_when_downstream_building(job_name)
                      @logger.info "Blocking builds of '#{job_name}' when downstream" +
                        " projects are building"
                      xml = get_config(job_name)
                      n_xml = Nokogiri::XML(xml)
              Severity: Major
              Found in lib/jenkins_api_client/job.rb and 3 other locations - About 40 mins to fix
              lib/jenkins_api_client/job.rb on lines 1188..1197
              lib/jenkins_api_client/job.rb on lines 1207..1216
              lib/jenkins_api_client/job.rb on lines 1226..1235

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 37.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                    def list_jobs(view_name)
                      @logger.info "Obtaining the jobs present in view '#{view_name}'"
                      job_names = []
                      raise "The view #{view_name} doesn't exists on the server"\
                        unless exists?(view_name)
              Severity: Minor
              Found in lib/jenkins_api_client/view.rb and 1 other location - About 40 mins to fix
              lib/jenkins_api_client/view.rb on lines 266..275

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 37.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 4 locations. Consider refactoring.
              Open

                    def block_build_when_upstream_building(job_name)
                      @logger.info "Blocking builds of '#{job_name}' when upstream" +
                        " projects are building"
                      xml = get_config(job_name)
                      n_xml = Nokogiri::XML(xml)
              Severity: Major
              Found in lib/jenkins_api_client/job.rb and 3 other locations - About 40 mins to fix
              lib/jenkins_api_client/job.rb on lines 1169..1178
              lib/jenkins_api_client/job.rb on lines 1188..1197
              lib/jenkins_api_client/job.rb on lines 1226..1235

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 37.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 4 locations. Consider refactoring.
              Open

                    def unblock_build_when_downstream_building(job_name)
                      @logger.info "Unblocking builds of '#{job_name}' when downstream" +
                        " projects are building"
                      xml = get_config(job_name)
                      n_xml = Nokogiri::XML(xml)
              Severity: Major
              Found in lib/jenkins_api_client/job.rb and 3 other locations - About 40 mins to fix
              lib/jenkins_api_client/job.rb on lines 1169..1178
              lib/jenkins_api_client/job.rb on lines 1207..1216
              lib/jenkins_api_client/job.rb on lines 1226..1235

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 37.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                            param.children.each do |value|
                              param_hash[:name] = value.content if value.name == "name"
                              if value.name == "description"
                                param_hash[:description] = value.content
                              end
              Severity: Minor
              Found in lib/jenkins_api_client/job.rb and 1 other location - About 35 mins to fix
              lib/jenkins_api_client/job.rb on lines 1295..1301

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 36.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                            param.children.each do |value|
                              param_hash[:name] = value.content if value.name == "name"
                              if value.name == "description"
                                param_hash[:description] = value.content
                              end
              Severity: Minor
              Found in lib/jenkins_api_client/job.rb and 1 other location - About 35 mins to fix
              lib/jenkins_api_client/job.rb on lines 1284..1290

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 36.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

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

                    def wait_for_ready
                      Timeout::timeout(@timeout) do
                        while true do
                          response = @client.get_root
                          @logger.info "Waiting for jenkins to restart..."
              Severity: Minor
              Found in lib/jenkins_api_client/system.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 create_list_view has a Cognitive Complexity of 7 (exceeds 5 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: Minor
              Found in lib/jenkins_api_client/view.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 list_available has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                    def list_available(filters = {})
                      supported_filters = [:category, :dependency]
                      filter_plural_map = {
                        :dependency => "dependencies",
                        :category => "categories"
              Severity: Minor
              Found in lib/jenkins_api_client/plugin_manager.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 list has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                    def list(filter = nil, ignorecase = true, slaveonly = false)
                      @logger.info "Obtaining nodes from jenkins matching filter '#{filter}'"
                      node_names = []
                      response_json = @client.api_get_request("/computer")
                      response_json["computer"].each do |computer|
              Severity: Minor
              Found in lib/jenkins_api_client/node.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

              Severity
              Category
              Status
              Source
              Language