diff options
| author | Gautham Goli | 2017-07-31 14:30:37 +0530 |
|---|---|---|
| committer | Gautham Goli | 2017-08-06 02:28:58 +0530 |
| commit | 7614d2cc8be065c33f4e4e893ccd1f0995a05401 (patch) | |
| tree | 8c18e57e87ac395a87eb2b4fa9c4c91f2aa7e606 /Library/Homebrew/rubocops/lines_cop.rb | |
| parent | affd9055c2aaaf3535ed1cb778b65a4bee5ef0e2 (diff) | |
| download | brew-7614d2cc8be065c33f4e4e893ccd1f0995a05401.tar.bz2 | |
audit: Port FileUtils, inreplace audit rules in audit_lines to rubocop
Diffstat (limited to 'Library/Homebrew/rubocops/lines_cop.rb')
| -rw-r--r-- | Library/Homebrew/rubocops/lines_cop.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Library/Homebrew/rubocops/lines_cop.rb b/Library/Homebrew/rubocops/lines_cop.rb index abd46162f..ed50ba49c 100644 --- a/Library/Homebrew/rubocops/lines_cop.rb +++ b/Library/Homebrew/rubocops/lines_cop.rb @@ -52,6 +52,23 @@ module RuboCop end end end + + class Miscellaneous < FormulaCop + def audit_formula(_node, _class_node, _parent_class_node, body_node) + # FileUtils is included in Formula + # encfs modifies a file with this name, so check for some leading characters + find_instance_method_call(body_node, "FileUtils", nil) do |method_node| + problem "Don't need 'FileUtils.' before #{method_node.method_name}" + end + + # Check for long inreplace block vars + find_all_blocks(body_node, :inreplace) do |node| + block_arg = node.arguments.children.first + next unless block_arg.source.size>1 + problem "\"inreplace <filenames> do |s|\" is preferred over \"|#{block_arg.source}|\"." + end + end + end end end end |
