rails / rubocop-rails-omakase

Omakase Ruby styling for Rails

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Consider removing rubocop-minitest dependency

igor-alexandrov opened this issue · comments

I am not quite sure that having rubocop-minitest as a dependency is correct. On one side – yes, Minitest is a default testing framework in Rails; on the other side, a lot of Rails apps use RSpec, and having rubocop-minitest in the dependency graph will look quite strange.

What do you think?

Related to this issue, how does one require rubocop-rspec when inheriting the omakase's rubocop config?

Here is what I have below:

require:
  - rubocop-rspec

inherit_gem:
  rubocop-rails-omakase: rubocop.yml

I can't get rubocop-rspec to run when using rubocop. I tried swapping the positions of the require and inherit_gem with no success. This is on a clean Rails 7.1.3.2 install with rubocop-rails-omakase 1.0.0 and rubocop-rspec 2.26.1.

After removing the inherit gem I can get rubocop-rspec to run and catch violations.

My guess is there is conflict with the require in my app's config and the require present in omakase's config.

https://github.com/rails/rubocop-rails-omakase/blob/main/rubocop.yml#L1-L4

Can anyone steer me in the right direction?

@vietqhoang this is the config I use usually:

inherit_gem:
  rubocop-rails-omakase: rubocop.yml
  rubocop-rspec: config/default.yml
  rubocop-faker: config/default.yml
  action_policy: config/rubocop-rspec.yml
  test-prof:
    - config/default.yml
    - config/rubocop-rspec.yml

require:
  - test_prof/rubocop
  - rubocop-faker
  - rubocop-rspec
  - rubocop-md

require section is used to include new RuboCop cops to your config, at the same time inherit_gem is used to include configuration for those rules.

@igor-alexandrov

Thanks for sharing your config. It led me to get my configuration working.

inherit_gem:
  rubocop-rails-omakase: rubocop.yml
  rubocop-rspec: config/default.yml

require:
  - rubocop-rspec

One other question. Although the cops are working as expected, I am experiencing a lot of output noise from rubocop-rspec. Is this something you also experience? I haven't experienced this in my other projects which use rubocop-rspec. Ideally I would like to silence these if these are just warnings.

/Users/viet/.rvm/gems/ruby-3.3.0/gems/rubocop-rspec-2.26.1/config/default.yml: RSpec/Capybara/CurrentPathExpectation has the wrong namespace - should be Capybara
/Users/viet/.rvm/gems/ruby-3.3.0/gems/rubocop-rspec-2.26.1/config/default.yml: RSpec/Capybara/MatchStyle has the wrong namespace - should be Capybara
/Users/viet/.rvm/gems/ruby-3.3.0/gems/rubocop-rspec-2.26.1/config/default.yml: RSpec/Capybara/NegationMatcher has the wrong namespace - should be Capybara
/Users/viet/.rvm/gems/ruby-3.3.0/gems/rubocop-rspec-2.26.1/config/default.yml: RSpec/Capybara/SpecificActions has the wrong namespace - should be Capybara
/Users/viet/.rvm/gems/ruby-3.3.0/gems/rubocop-rspec-2.26.1/config/default.yml: RSpec/Capybara/SpecificFinders has the wrong namespace - should be Capybara
/Users/viet/.rvm/gems/ruby-3.3.0/gems/rubocop-rspec-2.26.1/config/default.yml: RSpec/Capybara/SpecificMatcher has the wrong namespace - should be Capybara
/Users/viet/.rvm/gems/ruby-3.3.0/gems/rubocop-rspec-2.26.1/config/default.yml: RSpec/Capybara/VisibilityMatcher has the wrong namespace - should be Capybara
/Users/viet/.rvm/gems/ruby-3.3.0/gems/rubocop-rspec-2.26.1/config/default.yml: RSpec/FactoryBot/AttributeDefinedStatically has the wrong namespace - should be FactoryBot
/Users/viet/.rvm/gems/ruby-3.3.0/gems/rubocop-rspec-2.26.1/config/default.yml: RSpec/FactoryBot/ConsistentParenthesesStyle has the wrong namespace - should be FactoryBot
/Users/viet/.rvm/gems/ruby-3.3.0/gems/rubocop-rspec-2.26.1/config/default.yml: RSpec/FactoryBot/CreateList has the wrong namespace - should be FactoryBot
/Users/viet/.rvm/gems/ruby-3.3.0/gems/rubocop-rspec-2.26.1/config/default.yml: RSpec/FactoryBot/FactoryClassName has the wrong namespace - should be FactoryBot
/Users/viet/.rvm/gems/ruby-3.3.0/gems/rubocop-rspec-2.26.1/config/default.yml: RSpec/FactoryBot/FactoryNameStyle has the wrong namespace - should be FactoryBot
/Users/viet/.rvm/gems/ruby-3.3.0/gems/rubocop-rspec-2.26.1/config/default.yml: RSpec/FactoryBot/SyntaxMethods has the wrong namespace - should be FactoryBot

Thanks again. And sorry for derailing the issue.

I have the same warnings when rubocop-rspec is enabled.