KnapsackPro/knapsack_pro-ruby

View on GitHub

Showing 31 of 33 total issues

Class Env has 58 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Env
      LOG_LEVELS = {
        'fatal'  => ::Logger::FATAL,
        'error'  => ::Logger::ERROR,
        'warn'  => ::Logger::WARN,
Severity: Major
Found in lib/knapsack_pro/config/env.rb - About 1 day to fix

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

          def make_request(&block)
            retries ||= 0
    
            @http_response = block.call
            @response_body = parse_response_body(http_response.body)
    Severity: Minor
    Found in lib/knapsack_pro/client/connection.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

    Class Connection has 22 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class Connection
          class ServerError < StandardError; end
    
          TIMEOUT = 15
          REQUEST_RETRY_TIMEBOX = 8
    Severity: Minor
    Found in lib/knapsack_pro/client/connection.rb - About 2 hrs to fix

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

              def self.run_tests(accumulator)
                runner = accumulator.fetch(:runner)
                can_initialize_queue = accumulator.fetch(:can_initialize_queue)
                args = accumulator.fetch(:args)
                exitstatus = accumulator.fetch(:exitstatus)
      Severity: Minor
      Found in lib/knapsack_pro/runners/queue/minitest_runner.rb - About 1 hr to fix

        Method generate_json_report has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def generate_json_report
                require 'rspec/core'
        
                cli_format =
                  if Gem::Version.new(::RSpec::Core::Version::STRING) < Gem::Version.new('3.6.0')
        Severity: Minor
        Found in lib/knapsack_pro/test_case_detectors/rspec_test_example_detector.rb - About 1 hr to fix

          Method run_tests has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  def self.run_tests(accumulator)
                    runner = accumulator.fetch(:runner)
                    can_initialize_queue = accumulator.fetch(:can_initialize_queue)
                    args = accumulator.fetch(:args)
                    exitstatus = accumulator.fetch(:exitstatus)
          Severity: Minor
          Found in lib/knapsack_pro/runners/queue/cucumber_runner.rb - About 1 hr to fix

            Method make_request has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def make_request(&block)
                    retries ||= 0
            
                    @http_response = block.call
                    @response_body = parse_response_body(http_response.body)
            Severity: Minor
            Found in lib/knapsack_pro/client/connection.rb - About 1 hr to fix

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

                  def test_file_paths(can_initialize_queue, executed_test_files)
                    return [] if @fallback_activated
                    action = build_action(can_initialize_queue, attempt_connect_to_queue: can_initialize_queue)
                    connection = KnapsackPro::Client::Connection.new(action)
                    response = connection.call
              Severity: Minor
              Found in lib/knapsack_pro/queue_allocator.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_file_paths has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  def test_file_paths
                    action = build_action(cache_read_attempt: true)
                    connection = KnapsackPro::Client::Connection.new(action)
                    response = connection.call
              
              
              Severity: Minor
              Found in lib/knapsack_pro/allocator.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_file_paths has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def test_file_paths(can_initialize_queue, executed_test_files)
                    return [] if @fallback_activated
                    action = build_action(can_initialize_queue, attempt_connect_to_queue: can_initialize_queue)
                    connection = KnapsackPro::Client::Connection.new(action)
                    response = connection.call
              Severity: Minor
              Found in lib/knapsack_pro/queue_allocator.rb - About 1 hr to fix

                Method call has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                    def self.call(test_files)
                      total_execution_time = test_files.sum { |test_file| test_file.fetch('time_execution') }
                      time_threshold = (total_execution_time / KnapsackPro::Config::Env.ci_node_total) * TIME_THRESHOLD_PER_CI_NODE
                
                      test_files.select do |test_file|
                Severity: Minor
                Found in lib/knapsack_pro/slow_test_file_determiner.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 ci_provider has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                        def ci_provider
                          return 'AWS CodeBuild' if ENV.key?('CODEBUILD_BUILD_ARN')
                          return 'Azure Pipelines' if ENV.key?('SYSTEM_TEAMFOUNDATIONCOLLECTIONURI')
                          return 'Bamboo' if ENV.key?('bamboo_planKey')
                          return 'Bitbucket Pipelines' if ENV.key?('BITBUCKET_COMMIT')
                Severity: Minor
                Found in lib/knapsack_pro/config/ci/base.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 knapsack__run_specs has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                        def knapsack__run_specs(queue_runner)
                          # Based on:
                          # https://github.com/rspec/rspec-core/blob/f8c8880dabd8f0544a6f91d8d4c857c1bd8df903/lib/rspec/core/world.rb#L53
                          ordering_strategy = configuration.ordering_registry.fetch(:global)
                          node_examples_passed = true
                Severity: Minor
                Found in lib/knapsack_pro/extensions/rspec_extension.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_file_paths has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def test_file_paths
                      action = build_action(cache_read_attempt: true)
                      connection = KnapsackPro::Client::Connection.new(action)
                      response = connection.call
                
                
                Severity: Minor
                Found in lib/knapsack_pro/allocator.rb - About 1 hr to fix

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

                          def self.run_tests(accumulator)
                            runner = accumulator.fetch(:runner)
                            can_initialize_queue = accumulator.fetch(:can_initialize_queue)
                            args = accumulator.fetch(:args)
                            exitstatus = accumulator.fetch(:exitstatus)
                  Severity: Minor
                  Found in lib/knapsack_pro/runners/queue/minitest_runner.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 prepare_cli_args has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                          def prepare_cli_args(args, has_format_option, has_require_rails_helper_option, rails_helper_exists, test_dir)
                  Severity: Minor
                  Found in lib/knapsack_pro/pure/queue/rspec_pure.rb - About 35 mins to fix

                    Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                            def initialize(adapter_class, rspec_pure, args, stream_error, stream_out)
                    Severity: Minor
                    Found in lib/knapsack_pro/runners/queue/rspec_runner.rb - About 35 mins to fix

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

                              def self.run_tests(accumulator)
                                runner = accumulator.fetch(:runner)
                                can_initialize_queue = accumulator.fetch(:can_initialize_queue)
                                args = accumulator.fetch(:args)
                                exitstatus = accumulator.fetch(:exitstatus)
                      Severity: Minor
                      Found in lib/knapsack_pro/runners/queue/cucumber_runner.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 with_batch has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                              def with_batch
                                can_initialize_queue = true
                      
                                loop do
                                  handle_signal!
                      Severity: Minor
                      Found in lib/knapsack_pro/runners/queue/rspec_runner.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 test_path has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                            def self.test_path(object)
                              if ::Cucumber::VERSION.to_i >= 2
                                test_case = object
                                test_case.location.file
                              else
                      Severity: Minor
                      Found in lib/knapsack_pro/adapters/cucumber_adapter.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