hiptest/hiptest-publisher

View on GitHub
lib/hiptest-publisher/client.rb

Summary

Maintainability
C
1 day
Test Coverage
A
100%

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

  class Client
    attr_reader :cli_options
    attr_writer :async_options

    def initialize(cli_options, reporter = nil)
Severity: Minor
Found in lib/hiptest-publisher/client.rb - About 2 hrs to fix

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

    require 'erb'
    require 'i18n'
    require 'json'
    require 'net/http'
    require 'uri'
    Severity: Minor
    Found in lib/hiptest-publisher/client.rb - About 2 hrs to fix

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

          def project_export_filters
            mapping = {
              filter_on_scenario_ids: 'filter_scenario_ids',
              filter_on_folder_ids: 'filter_folder_ids',
              filter_on_scenario_name: 'filter_scenario_name',
      Severity: Minor
      Found in lib/hiptest-publisher/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

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

          def test_run_id
            return unless cli_options.test_run_id? || cli_options.test_run_name?
      
            if cli_options.test_run_id?
              key = "id"
      Severity: Minor
      Found in lib/hiptest-publisher/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

      Method push_query_parameters has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def push_query_parameters
            parameters = {}
            unless cli_options.execution_environment.strip.empty?
              parameters['execution_environment'] = cli_options.execution_environment
            end
      Severity: Minor
      Found in lib/hiptest-publisher/client.rb - About 45 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 fetch_project has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def fetch_project
            cached = export_cache.cache_for(url)
      
            unless cached.nil?
              @reporter.with_status_message I18n.t(:using_cached_data) do
      Severity: Minor
      Found in lib/hiptest-publisher/client.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 fetch_project_export_asynchronously has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def fetch_project_export_asynchronously
            publication_export_id = fetch_asynchronous_publication_export_id
            url = "#{base_publication_path}/async_project/#{publication_export_id}"
            response = nil
      
      
      Severity: Minor
      Found in lib/hiptest-publisher/client.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 url has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def url
            if cli_options.push?
              "#{cli_options.site}/import_test_results/#{cli_options.token}/#{cli_options.push_format}#{push_query_parameters}"
            elsif test_run_id
              "#{base_publication_path}/test_run/#{test_run_id}#{test_run_export_filter}"
      Severity: Minor
      Found in lib/hiptest-publisher/client.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

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

          def send_get_request(url, attempt = MAX_REDIRECTION)
            raise MaximumRedirectionReachedError if attempt < 0
      
            uri = URI.parse(url)
            send_request(Net::HTTP::Get.new(uri))
      Severity: Minor
      Found in lib/hiptest-publisher/client.rb and 1 other location - About 30 mins to fix
      lib/hiptest-publisher/client.rb on lines 253..260

      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 33.

      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 send_post_request(url, attempt = MAX_REDIRECTION)
            raise MaximumRedirectionReachedError if attempt < 0
      
            uri = URI.parse(url)
            send_request(Net::HTTP::Post.new(uri))
      Severity: Minor
      Found in lib/hiptest-publisher/client.rb and 1 other location - About 30 mins to fix
      lib/hiptest-publisher/client.rb on lines 244..251

      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 33.

      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

      There are no issues that match your filters.

      Category
      Status