homebrew-core/Formula/checkstyle.rb

27 lines
929 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.38/checkstyle-8.38-all.jar"
sha256 "340f3c51b9e86607ceaebba7e10004acf8a67e4ad535a900b9da89b1633993c8"
license "LGPL-2.1-or-later"
bottle :unneeded
depends_on "openjdk"
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 = shell_output("#{bin}/checkstyle -c /sun_checks.xml #{path}", 2)
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