homebrew-core/Formula/checkstyle.rb
2017-11-26 09:32:48 -08:00

23 lines
850 B
Ruby

class Checkstyle < Formula
desc "Check Java source against a coding standard"
homepage "https://checkstyle.sourceforge.io/"
url "https://downloads.sourceforge.net/project/checkstyle/checkstyle/8.5/checkstyle-8.5-all.jar"
sha256 "b5ac50636af5916afe2236186910b481d9183fced55e772157aef1281a3cabc9"
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