-
Notifications
You must be signed in to change notification settings - Fork 280
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
Do not raise Utilityfunction for methods defined in a class_method block #1596
base: master
Are you sure you want to change the base?
Changes from 1 commit
1c5bbfb
e5b3933
ee1ca9d
f819833
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -177,6 +177,27 @@ def bravo(charlie) | |
end | ||
end | ||
|
||
context 'when examining class_methods block' do | ||
it 'reports on the refined class' do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This description seems wrong. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Opps, ctrl + C problems |
||
src = <<-RUBY | ||
module Alpha | ||
extend ActiveSupport::Concern | ||
|
||
class_methods do | ||
def bravo(arg1, arg2) | ||
return 1 if arg1.something? | ||
return 2 if arg2.something_else? | ||
|
||
3 | ||
end | ||
end | ||
end | ||
RUBY | ||
|
||
expect(src).not_to reek_of(:UtilityFunction, context: 'Alpha#bravo') | ||
end | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you also add a test case that shows that methods defined outside the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup |
||
|
||
describe 'method visibility' do | ||
it 'reports private methods' do | ||
src = <<-RUBY | ||
|
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.
Is there a way to
pattern match
thes(:send, nil, class_methods)
node directly?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.
You can check
node.name == :class_methods