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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
dcb9e6f5
Commit
dcb9e6f5
authored
Jan 11, 2021
by
Thong Kuah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Speed up by reducing iterations
parent
0b34288f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
3 deletions
+15
-3
rubocop/cop/lint/last_keyword_argument.rb
rubocop/cop/lint/last_keyword_argument.rb
+15
-3
No files found.
rubocop/cop/lint/last_keyword_argument.rb
View file @
dcb9e6f5
...
...
@@ -52,11 +52,14 @@ module RuboCop
def
known_match?
(
file_path
,
line_number
,
method_name
)
file_path_from_root
=
file_path
.
sub
(
File
.
expand_path
(
'../../..'
,
__dir__
),
''
)
file_and_line
=
"
#{
file_path_from_root
}
:
#{
line_number
}
"
method_name
=
'initialize'
if
method_name
==
'new'
self
.
class
.
keyword_warnings
.
any?
do
|
warning
|
warning
.
include?
(
"
#{
file_path_from_root
}
:
#{
line_number
}
"
)
&&
warning
.
include?
(
"called method `
#{
method_name
}
'"
)
return
unless
self
.
class
.
keyword_warnings
[
method_name
]
self
.
class
.
keyword_warnings
[
method_name
].
any?
do
|
warning
|
warning
.
include?
(
file_and_line
)
end
end
...
...
@@ -69,7 +72,16 @@ module RuboCop
hash
.
merge!
(
YAML
.
safe_load
(
File
.
read
(
file
)))
end
hash
.
values
.
flatten
.
select
{
|
str
|
str
.
include?
(
KEYWORD_DEPRECATION_STR
)
}.
uniq
hash
.
values
.
flatten
.
each_with_object
({})
do
|
str
,
results
|
next
unless
str
.
include?
(
KEYWORD_DEPRECATION_STR
)
match_data
=
str
.
match
(
/called method `([^\s]+)'/
)
next
unless
match_data
key
=
match_data
[
1
]
results
[
key
]
||=
[]
results
[
key
]
<<
str
end
end
end
end
...
...
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