homebrew-core/Formula/checkstyle.rb
2018-07-01 15:45:17 +01:00

23 lines
858 B
Ruby

class Checkstyle < Formula
desc "Check Java source against a coding standard"
homepage "https://checkstyle.sourceforge.io/"
url "https://github.com/checkstyle/checkstyle/releases/download/checkstyle-8.11/checkstyle-8.11-all.jar"
sha256 "9bbbaa85a9d2efca3c504bb8282d1a72feb8b0149551a616313de66333a9a48f"
bottle :unneeded
def install
libexec.install "checkstyle-#{version}-all.jar"
bin.write_jar_script libexec/"checkstyle-#{version}-all.jar", "checkstyle"
end
test do
path = testpath/"foo.java"
path.write "public class Foo{ }\n"
output = `#{bin}/checkstyle -c /sun_checks.xml #{path}`
errors = output.lines.select { |line| line.start_with?("[ERROR] #{path}") }
assert_match "#{path}:1:17: '{' is not preceded with whitespace.", errors.join(" ")
assert_equal errors.size, $CHILD_STATUS.exitstatus
end
end