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

[Fix #5261] Fix false positive for Style/MixinUsage when using inside module #5272

Merged
merged 1 commit into from Dec 20, 2017

Conversation

koic
Copy link
Member

@koic koic commented Dec 18, 2017

Fixes #5261.

Correspondence to use case for include belonging to module was insufficient. This PR added a reproduction test and fixed it.


Before submitting the PR make sure the following are checked:

  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Added an entry to the Changelog if the new code introduces user-observable changes. See changelog entry format.
  • The PR relates to only one subject with a clear title
    and description in grammatically correct, complete sentences.
  • Run rake default or rake parallel. It executes all tests and RuboCop for itself, and generates the documentation.

@@ -58,6 +68,28 @@ class C
RUBY
end

it 'registers an offense when using `include` in method definition ' \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does not register :-)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops! I fixed it 💦

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was a slight misunderstanding. This was good with registers, the other was not good. #5272 (comment)

Thank you for pointing out.

RUBY
end

it 'registers an offense when using `include` in method definition ' \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does not register :-)

@koic koic force-pushed the fix_false_positive_for_style_mixin_cop branch from df1e39c to ee78395 Compare December 18, 2017 08:03
…ng inside module

Fixes rubocop#5261.

Correspondence to use case for `include` belonging to module was
insufficient. This PR added a reproduction test and fixed it.
@koic koic force-pushed the fix_false_positive_for_style_mixin_cop branch from ee78395 to 1e491db Compare December 19, 2017 04:53
Copy link
Contributor

@garettarrowood garettarrowood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@buehmann
Copy link
Contributor

For the record: This PR also seems to fix false positives that we're seeing with 0.52.0 on code like

class Foo
  if GlobalConfig.special_logging?
    include LogInstrumentation
  end
end

@bbatsov bbatsov merged commit 02cfcfe into rubocop:master Dec 20, 2017
@koic koic deleted the fix_false_positive_for_style_mixin_cop branch December 20, 2017 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

false positive for Style/Mixin
4 participants