73 lines
2.4 KiB
Ruby
73 lines
2.4 KiB
Ruby
class GolangciLint < Formula
|
|
desc "Fast linters runner for Go"
|
|
homepage "https://golangci-lint.run/"
|
|
url "https://github.com/golangci/golangci-lint.git",
|
|
tag: "v1.40.1",
|
|
revision: "625445b1f559dc0a09bc9345dc39d50b64ec18bc"
|
|
license "GPL-3.0-only"
|
|
head "https://github.com/golangci/golangci-lint.git"
|
|
|
|
bottle do
|
|
sha256 cellar: :any_skip_relocation, arm64_big_sur: "99f5940cc7009547c836731a5e355a48c48ec4b4db4c1981de917e5180d762bf"
|
|
sha256 cellar: :any_skip_relocation, big_sur: "aa674d9c79c61a7ed07c456e4de5bc3134bd052515f0a2eb74bc41dd8ab73053"
|
|
sha256 cellar: :any_skip_relocation, catalina: "a43381bd424f7d8e354f6f4f1f46b61540dbca823c876f4ab14a455a80e2cd3a"
|
|
sha256 cellar: :any_skip_relocation, mojave: "adf0d30778c4d687259fed2d1fae5b0bd8750403ba47247706c130d373544341"
|
|
end
|
|
|
|
depends_on "go"
|
|
|
|
def install
|
|
ldflags = %W[
|
|
-s -w
|
|
-X main.version=#{version}
|
|
-X main.commit=#{Utils.git_short_head(length: 7)}
|
|
-X main.date=#{Time.now.utc.rfc3339}
|
|
].join(" ")
|
|
|
|
system "go", "build", *std_go_args, "-ldflags", ldflags, "./cmd/golangci-lint"
|
|
|
|
output = Utils.safe_popen_read("#{bin}/golangci-lint", "completion", "bash")
|
|
(bash_completion/"golangci-lint").write output
|
|
|
|
output = Utils.safe_popen_read("#{bin}/golangci-lint", "completion", "zsh")
|
|
(zsh_completion/"_golangci-lint").write output
|
|
|
|
output = Utils.safe_popen_read("#{bin}/golangci-lint", "completion", "fish")
|
|
(fish_completion/"golangci-lint.fish").write output
|
|
end
|
|
|
|
test do
|
|
str_version = shell_output("#{bin}/golangci-lint --version")
|
|
assert_match "golangci-lint has version #{version} built from", str_version
|
|
|
|
str_help = shell_output("#{bin}/golangci-lint --help")
|
|
str_default = shell_output("#{bin}/golangci-lint")
|
|
assert_equal str_default, str_help
|
|
assert_match "Usage:", str_help
|
|
assert_match "Available Commands:", str_help
|
|
|
|
(testpath/"try.go").write <<~EOS
|
|
package try
|
|
|
|
func add(nums ...int) (res int) {
|
|
for _, n := range nums {
|
|
res += n
|
|
}
|
|
return
|
|
}
|
|
EOS
|
|
|
|
args = %w[
|
|
--color=never
|
|
--disable-all
|
|
--issues-exit-code=0
|
|
--print-issued-lines=false
|
|
--enable=deadcode
|
|
].join(" ")
|
|
|
|
ok_test = shell_output("#{bin}/golangci-lint run #{args} #{testpath}/try.go")
|
|
expected_message = "try.go:3:6: `add` is unused (deadcode)"
|
|
assert_match expected_message, ok_test
|
|
end
|
|
end
|