aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/dev-cmd/audit.rb
diff options
context:
space:
mode:
Diffstat (limited to 'Library/Homebrew/dev-cmd/audit.rb')
-rw-r--r--Library/Homebrew/dev-cmd/audit.rb168
1 files changed, 0 insertions, 168 deletions
diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb
index ec26eb9cd..bfe4dbc00 100644
--- a/Library/Homebrew/dev-cmd/audit.rb
+++ b/Library/Homebrew/dev-cmd/audit.rb
@@ -820,168 +820,12 @@ class FormulaAuditor
problem "\"(#{Regexp.last_match(1)}...#{Regexp.last_match(2)})\" should be \"(#{Regexp.last_match(3).downcase}+...)\""
end
- if line =~ /((man)\s*\+\s*(['"])(man[1-8])(['"]))/
- problem "\"#{Regexp.last_match(1)}\" should be \"#{Regexp.last_match(4)}\""
- end
-
- # Prefer formula path shortcuts in strings
- if line =~ %r[(\#\{prefix\}/(bin|include|libexec|lib|sbin|share|Frameworks))]
- problem "\"#{Regexp.last_match(1)}\" should be \"\#{#{Regexp.last_match(2).downcase}}\""
- end
-
- if line =~ %r[((\#\{prefix\}/share/man/|\#\{man\}/)(man[1-8]))]
- problem "\"#{Regexp.last_match(1)}\" should be \"\#{#{Regexp.last_match(3)}}\""
- end
-
- if line =~ %r[((\#\{share\}/(man)))[/'"]]
- problem "\"#{Regexp.last_match(1)}\" should be \"\#{#{Regexp.last_match(3)}}\""
- end
-
- if line =~ %r[(\#\{prefix\}/share/(info|man))]
- problem "\"#{Regexp.last_match(1)}\" should be \"\#{#{Regexp.last_match(2)}}\""
- end
-
- if line =~ /depends_on\s+['"](.+)['"]\s+=>\s+:(lua|perl|python|ruby)(\d*)/
- problem "#{Regexp.last_match(2)} modules should be vendored rather than use deprecated `depends_on \"#{Regexp.last_match(1)}\" => :#{Regexp.last_match(2)}#{Regexp.last_match(3)}`"
- end
-
- if line =~ /depends_on\s+['"](.+)['"]\s+=>\s+(.*)/
- dep = Regexp.last_match(1)
- Regexp.last_match(2).split(" ").map do |o|
- break if ["if", "unless"].include?(o)
- next unless o =~ /^\[?['"](.*)['"]/
- problem "Dependency #{dep} should not use option #{Regexp.last_match(1)}"
- end
- end
-
- if line =~ /if\s+ARGV\.include\?\s+'--(HEAD|devel)'/
- problem "Use \"if build.#{Regexp.last_match(1).downcase}?\" instead"
- end
-
problem "Use separate make calls" if line.include?("make && make")
- problem "Use spaces instead of tabs for indentation" if line =~ /^[ ]*\t/
-
- if line.include?("ENV.java_cache")
- problem "In-formula ENV.java_cache usage has been deprecated & should be removed."
- end
-
- # Avoid hard-coding compilers
- if line =~ %r{(system|ENV\[.+\]\s?=)\s?['"](/usr/bin/)?(gcc|llvm-gcc|clang)['" ]}
- problem "Use \"\#{ENV.cc}\" instead of hard-coding \"#{Regexp.last_match(3)}\""
- end
-
- if line =~ %r{(system|ENV\[.+\]\s?=)\s?['"](/usr/bin/)?((g|llvm-g|clang)\+\+)['" ]}
- problem "Use \"\#{ENV.cxx}\" instead of hard-coding \"#{Regexp.last_match(3)}\""
- end
-
- if line =~ /system\s+['"](env|export)(\s+|['"])/
- problem "Use ENV instead of invoking '#{Regexp.last_match(1)}' to modify the environment"
- end
-
- if line =~ /version == ['"]HEAD['"]/
- problem "Use 'build.head?' instead of inspecting 'version'"
- end
-
- if line =~ /build\.include\?[\s\(]+['"]\-\-(.*)['"]/
- problem "Reference '#{Regexp.last_match(1)}' without dashes"
- end
-
- if line =~ /build\.include\?[\s\(]+['"]with(out)?-(.*)['"]/
- problem "Use build.with#{Regexp.last_match(1)}? \"#{Regexp.last_match(2)}\" instead of build.include? 'with#{Regexp.last_match(1)}-#{Regexp.last_match(2)}'"
- end
-
- if line =~ /build\.with\?[\s\(]+['"]-?-?with-(.*)['"]/
- problem "Don't duplicate 'with': Use `build.with? \"#{Regexp.last_match(1)}\"` to check for \"--with-#{Regexp.last_match(1)}\""
- end
-
- if line =~ /build\.without\?[\s\(]+['"]-?-?without-(.*)['"]/
- problem "Don't duplicate 'without': Use `build.without? \"#{Regexp.last_match(1)}\"` to check for \"--without-#{Regexp.last_match(1)}\""
- end
-
- if line =~ /unless build\.with\?(.*)/
- problem "Use if build.without?#{Regexp.last_match(1)} instead of unless build.with?#{Regexp.last_match(1)}"
- end
-
- if line =~ /unless build\.without\?(.*)/
- problem "Use if build.with?#{Regexp.last_match(1)} instead of unless build.without?#{Regexp.last_match(1)}"
- end
-
- if line =~ /(not\s|!)\s*build\.with?\?/
- problem "Don't negate 'build.with?': use 'build.without?'"
- end
-
- if line =~ /(not\s|!)\s*build\.without?\?/
- problem "Don't negate 'build.without?': use 'build.with?'"
- end
-
- if line =~ /ARGV\.(?!(debug\?|verbose\?|value[\(\s]))/
- problem "Use build instead of ARGV to check options"
- end
-
- if line.include?("MACOS_VERSION")
- problem "Use MacOS.version instead of MACOS_VERSION"
- end
-
- if line.include?("MACOS_FULL_VERSION")
- problem "Use MacOS.full_version instead of MACOS_FULL_VERSION"
- end
-
- cats = %w[leopard snow_leopard lion mountain_lion].join("|")
- if line =~ /MacOS\.(?:#{cats})\?/
- problem "\"#{$&}\" is deprecated, use a comparison to MacOS.version instead"
- end
-
- if line =~ /depends_on [A-Z][\w:]+\.new$/
- problem "`depends_on` can take requirement classes instead of instances"
- end
-
- if line =~ /^def (\w+).*$/
- problem "Define method #{Regexp.last_match(1).inspect} in the class body, not at the top-level"
- end
-
- if line.include?("ENV.fortran") && !formula.requirements.map(&:class).include?(FortranRequirement)
- problem "Use `depends_on :fortran` instead of `ENV.fortran`"
- end
-
if line =~ /JAVA_HOME/i && !formula.requirements.map(&:class).include?(JavaRequirement)
problem "Use `depends_on :java` to set JAVA_HOME"
end
- if line =~ /depends_on :(.+) (if.+|unless.+)$/
- conditional_dep_problems(Regexp.last_match(1).to_sym, Regexp.last_match(2), $&)
- end
-
- if line =~ /depends_on ['"](.+)['"] (if.+|unless.+)$/
- conditional_dep_problems(Regexp.last_match(1), Regexp.last_match(2), $&)
- end
-
- if line =~ /(Dir\[("[^\*{},]+")\])/
- problem "#{Regexp.last_match(1)} is unnecessary; just use #{Regexp.last_match(2)}"
- end
-
- if line =~ /system (["'](#{FILEUTILS_METHODS})["' ])/o
- system = Regexp.last_match(1)
- method = Regexp.last_match(2)
- problem "Use the `#{method}` Ruby method instead of `system #{system}`"
- end
-
- if line =~ /assert [^!]+\.include?/
- problem "Use `assert_match` instead of `assert ...include?`"
- end
-
- if line =~ /(assert File\.exist\?|assert \(.*\)\.exist\?)/
- problem "Use `assert_predicate <path_to_file>, :exist?` instead of `#{Regexp.last_match(1)}`"
- end
-
- if line =~ /(assert !File\.exist\?|assert !\(.*\)\.exist\?)/
- problem "Use `refute_predicate <path_to_file>, :exist?` instead of `#{Regexp.last_match(1)}`"
- end
-
- if line =~ /(assert File\.executable\?|assert \(.*\)\.executable\?)/
- problem "Use `assert_predicate <path_to_file>, :executable?` instead of `#{Regexp.last_match(1)}`"
- end
-
return unless @strict
problem "`#{Regexp.last_match(1)}` in formulae is deprecated" if line =~ /(env :(std|userpaths))/
@@ -1028,18 +872,6 @@ class FormulaAuditor
EOS
end
- def conditional_dep_problems(dep, condition, line)
- quoted_dep = quote_dep(dep)
- dep = Regexp.escape(dep.to_s)
-
- case condition
- when /if build\.include\? ['"]with-#{dep}['"]$/, /if build\.with\? ['"]#{dep}['"]$/
- problem %Q(Replace #{line.inspect} with "depends_on #{quoted_dep} => :optional")
- when /unless build\.include\? ['"]without-#{dep}['"]$/, /unless build\.without\? ['"]#{dep}['"]$/
- problem %Q(Replace #{line.inspect} with "depends_on #{quoted_dep} => :recommended")
- end
- end
-
def quote_dep(dep)
dep.is_a?(Symbol) ? dep.inspect : "'#{dep}'"
end