rails / rubocop-rails-omakase

Omakase Ruby styling for Rails
442 stars 15 forks source link

Consider removing rubocop-minitest dependency #13

Closed igor-alexandrov closed 6 hours ago

igor-alexandrov commented 10 months ago

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?

vietqhoang commented 8 months ago

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?

igor-alexandrov commented 8 months ago

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

vietqhoang commented 8 months ago

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

igor-alexandrov commented 8 months ago

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