diff options
| author | Gautham Goli | 2017-08-04 01:18:00 +0530 |
|---|---|---|
| committer | Gautham Goli | 2017-09-04 15:05:43 +0530 |
| commit | 267def28faab69388be3bc6347c0644f6ca812e8 (patch) | |
| tree | 2661e64f50ae36b17819ce7cced1ca9ba6c1bfb1 /Library/Homebrew/rubocops/lines_cop.rb | |
| parent | 751334a257d81851e68da7ab390982d4e9fdf909 (diff) | |
| download | brew-267def28faab69388be3bc6347c0644f6ca812e8.tar.bz2 | |
audit: Port rules from line_problems to rubocop part 3
Diffstat (limited to 'Library/Homebrew/rubocops/lines_cop.rb')
| -rw-r--r-- | Library/Homebrew/rubocops/lines_cop.rb | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/Library/Homebrew/rubocops/lines_cop.rb b/Library/Homebrew/rubocops/lines_cop.rb index ed50ba49c..241f9860e 100644 --- a/Library/Homebrew/rubocops/lines_cop.rb +++ b/Library/Homebrew/rubocops/lines_cop.rb @@ -67,7 +67,71 @@ module RuboCop next unless block_arg.source.size>1 problem "\"inreplace <filenames> do |s|\" is preferred over \"|#{block_arg.source}|\"." end + + [:rebuild, :version_scheme].each do |method_name| + find_method_with_args(body_node, method_name, 0) do + problem "'#{method_name} 0' should be removed" + end + end + + [:mac?, :linux?].each do |method_name| + next unless formula_tap == "homebrew-core" + find_instance_method_call(body_node, "OS", method_name) do |check| + problem "Don't use #{check.source}; Homebrew/core only supports macOS" + end + end + + find_method_with_args(body_node, :fails_with, :llvm) do + problem "'fails_with :llvm' is now a no-op so should be removed" + end + + find_method_with_args(body_node, :system, /^(otool|install_name_tool|lipo)$/) do + next if @formula_name == "Cctools" + problem "Use ruby-macho instead of calling #{@offensive_node.source}" + end + + find_every_method_call_by_name(body_node, :system).each do |method_node| + next if @formula_name =~ /^Kibana(\@\d+(\.\d+)?)?$/ + first_param, second_param = parameters(method_node) + next if !node_equals?(first_param, "npm") || + !node_equals?(second_param, "install") + offending_node(method_node) + problem "Use Language::Node for npm install args" unless languageNodeModule?(method_node) + end + + if find_method_def(body_node, :test) + problem "Use new-style test definitions (test do)" + end + + if find_method_def(body_node, :options) + problem "Use new-style option definitions" + end + + find_method_with_args(body_node, :skip_clean, :all) do + problem <<-EOS.undent.chomp + `skip_clean :all` is deprecated; brew no longer strips symbols + Pass explicit paths to prevent Homebrew from removing empty folders. + EOS + end + + find_instance_method_call(body_node, :build, :universal?) do + next if @formula_name == "Wine" + problem "macOS has been 64-bit only so build.universal? is deprecated." + end + + find_instance_method_call(body_node, "ENV", :universal_binary) do + problem "macOS has been 64-bit only since 10.6 so ENV.universal_binary is deprecated." + end + + find_instance_method_call(body_node, "ENV", :x11) do + problem 'Use "depends_on :x11" instead of "ENV.x11"' + end end + + # Node Pattern search for Language::Node + def_node_search :languageNodeModule?, <<-EOS.undent + (const (const nil :Language) :Node) + EOS end end end |
