Skip to content

RSpecRails/NegationBeValid cop Error #69

@aahmad

Description

@aahmad

Hi,

We keep receiving this error when running against rspec files:

An error occurred while RSpecRails/NegationBeValid cop was inspecting [filename]

The actual test looks fine:

expect(form).to be_valid

Doesn't seem to be anything odd but I suspect it's blowing up trying to analyze that line (and others):

An error occurred while RSpecRails/NegationBeValid cop was inspecting test_spec.rb:420:26.
~/.rbenv/versions/3.4.3/lib/ruby/gems/3.4.0/gems/rubocop-1.75.8/lib/rubocop/cop/mixin/configurable_enforced_style.rb:81:in 'RuboCop::Cop::ConfigurableEnforcedStyle#style': undefined method 'to_sym' for nil (NoMethodError)

          s = cop_config[style_parameter_name].to_sym

        from ~/.rbenv/versions/3.4.3/lib/ruby/gems/3.4.0/gems/rubocop-rspec_rails-2.31.0/lib/rubocop/cop/rspec_rails/negation_be_valid.rb:62:in 'RuboCop::Cop::RSpecRails::NegationBeValid#offense?'
        from ~/.rbenv/versions/3.4.3/lib/ruby/gems/3.4.0/gems/rubocop-rspec_rails-2.31.0/lib/rubocop/cop/rspec_rails/negation_be_valid.rb:50:in 'RuboCop::Cop::RSpecRails::NegationBeValid#on_send'
        from ~/.rbenv/versions/3.4.3/lib/ruby/gems/3.4.0/gems/rubocop-1.75.8/lib/rubocop/cop/commissioner.rb:143:in 'Kernel#public_send'
        from ~/.rbenv/versions/3.4.3/lib/ruby/gems/3.4.0/gems/rubocop-1.75.8/lib/rubocop/cop/commissioner.rb:143:in 'block (2 levels) in RuboCop::Cop::Commissioner#trigger_restricted_cops'
        from ~/.rbenv/versions/3.4.3/lib/ruby/gems/3.4.0/gems/rubocop-1.75.8/lib/rubocop/cop/commissioner.rb:171:in 'RuboCop::Cop::Commissioner#with_cop_error_handling'
        from ~/.rbenv/versions/3.4.3/lib/ruby/gems/3.4.0/gems/rubocop-1.75.8/lib/rubocop/cop/commissioner.rb:142:in 'block in RuboCop::Cop::Commissioner#trigger_restricted_cops'
        from ~/.rbenv/versions/3.4.3/lib/ruby/gems/3.4.0/gems/rubocop-1.75.8/lib/rubocop/cop/commissioner.rb:141:in 'Array#each'

The versions of everything are:

1.75.8 (using Parser 3.3.8.0, Prism 1.4.0, rubocop-ast 1.46.0, 
analyzing as Ruby 3.4, running on ruby 3.4.3) [arm64-darwin23]

We are using the latest standardrb with the following config:

require:
  - standard
plugins:
  - rubocop-rails
  - rubocop-rspec
  - rubocop-capybara
  - rubocop-factory_bot
  - standard-custom
  - rubocop-performance
  - standard-performance
  - standard-rails
  - standard-rspec

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions