Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Requiring 'rubocop-minitest' in config limits all cops to only run on the test/ directory #13

Closed
tayjohno opened this issue Sep 23, 2019 · 2 comments · Fixed by #14
Closed
Labels
bug Something isn't working

Comments

@tayjohno
Copy link

tayjohno commented Sep 23, 2019

First off, thanks for starting a minitest-specific repo! I'm very excited to incorporate this into our Rubocop install. I've noticed that while the current gems are already useful, there's a configuration conflict that's preventing us from being able to use this in its current state.

Expected behavior

Adding the line

require:
  - rubocop-minitest
  ...

should not impact the configuration of existing cops.

Actual behavior

When adding the above line, rubocop ceases to run on any files outside of our /test/ directory. It appears that this configuration is overriding the default configuration for all rubocop gems.

Steps to reproduce the problem

See repo here for a simple reproduction of the issue.

https://github.com/tayjohno/sample-rubocop-minitest-issue

When commenting out the line to include rubocop-minitest, you'll see that the base rubocop gems run on 3 files (Gemfile, lib/sample.rb, and test/sample_test.rb).

$ [bundle exec] rubocop
Inspecting 3 files
.CC

Offenses:

lib/sample.rb:1:1: C: Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.
class Sample
^
test/sample_test.rb:1:1: C: Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.
class SampleTest < Minitest::Test
^
test/sample_test.rb:2:1: C: Layout/EmptyLinesAroundClassBody: Extra empty line detected at class body beginning.

3 files inspected, 3 offenses detected

But when you uncomment the line, even the base rubocop cops only runs on test/sample_test.rb.

$ [bundle exec] rubocop
Inspecting 1 file
C

Offenses:

test/sample_test.rb:1:1: C: Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.
class SampleTest < Minitest::Test
^
test/sample_test.rb:2:1: C: Layout/EmptyLinesAroundClassBody: Extra empty line detected at class body beginning.

1 file inspected, 2 offenses detected

RuboCop version

$ [bundle exec] rubocop -V
0.74.0 (using Parser 2.6.4.1, running on ruby 2.6.2 x86_64-darwin18)
@tayjohno tayjohno changed the title Requiring 'rubocop-minitest' in config limits _all_ cops to only run on the /test directory Requiring 'rubocop-minitest' in config limits all cops to only run on the test/ directory Sep 23, 2019
@koic koic added the bug Something isn't working label Sep 24, 2019
koic added a commit to koic/rubocop-minitest that referenced this issue Sep 24, 2019
…meter

Fixes rubocop#13.

This PR fixes an issue that all cops only executed test directory.
Only test directory should be executed by Minitest department.
@koic
Copy link
Member

koic commented Sep 24, 2019

Thanks for your early feedback using RuboCop Minitest!
I opened a PR #14 and I will cut RuboCop Minitest 0.2.1 soon.

bbatsov pushed a commit that referenced this issue Sep 24, 2019
Fixes #13.

This PR fixes an issue that all cops only executed test directory.
Only test directory should be executed by Minitest department.
@koic
Copy link
Member

koic commented Sep 24, 2019

RuboCop Minitest 0.2.1 has been released. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants