Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
e3e74662
Commit
e3e74662
authored
Aug 28, 2018
by
Jacopo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handles when ClassMethods is used inside a class
parent
a1cad13b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
2 deletions
+15
-2
rubocop/cop/prefer_class_methods_over_module.rb
rubocop/cop/prefer_class_methods_over_module.rb
+4
-2
spec/rubocop/cop/prefer_class_methods_over_module_spec.rb
spec/rubocop/cop/prefer_class_methods_over_module_spec.rb
+11
-0
No files found.
rubocop/cop/prefer_class_methods_over_module.rb
View file @
e3e74662
...
...
@@ -48,7 +48,7 @@ module RuboCop
private
def
extends_activesupport_concern?
(
node
)
container_module
=
container_module_of
(
node
.
parent
)
container_module
=
container_module_of
(
node
)
return
false
unless
container_module
container_module
.
descendants
.
any?
do
|
descendant
|
...
...
@@ -57,7 +57,9 @@ module RuboCop
end
def
container_module_of
(
node
)
node
=
node
.
parent
until
node
.
type
==
:module
while
node
=
node
.
parent
break
if
node
.
type
==
:module
end
node
end
...
...
spec/rubocop/cop/prefer_class_methods_over_module_spec.rb
View file @
e3e74662
...
...
@@ -48,6 +48,17 @@ describe RuboCop::Cop::PreferClassMethodsOverModule do
RUBY
end
it
"doesn't flag violation when ClassMethods is used inside a class"
do
expect_no_offenses
(
<<~
RUBY
)
class Foo
module ClassMethods
def a_class_method
end
end
end
RUBY
end
it
"doesn't flag violation when not using either class_methods or ClassMethods"
do
expect_no_offenses
(
<<~
RUBY
)
module Foo
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment