homebrew-core/Formula/checkstyle.rb

29 lines
1.0 KiB
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-10.5.0/checkstyle-10.5.0-all.jar"
sha256 "19b3d503f67d4743fda6b2531495024d5f69abdfc26e5e943a3c2102585ef410"
license "LGPL-2.1-or-later"
bottle do
sha256 cellar: :any_skip_relocation, all: "b8d4bd78ad3a0656d64bed81ac7cd60b414e7b36aa431c28ae956a97f79b8da5"
end
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