rspec/rspec-core

View on GitHub

Showing 94 of 94 total issues

Class Configuration has 132 methods (exceeds 20 allowed). Consider refactoring.

    class Configuration
      include RSpec::Core::Hooks

      # Module that holds `attr_reader` declarations. It's in a separate
      # module to allow us to override those methods and use `super`.
Severity: Major
Found in lib/rspec/core/configuration.rb - About 2 days to fix

    File configuration.rb has 957 lines of code (exceeds 250 allowed). Consider refactoring.

    RSpec::Support.require_rspec_core "backtrace_formatter"
    RSpec::Support.require_rspec_core "ruby_project"
    RSpec::Support.require_rspec_core "formatters/deprecation_formatter"
    RSpec::Support.require_rspec_core "output_wrapper"
    
    
    Severity: Major
    Found in lib/rspec/core/configuration.rb - About 2 days to fix

      Method parser has 200 lines of code (exceeds 25 allowed). Consider refactoring.

          def parser(options)
            OptionParser.new do |parser|
              parser.summary_width = 34
      
              parser.banner = "Usage: rspec [options] [files or directories]\n\n"
      Severity: Major
      Found in lib/rspec/core/option_parser.rb - About 1 day to fix

        Method parser has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.

            def parser(options)
              OptionParser.new do |parser|
                parser.summary_width = 34
        
                parser.banner = "Usage: rspec [options] [files or directories]\n\n"
        Severity: Minor
        Found in lib/rspec/core/option_parser.rb - About 7 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

        File example_group.rb has 460 lines of code (exceeds 250 allowed). Consider refactoring.

        RSpec::Support.require_rspec_support 'recursive_const_methods'
        
        module RSpec
          module Core
            # rubocop:disable Metrics/ClassLength
        Severity: Minor
        Found in lib/rspec/core/example_group.rb - About 7 hrs to fix

          Class ExampleGroup has 50 methods (exceeds 20 allowed). Consider refactoring.

              class ExampleGroup
                extend Hooks
          
                include MemoizedHelpers
                extend MemoizedHelpers::ClassMethods
          Severity: Minor
          Found in lib/rspec/core/example_group.rb - About 7 hrs to fix

            File exception_presenter.rb has 378 lines of code (exceeds 250 allowed). Consider refactoring.

            RSpec::Support.require_rspec_core "formatters/console_codes"
            RSpec::Support.require_rspec_core "formatters/snippet_extractor"
            RSpec::Support.require_rspec_core 'formatters/syntax_highlighter'
            RSpec::Support.require_rspec_support "encoded_string"
            
            
            Severity: Minor
            Found in lib/rspec/core/formatters/exception_presenter.rb - About 5 hrs to fix

              File example.rb has 343 lines of code (exceeds 250 allowed). Consider refactoring.

              module RSpec
                module Core
                  # Wrapper for an instance of a subclass of {ExampleGroup}. An instance of
                  # `RSpec::Core::Example` is returned by example definition methods
                  # such as {ExampleGroup.it it} and is yielded to the {ExampleGroup.it it},
              Severity: Minor
              Found in lib/rspec/core/example.rb - About 4 hrs to fix

                Class Example has 33 methods (exceeds 20 allowed). Consider refactoring.

                    class Example
                      # @private
                      #
                      # Used to define methods that delegate to this example's metadata.
                      def self.delegate_to_metadata(key)
                Severity: Minor
                Found in lib/rspec/core/example.rb - About 4 hrs to fix

                  Class World has 32 methods (exceeds 20 allowed). Consider refactoring.

                      class World
                        # @private
                        attr_reader :example_groups, :filtered_examples, :example_group_counts_by_spec_file
                  
                        # Used internally to determine what to do when a SIGINT is received.
                  Severity: Minor
                  Found in lib/rspec/core/world.rb - About 4 hrs to fix

                    File html_printer.rb has 331 lines of code (exceeds 250 allowed). Consider refactoring.

                    require 'erb'
                    
                    module RSpec
                      module Core
                        module Formatters
                    Severity: Minor
                    Found in lib/rspec/core/formatters/html_printer.rb - About 3 hrs to fix

                      File metadata.rb has 326 lines of code (exceeds 250 allowed). Consider refactoring.

                      module RSpec
                        module Core
                          # Each ExampleGroup class and Example instance owns an instance of
                          # Metadata, which is Hash extended to support lazy evaluation of values
                          # associated with keys that may or may not be used by any example or group.
                      Severity: Minor
                      Found in lib/rspec/core/metadata.rb - About 3 hrs to fix

                        Class Reporter has 28 methods (exceeds 20 allowed). Consider refactoring.

                          class Reporter
                            # @private
                            RSPEC_NOTIFICATIONS = Set.new(
                              [
                                :close, :deprecation, :deprecation_summary, :dump_failures, :dump_pending,
                        Severity: Minor
                        Found in lib/rspec/core/reporter.rb - About 3 hrs to fix

                          Class ConfigurationOptions has 27 methods (exceeds 20 allowed). Consider refactoring.

                              class ConfigurationOptions
                                # @param args [Array<String>] command line arguments
                                def initialize(args)
                                  @args = args.dup
                                  organize_options
                          Severity: Minor
                          Found in lib/rspec/core/configuration_options.rb - About 3 hrs to fix

                            Class ExceptionPresenter has 27 methods (exceeds 20 allowed). Consider refactoring.

                                  class ExceptionPresenter
                                    attr_reader :exception, :example, :description, :message_color,
                                                :detail_formatter, :extra_detail_formatter, :backtrace_formatter
                                    private :message_color, :detail_formatter, :extra_detail_formatter, :backtrace_formatter
                            
                            
                            Severity: Minor
                            Found in lib/rspec/core/formatters/exception_presenter.rb - About 3 hrs to fix

                              File notifications.rb has 264 lines of code (exceeds 250 allowed). Consider refactoring.

                              RSpec::Support.require_rspec_core "formatters/console_codes"
                              RSpec::Support.require_rspec_core "formatters/exception_presenter"
                              RSpec::Support.require_rspec_core "formatters/helpers"
                              RSpec::Support.require_rspec_core "shell_escape"
                              
                              
                              Severity: Minor
                              Found in lib/rspec/core/notifications.rb - About 2 hrs to fix

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

                                      def initialize
                                        # rubocop:disable Style/GlobalVars
                                        @start_time = $_rspec_core_load_started_at || ::RSpec::Core::Time.now
                                        # rubocop:enable Style/GlobalVars
                                        @expectation_frameworks = []
                                Severity: Minor
                                Found in lib/rspec/core/configuration.rb - About 1 hr to fix

                                  Method filter_applies? has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.

                                          def filter_applies?(key, filter_value, metadata)
                                            silence_metadata_example_group_deprecations do
                                              return location_filter_applies?(filter_value, metadata) if key == :locations
                                              return id_filter_applies?(filter_value, metadata)       if key == :ids
                                              return filters_apply?(key, filter_value, metadata)      if Hash === filter_value
                                  Severity: Minor
                                  Found in lib/rspec/core/metadata_filter.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 ensure_hooks_initialized_for has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.

                                          def ensure_hooks_initialized_for(position, scope)
                                            if position == :before
                                              if scope == :example
                                                @before_example_hooks ||= @filterable_item_repo_class.new(:all?)
                                              else
                                  Severity: Minor
                                  Found in lib/rspec/core/hooks.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

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

                                          def jenkins_hash_digest(string)
                                            hash = 0
                                  
                                            string.each_byte do |byte|
                                              hash += byte
                                  Severity: Major
                                  Found in lib/rspec/core/ordering.rb and 1 other location - About 1 hr to fix
                                  benchmarks/hash_functions.rb on lines 6..22

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

                                  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.

                                  def jenkins_iterative(string)
                                    hash = 0
                                  
                                    string.each_byte do |byte|
                                      hash += byte
                                  Severity: Major
                                  Found in benchmarks/hash_functions.rb and 1 other location - About 1 hr to fix
                                  lib/rspec/core/ordering.rb on lines 39..55

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

                                  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 add_filter has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.

                                        def add_filter(argv, name, hash)
                                          hash.each_pair do |k, v|
                                            next if CONDITIONAL_FILTERS.include?(k)
                                            tag = name == :inclusion ? k.to_s : "~#{k}".dup
                                            tag << ":#{v}" if v.is_a?(String)
                                  Severity: Minor
                                  Found in lib/rspec/core/drb.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 37 lines of code (exceeds 25 allowed). Consider refactoring.

                                        def run(example_group_instance, reporter)
                                          @example_group_instance = example_group_instance
                                          @reporter = reporter
                                          RSpec.configuration.configure_example(self, hooks)
                                          RSpec.current_example = self
                                  Severity: Minor
                                  Found in lib/rspec/core/example.rb - About 1 hr to fix

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

                                          def expect_with(*frameworks)
                                            modules = frameworks.map do |framework|
                                              case framework
                                              when Module
                                                framework
                                    Severity: Minor
                                    Found in lib/rspec/core/configuration.rb - About 1 hr to fix

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

                                            def mock_with(framework)
                                              framework_module =
                                                if framework.is_a?(Module)
                                                  framework
                                                else
                                      Severity: Minor
                                      Found in lib/rspec/core/configuration.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 bisect_over has 31 lines of code (exceeds 25 allowed). Consider refactoring.

                                              def bisect_over(candidate_ids)
                                                return if candidate_ids.one?
                                      
                                                notify(
                                                  :bisect_round_started,
                                      Severity: Minor
                                      Found in lib/rspec/core/bisect/example_minimizer.rb - About 1 hr to fix

                                        Method run_benchmarks has 30 lines of code (exceeds 25 allowed). Consider refactoring.

                                          def self.run_benchmarks
                                            Benchmark.ips do |x|
                                              implementations = { :old => "without", :new => "with" }
                                              # Historically, many of our benchmarks have initially been order-sensitive,
                                              # where whichever implementation went first got favored because defining
                                        Severity: Minor
                                        Found in benchmarks/singleton_example_groups/helper.rb - About 1 hr to fix

                                          Method example_failed has 29 lines of code (exceeds 25 allowed). Consider refactoring.

                                                  def example_failed(failure)
                                                    @failed_examples << failure.example
                                                    unless @header_red
                                                      @header_red = true
                                                      @printer.make_header_red
                                          Severity: Minor
                                          Found in lib/rspec/core/formatters/html_formatter.rb - About 1 hr to fix

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

                                                      def formatted_cause(exception)
                                                        last_cause = final_exception(exception, [exception])
                                                        cause = []
                                            
                                                        if exception.cause
                                            Severity: Minor
                                            Found in lib/rspec/core/formatters/exception_presenter.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 hooks_for has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.

                                                    def hooks_for(position, scope)
                                                      if position == :before
                                                        scope == :example ? @before_example_hooks : @before_context_hooks
                                                      elsif position == :after
                                                        scope == :example ? @after_example_hooks : @after_context_hooks
                                            Severity: Minor
                                            Found in lib/rspec/core/hooks.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_task has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.

                                                  def run_task(verbose)
                                                    command = spec_command
                                                    puts command if verbose
                                            
                                                    if with_clean_environment
                                            Severity: Minor
                                            Found in lib/rspec/core/rake_task.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 a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.

                                                  def run(example_group_instance, reporter)
                                                    @example_group_instance = example_group_instance
                                                    @reporter = reporter
                                                    RSpec.configuration.configure_example(self, hooks)
                                                    RSpec.current_example = self
                                            Severity: Minor
                                            Found in lib/rspec/core/example.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 define_example_group_method has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.

                                                  def self.define_example_group_method(name, metadata={})
                                                    idempotently_define_singleton_method(name) do |*args, &example_group_block|
                                                      thread_data = RSpec::Support.thread_local_data
                                                      top_level   = self == ExampleGroup
                                            
                                            
                                            Severity: Minor
                                            Found in lib/rspec/core/example_group.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 announce_filters has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.

                                                  def announce_filters
                                                    fail_if_config_and_cli_options_invalid
                                                    filter_announcements = []
                                            
                                                    announce_inclusion_filter filter_announcements
                                            Severity: Minor
                                            Found in lib/rspec/core/world.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 add has 26 lines of code (exceeds 25 allowed). Consider refactoring.

                                                def add(formatter_to_use, *paths)
                                                  # If a formatter instance was passed, we can register it directly,
                                                  # with no need for any of the further processing that happens below.
                                                  if Loader.formatters.key?(formatter_to_use.class)
                                                    register formatter_to_use, notifications_for(formatter_to_use.class)
                                            Severity: Minor
                                            Found in lib/rspec/core/formatters.rb - About 1 hr to fix

                                              Method define_example_group_method has 26 lines of code (exceeds 25 allowed). Consider refactoring.

                                                    def self.define_example_group_method(name, metadata={})
                                                      idempotently_define_singleton_method(name) do |*args, &example_group_block|
                                                        thread_data = RSpec::Support.thread_local_data
                                                        top_level   = self == ExampleGroup
                                              
                                              
                                              Severity: Minor
                                              Found in lib/rspec/core/example_group.rb - About 1 hr to fix

                                                Method expect_with has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.

                                                      def expect_with(*frameworks)
                                                        modules = frameworks.map do |framework|
                                                          case framework
                                                          when Module
                                                            framework
                                                Severity: Minor
                                                Found in lib/rspec/core/configuration.rb - About 55 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 get_files_to_run has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.

                                                      def get_files_to_run(paths)
                                                        files = FlatMap.flat_map(paths_to_check(paths)) do |path|
                                                          path = path.gsub(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
                                                          File.directory?(path) ? gather_directories(path) : extract_location(path)
                                                        end.uniq
                                                Severity: Minor
                                                Found in lib/rspec/core/configuration.rb - About 55 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 options has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.

                                                      def options
                                                        argv = []
                                                        argv << "--color"        if @submitted_options[:color]
                                                        argv << "--force-color"  if @submitted_options[:color_mode] == :on
                                                        argv << "--no-color"     if @submitted_options[:color_mode] == :off
                                                Severity: Minor
                                                Found in lib/rspec/core/drb.rb - About 55 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 backwards_compatibility_default_proc has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.

                                                        def self.backwards_compatibility_default_proc(&example_group_selector)
                                                          Proc.new do |hash, key|
                                                            case key
                                                            when :example_group
                                                              # We commonly get here when rspec-core is applying a previously
                                                Severity: Minor
                                                Found in lib/rspec/core/metadata.rb - About 55 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 custom_formatter has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.

                                                    def custom_formatter(formatter_ref)
                                                      if Class === formatter_ref
                                                        formatter_ref
                                                      elsif string_const?(formatter_ref)
                                                        begin
                                                Severity: Minor
                                                Found in lib/rspec/core/formatters.rb - About 55 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 print_example_failed has 6 arguments (exceeds 4 allowed). Consider refactoring.

                                                        def print_example_failed(pending_fixed, description, run_time, failure_id,
                                                                                 exception, extra_content)
                                                Severity: Minor
                                                Found in lib/rspec/core/formatters/html_printer.rb - About 45 mins to fix

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

                                                      def setup_default(output_stream, deprecation_stream)
                                                        add default_formatter, output_stream if @formatters.empty?
                                                  
                                                        unless @formatters.any? { |formatter| DeprecationFormatter === formatter }
                                                          add DeprecationFormatter, deprecation_stream, output_stream
                                                  Severity: Minor
                                                  Found in lib/rspec/core/formatters.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 organize_options has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.

                                                        def organize_options
                                                          @filter_manager_options = []
                                                  
                                                          @options = (file_options << command_line_options << env_options).each do |opts|
                                                            @filter_manager_options << [:include, opts.delete(:inclusion_filter)] if opts.key?(:inclusion_filter)
                                                  Severity: Minor
                                                  Found in lib/rspec/core/configuration_options.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 run has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.

                                                          def run(position, scope, example_or_group)
                                                            return if RSpec.configuration.dry_run?
                                                  
                                                            if scope == :context
                                                              unless example_or_group.class.metadata[:skip]
                                                  Severity: Minor
                                                  Found in lib/rspec/core/hooks.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 apply_derived_metadata_to has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.

                                                        def apply_derived_metadata_to(metadata)
                                                          already_run_blocks = Set.new
                                                  
                                                          # We loop and attempt to re-apply metadata blocks to support cascades
                                                          # (e.g. where a derived bit of metadata triggers the application of
                                                  Severity: Minor
                                                  Found in lib/rspec/core/configuration.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 unclosed_tokens_in_line_range has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.

                                                            def unclosed_tokens_in_line_range(line_range)
                                                              tokens = FlatMap.flat_map(line_range) do |line_number|
                                                                source.tokens_by_line_number[line_number]
                                                              end
                                                  
                                                  
                                                  Severity: Minor
                                                  Found in lib/rspec/core/formatters/snippet_extractor.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

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

                                                        def prepend_before(scope=nil, *meta, &block)
                                                          handle_suite_hook(scope, meta) do
                                                            @before_suite_hooks.unshift Hooks::BeforeHook.new(block, {})
                                                          end || begin
                                                            # defeat Ruby 2.5 lazy proc allocation to ensure
                                                  Severity: Major
                                                  Found in lib/rspec/core/configuration.rb and 3 other locations - About 40 mins to fix
                                                  lib/rspec/core/configuration.rb on lines 1941..1954
                                                  lib/rspec/core/configuration.rb on lines 1996..2009
                                                  lib/rspec/core/configuration.rb on lines 2026..2039

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

                                                  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.

                                                        def before(scope=nil, *meta, &block)
                                                          handle_suite_hook(scope, meta) do
                                                            @before_suite_hooks << Hooks::BeforeHook.new(block, {})
                                                          end || begin
                                                            # defeat Ruby 2.5 lazy proc allocation to ensure
                                                  Severity: Major
                                                  Found in lib/rspec/core/configuration.rb and 3 other locations - About 40 mins to fix
                                                  lib/rspec/core/configuration.rb on lines 1971..1984
                                                  lib/rspec/core/configuration.rb on lines 1996..2009
                                                  lib/rspec/core/configuration.rb on lines 2026..2039

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

                                                  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.

                                                        def after(scope=nil, *meta, &block)
                                                          handle_suite_hook(scope, meta) do
                                                            @after_suite_hooks.unshift Hooks::AfterHook.new(block, {})
                                                          end || begin
                                                            # defeat Ruby 2.5 lazy proc allocation to ensure
                                                  Severity: Major
                                                  Found in lib/rspec/core/configuration.rb and 3 other locations - About 40 mins to fix
                                                  lib/rspec/core/configuration.rb on lines 1941..1954
                                                  lib/rspec/core/configuration.rb on lines 1971..1984
                                                  lib/rspec/core/configuration.rb on lines 2026..2039

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

                                                  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

                                                  Severity
                                                  Category