homebrew-core/Formula/detekt.rb

36 lines
1.0 KiB
Ruby

class Detekt < Formula
desc "Static code analysis for Kotlin"
homepage "https://github.com/detekt/detekt"
url "https://jcenter.bintray.com/io/gitlab/arturbosch/detekt/detekt-cli/1.12.0/detekt-cli-1.12.0-all.jar"
sha256 "5882061e29077ccee52cb1b3cdeaeea5aab4023f1edc034b3ab61636c28f03ff"
license "Apache-2.0"
livecheck do
url :homepage
regex(/^v?(\d+(?:\.\d+)+)$/i)
end
bottle :unneeded
depends_on "openjdk"
def install
libexec.install "detekt-cli-#{version}-all.jar"
bin.write_jar_script libexec/"detekt-cli-#{version}-all.jar", "detekt"
end
test do
# generate default config for testing
system bin/"detekt", "--generate-config"
assert_match "empty-blocks:", File.read(testpath/"detekt.yml")
(testpath/"input.kt").write <<~EOS
fun main() {
}
EOS
shell_output("#{bin}/detekt --input input.kt --report txt:output.txt --config #{testpath}/detekt.yml", 2)
assert_equal "EmptyFunctionBlock", shell_output("cat output.txt").slice(/\w+/)
end
end