Commit 68ee371d authored by Igor Drozdov's avatar Igor Drozdov

Merge branch 'speed_up_last_keyword_cop' into 'master'

[RUN ALL RSPEC] Speed up last keyword cop

See merge request gitlab-org/gitlab!51288
parents dbe2280c 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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment