diff options
| author | Gautham Goli | 2017-08-14 00:02:44 +0530 |
|---|---|---|
| committer | Gautham Goli | 2017-08-14 00:02:44 +0530 |
| commit | a73c29fef21ccb7f45243500f04f1ed9965fdf38 (patch) | |
| tree | bf9e910a427cb874cb8a242ed98798030a106780 /Library/Homebrew/rubocops | |
| parent | 77105b809a83583e3da5726105dc9cd913112913 (diff) | |
| download | brew-a73c29fef21ccb7f45243500f04f1ed9965fdf38.tar.bz2 | |
add tests for non glob dirs audit
Diffstat (limited to 'Library/Homebrew/rubocops')
| -rw-r--r-- | Library/Homebrew/rubocops/lines_cop.rb | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/Library/Homebrew/rubocops/lines_cop.rb b/Library/Homebrew/rubocops/lines_cop.rb index 604de5af9..7a0e08ba2 100644 --- a/Library/Homebrew/rubocops/lines_cop.rb +++ b/Library/Homebrew/rubocops/lines_cop.rb @@ -255,11 +255,14 @@ module RuboCop problem "\"#{m.source}\" is deprecated, use a comparison to MacOS.version instead" end end - # - # dirPattern(body_node) do |m| - # next unless m =~ /\[("[^\*{},]+")\]/ - # problem "Dir(#{Regexp.last_match(1)}) is unnecessary; just use #{Regexp.last_match(1)}" - # end + + find_instance_method_call(body_node, "Dir", :[]) do |m| + path = parameters(m).first + next if !path.str_type? + next unless match = regex_match_group(path, /^[^\*{},]+$/) + 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| |
