aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/rubocops
diff options
context:
space:
mode:
authorGautham Goli2017-08-14 01:09:06 +0530
committerGautham Goli2017-08-14 01:09:06 +0530
commit7dfe09ccae5b1a8309326e5a5cb3172fbcd795d3 (patch)
tree56aacffccfa1429c195837f7ea2f75d3c0c2b1f0 /Library/Homebrew/rubocops
parenta73c29fef21ccb7f45243500f04f1ed9965fdf38 (diff)
downloadbrew-7dfe09ccae5b1a8309326e5a5cb3172fbcd795d3.tar.bz2
Add tests for fileUtils call in system
Diffstat (limited to 'Library/Homebrew/rubocops')
-rw-r--r--Library/Homebrew/rubocops/lines_cop.rb15
1 files changed, 8 insertions, 7 deletions
diff --git a/Library/Homebrew/rubocops/lines_cop.rb b/Library/Homebrew/rubocops/lines_cop.rb
index 7a0e08ba2..1b7a1935e 100644
--- a/Library/Homebrew/rubocops/lines_cop.rb
+++ b/Library/Homebrew/rubocops/lines_cop.rb
@@ -263,13 +263,14 @@ module RuboCop
problem "Dir([\"#{string_content(path)}\"]) is unnecessary; just use \"#{match[0]}\""
end
- #
- # fileUtils_methods= FileUtils.singleton_methods(false).map { |m| Regexp.escape(m) }.join "|"
- # find_method_with_args(body_node, :system, /fileUtils_methods/) do |m|
- # method = string_content(@offensive_node)
- # problem "Use the `#{method}` Ruby method instead of `#{m.source}`"
- # end
- #
+
+ fileUtils_methods= Regexp.new(FileUtils.singleton_methods(false).map { |m| Regexp.escape(m) }.join "|")
+ find_every_method_call_by_name(body_node, :system).each do |m|
+ param = parameters(m).first
+ next unless match = regex_match_group(param, fileUtils_methods)
+ problem "Use the `#{match}` Ruby method instead of `#{m.source}`"
+ end
+
# if find_method_def(@processed_source.ast)
# problem "Define method #{method_name(@offensive_node)} in the class body, not at the top-level"
# end