aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/rubocops
diff options
context:
space:
mode:
authorGautham Goli2017-08-14 21:34:01 +0530
committerGautham Goli2017-08-14 21:45:01 +0530
commit9c9c280c8aeb97a6ec8956242727208d80247826 (patch)
treed491280f749e0924db7355d82854941c3a56359a /Library/Homebrew/rubocops
parent65ae6bacd8c92d718b259f7efd50fc3fe9f0838b (diff)
downloadbrew-9c9c280c8aeb97a6ec8956242727208d80247826.tar.bz2
add tests for formula path string 1
Diffstat (limited to 'Library/Homebrew/rubocops')
-rw-r--r--Library/Homebrew/rubocops/lines_cop.rb38
1 files changed, 19 insertions, 19 deletions
diff --git a/Library/Homebrew/rubocops/lines_cop.rb b/Library/Homebrew/rubocops/lines_cop.rb
index 919b21243..49eff510d 100644
--- a/Library/Homebrew/rubocops/lines_cop.rb
+++ b/Library/Homebrew/rubocops/lines_cop.rb
@@ -118,24 +118,24 @@ module RuboCop
end
end
- # # Prefer formula path shortcuts in strings
- # formula_path_strings(body_node, :prefix) do |p|
- # next unless match = regex_match_group(p, %r{(/(man))[/'"]})
- # problem "\"\#\{prefix}#{match[1]}\" should be \"\#{#{match[3]}}\""
- # end
- #
- # formula_path_strings(body_node, :share) do |p|
- # if match = regex_match_group(p, %r{/(bin|include|libexec|lib|sbin|share|Frameworks)}i)
- # problem "\"\#\{prefix}#{match[1]}\" should be \"\#{#{match[1].downcase}}\""
- # end
- # if match = regex_match_group(p, %r{((/share/man/|\#\{man\}/)(man[1-8]))})
- # problem "\"\#\{prefix}#{match[1]}\" should be \"\#{#{match[3]}}\""
- # end
- # if match = regex_match_group(p, %r{(/share/(info|man))})
- # problem "\"\#\{prefix}#{match[1]}\" should be \"\#{#{match[2]}}\""
- # end
- # end
- #
+ # Prefer formula path shortcuts in strings
+ formula_path_strings(body_node, :share) do |p|
+ next unless match = regex_match_group(p, %r{(/(man))/?})
+ problem "\"\#\{share}#{match[1]}\" should be \"\#{#{match[2]}}\""
+ end
+
+ formula_path_strings(body_node, :share) do |p|
+ if match = regex_match_group(p, %r{/(bin|include|libexec|lib|sbin|share|Frameworks)}i)
+ problem "\"\#\{prefix}#{match[1]}\" should be \"\#{#{match[1].downcase}}\""
+ end
+ if match = regex_match_group(p, %r{((/share/man/|\#\{man\}/)(man[1-8]))})
+ problem "\"\#\{prefix}#{match[1]}\" should be \"\#{#{match[3]}}\""
+ end
+ if match = regex_match_group(p, %r{(/share/(info|man))})
+ problem "\"\#\{prefix}#{match[1]}\" should be \"\#{#{match[2]}}\""
+ end
+ end
+
# find_every_method_call_by_name(body_node, :depends_on) do |m|
# key, value = destructure_hash(paramters(m).first)
# next unless key.str_type?
@@ -349,7 +349,7 @@ module RuboCop
(hash (pair $_ $_))
EOS
- def_node_matcher :formula_path_strings, <<-EOS.undent
+ def_node_search :formula_path_strings, <<-EOS.undent
(dstr (begin (send nil %1)) $(str _ ))
EOS