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

      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

            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

            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

            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

            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

            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

            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

            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

            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

            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

            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

            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

            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

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

            def at_match?(job)
            return true unless @at
            return job[:at].nil? if @at == :no_wait
            return false unless job[:at]
             
             
            Severity: Minor
            Found in lib/rspec/rails/matchers/active_job.rb - About 25 mins to fix
            Severity
            Category
            Status
            Source
            Language