rspec/rspec-rails

View on GitHub

Showing 21 of 21 total issues

Method initialize_configuration has 85 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def self.initialize_configuration(config) # rubocop:disable Metrics/MethodLength,Metrics/CyclomaticComplexity
      config.backtrace_exclusion_patterns << /vendor\//
      config.backtrace_exclusion_patterns << %r{lib/rspec/rails}

      # controller settings
Severity: Major
Found in lib/rspec/rails/configuration.rb - About 3 hrs to fix

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

            class Base < RSpec::Rails::Matchers::BaseMatcher
              def initialize
                @args = []
                @queue = nil
                @at = nil
    Severity: Minor
    Found in lib/rspec/rails/matchers/active_job.rb - About 3 hrs to fix

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

          def self.initialize_configuration(config) # rubocop:disable Metrics/MethodLength,Metrics/CyclomaticComplexity
            config.backtrace_exclusion_patterns << /vendor\//
            config.backtrace_exclusion_patterns << %r{lib/rspec/rails}
      
            # controller settings
      Severity: Minor
      Found in lib/rspec/rails/configuration.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 HaveBroadcastedTo has 22 methods (exceeds 20 allowed). Consider refactoring.
      Open

              class HaveBroadcastedTo < RSpec::Matchers::BuiltIn::BaseMatcher
                def initialize(target, channel:)
                  @target = target
                  @channel = channel
                  @block = proc { }
      Severity: Minor
      Found in lib/rspec/rails/matchers/action_cable/have_broadcasted_to.rb - About 2 hrs to fix

        File active_job.rb has 260 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require "active_job/base"
        require "active_job/arguments"
        
        module RSpec
          module Rails
        Severity: Minor
        Found in lib/rspec/rails/matchers/active_job.rb - About 2 hrs to fix

          Method controller has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  def controller(base_class = nil, &body)
                    if RSpec.configuration.infer_base_class_for_anonymous_controllers?
                      base_class ||= controller_class
                    end
                    base_class ||= defined?(ApplicationController) ? ApplicationController : ActionController::Base
          Severity: Minor
          Found in lib/rspec/rails/example/controller_example_group.rb - About 1 hr to fix

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

                    def failure_message
                      [].tap do |message|
                        unless actual.is_a?(expected) && actual.new_record?
                          message << "expected #{actual.inspect} to be a new #{expected.inspect}"
                        end
            Severity: Minor
            Found in lib/rspec/rails/matchers/be_a_new.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 controller has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                    def controller(base_class = nil, &body)
                      if RSpec.configuration.infer_base_class_for_anonymous_controllers?
                        base_class ||= controller_class
                      end
                      base_class ||= defined?(ApplicationController) ? ApplicationController : ActionController::Base
            Severity: Minor
            Found in lib/rspec/rails/example/controller_example_group.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 initialize_activerecord_configuration has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                  def self.initialize_activerecord_configuration(config)
                    config.before :suite do
                      # This allows dynamic columns etc to be used on ActiveRecord models when creating instance_doubles
                      if defined?(ActiveRecord) && defined?(ActiveRecord::Base) && defined?(::RSpec::Mocks) && (::RSpec::Mocks.respond_to?(:configuration))
                        ::RSpec::Mocks.configuration.when_declaring_verifying_double do |possible_model|
            Severity: Minor
            Found in lib/rspec/rails/active_record.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 2 locations. Consider refactoring.
            Open

            module Rspec
              module Generators
                # @private
                class GeneratorGenerator < Base
                  class_option :generator_specs, type: :boolean, default: true,  desc: "Generate generator specs"
            Severity: Minor
            Found in lib/generators/rspec/generator/generator_generator.rb and 1 other location - About 35 mins to fix
            lib/generators/rspec/system/system_generator.rb on lines 4..21

            Duplicated Code

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

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

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

            Tuning

            This issue has a mass of 36.

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

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

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

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

            Refactorings

            Further Reading

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

              module Rspec
                module Generators
                  # @private
                  class SystemGenerator < Base
                    class_option :system_specs, type: :boolean, default: true,  desc: "Generate system specs"
            Severity: Minor
            Found in lib/generators/rspec/system/system_generator.rb and 1 other location - About 35 mins to fix
            lib/generators/rspec/generator/generator_generator.rb on lines 3..20

            Duplicated Code

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

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

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

            Tuning

            This issue has a mass of 36.

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

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

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

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

            Refactorings

            Further Reading

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

                    def _default_render_options
                      formats = if ActionView::Template::Types.respond_to?(:symbols)
                                  ActionView::Template::Types.symbols
                                else
                                  [:html, :text, :js, :css, :xml, :json].map(&:to_s)
            Severity: Minor
            Found in lib/rspec/rails/example/view_example_group.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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                  def initialize(*assertion_modules)
                    assertion_class = Class.new(SimpleDelegator) do
                      include ::RSpec::Rails::Assertions
                      include ::RSpec::Rails::MinitestCounters
                      assertion_modules.each { |mod| include mod }
            Severity: Minor
            Found in lib/rspec/rails/adapters.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 check has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                      def check(messages)
                        @matching_msgs, @unmatching_msgs = messages.partition do |msg|
                          decoded = ActiveSupport::JSON.decode(msg)
                          decoded = decoded.with_indifferent_access if decoded.is_a?(Hash)
            
            
            Severity: Minor
            Found in lib/rspec/rails/matchers/action_cable/have_broadcasted_to.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 name has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                        def self.name
                          root_controller = defined?(ApplicationController) ? ApplicationController : ActionController::Base
                          if superclass == root_controller || superclass.abstract?
                            "AnonymousController"
                          else
            Severity: Minor
            Found in lib/rspec/rails/example/controller_example_group.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 generate_view_specs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                  def generate_view_specs
                    return if options[:api]
                    return unless options[:view_specs] && options[:template_engine]
            
                    copy_view :edit
            Severity: Minor
            Found in lib/generators/rspec/scaffold/scaffold_generator.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

            Method base_message has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                      def base_message
                        "#{message_expectation_modifier} #{@expected_number} jobs,".tap do |msg|
                          msg << " with #{@args}," if @args.any?
                          msg << " on queue #{@queue}," if @queue
                          msg << " at #{@at.inspect}," if @at
            Severity: Minor
            Found in lib/rspec/rails/matchers/active_job.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

            Method rails_fixture_file_wrapper has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                  def rails_fixture_file_wrapper
                    RailsFixtureFileWrapper.fixture_path = nil
                    resolved_fixture_path =
                      if respond_to?(:fixture_path) && !fixture_path.nil?
                        fixture_path.to_s
            Severity: Minor
            Found in lib/rspec/rails/fixture_file_upload_support.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

            Method base_message has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                    def base_message
                      [mailer_class_name, @method_name].compact.join('.').tap do |msg|
                        msg << " #{expected_count_message}"
                        msg << " with #{@mail_args}," if @mail_args.any?
                        msg << " on queue #{@queue}," if @queue
            Severity: Minor
            Found in lib/rspec/rails/matchers/have_enqueued_mail.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

            Method passed? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                  def passed?
                    return false if RSpec.current_example.exception
                    return true unless defined?(::RSpec::Expectations::FailureAggregator)
            
                    failure_notifier = ::RSpec::Support.failure_notifier
            Severity: Minor
            Found in lib/rspec/rails/example/system_example_group.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

            Severity
            Category
            Status
            Source
            Language