-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
Fix some false negatives for Minitest/GlobalExpectations
#72
Conversation
bbbe4e3
to
8cf3bb9
Compare
@@ -162,6 +162,51 @@ class GlobalExpectationsTest < Minitest::Test | |||
end | |||
RUBY | |||
end | |||
|
|||
define_method(:"registers_offense_when_using_global_#{matcher}_for_chained_hash_reference") do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To run a test, the prefix must start with test_
.
define_method(:"registers_offense_when_using_global_#{matcher}_for_chained_hash_reference") do | |
define_method(:"test_registers_offense_when_using_global_#{matcher}_for_chained_hash_reference") do |
And, if an appropriate method name exceeds the maximum length of Layout/LineLength
, this repository allows the maximum length of Layout/LineLength
of .rubocop_todo.yml to be increased. In that case, I think it will be 120 or less.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@koic Good catch. It was just a typo when I polish the final formatting of the new specs. Fixed 👍.
Also I increased Layout/LineLength
in the .rubocop.yml
file and keep .rubocop_todo.yml
unchanged as far as it's an autogenerated file. Please let me know it there is a more convenient way to increase a line max length and to solve the issue.
RUBY | ||
end | ||
|
||
define_method(:"registers_offense_when_using_global_#{matcher}_for_method_call_with_params") do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
define_method(:"registers_offense_when_using_global_#{matcher}_for_method_call_with_params") do | |
define_method(:"test_registers_offense_when_using_global_#{matcher}_for_method_call_with_params") do |
RUBY | ||
end | ||
|
||
define_method(:"registers_offense_when_using_global_#{matcher}_for_constant") do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
define_method(:"registers_offense_when_using_global_#{matcher}_for_constant") do | |
define_method(:"test_registers_offense_when_using_global_#{matcher}_for_constant") do |
.rubocop.yml
Outdated
@@ -51,6 +51,9 @@ Layout/ClassStructure: | |||
Layout/TrailingWhitespace: | |||
AllowInHeredoc: true | |||
|
|||
Layout/LineLength: | |||
Max: 120 | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you update .rubocop_todo.yml, not .rubocop.yml in this PR?
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -20,4 +20,4 @@ Metrics/MethodLength:
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Layout/LineLength:
- Max: 100
+ Max: 120
And other changes looks good to me. Can you squash your commits into one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@koic Done.
I fixed my mistake I've introduced in the pattern. The new pattern didn't support _
's aliases - value
and expect
. Added proper tests.
f215c92
to
29c8418
Compare
29c8418
to
20df3f6
Compare
Thanks! |
Fixed some use cases for the
Minitest/GlobalExpectations
cop.I have noticed there are cases when the cop doesn't produce offenses:
Let's look at some examples which the cope ignores:
Related links
DEPRECATED: global use of must_equal from ... Use _(obj).must_equal instead. This will fail in Minitest 6.
#60Minitest/GlobalExpectations
#63Minitest/GlobalExpectations
cop #69Before submitting the PR make sure the following are checked:
[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).and description in grammatically correct, complete sentences.
bundle exec rake default
. It executes all tests and RuboCop for itself, and generates the documentation.