From 75cd582021a4c0130f888f58fc7f33687d44a642 Mon Sep 17 00:00:00 2001 From: Denis Bilenko Date: Fri, 10 Jan 2025 10:49:33 +0100 Subject: [PATCH] Remove lint.sh; re-add 'make fmt' (#2113) See Makefile for explanation on difference between 'make fmt' and 'make lint'. I also removed lint.sh. Original motivation was to use it in aider, but it's not a good fit there, because aider passes filenames and it does not work well with most golang linters which requires whole packages to work. Follow up to #2062, #2056, #2051. --- Makefile | 10 ++++++++-- lint.sh | 14 -------------- 2 files changed, 8 insertions(+), 16 deletions(-) delete mode 100755 lint.sh diff --git a/Makefile b/Makefile index 40eef9f31..2c84d88ba 100644 --- a/Makefile +++ b/Makefile @@ -5,11 +5,17 @@ PACKAGES=./acceptance/... ./libs/... ./internal/... ./cmd/... ./bundle/... . GOTESTSUM_FORMAT ?= pkgname-and-test-fails lint: - ./lint.sh ./... + golangci-lint run --fix lintcheck: golangci-lint run ./... +# Note 'make lint' will do formatting as well. However, if there are compilation errors, +# formatting/goimports will not be applied by 'make lint'. However, it will be applied by 'make fmt'. +# If you need to ensure that formatting & imports are always fixed, do "make fmt lint" +fmt: + golangci-lint run --enable-only="gofmt,gofumpt,goimports" --fix ./... + test: gotestsum --format ${GOTESTSUM_FORMAT} --no-summary=skipped -- ${PACKAGES} @@ -39,4 +45,4 @@ integration: integration-short: $(INTEGRATION) -short -.PHONY: lint lintcheck test cover showcover build snapshot vendor schema integration integration-short +.PHONY: lint lintcheck fmt test cover showcover build snapshot vendor schema integration integration-short diff --git a/lint.sh b/lint.sh deleted file mode 100755 index 1f881eaf7..000000000 --- a/lint.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -set -uo pipefail -# With golangci-lint, if there are any compliation issues, then formatters' autofix won't be applied. -# https://github.com/golangci/golangci-lint/issues/5257 - -golangci-lint run --fix "$@" -lint_exit_code=$? - -if [ $lint_exit_code -ne 0 ]; then - # These linters work in presence of compilation issues when run alone, so let's get these fixes at least. - golangci-lint run --enable-only="gofmt,gofumpt,goimports" --fix "$@" -fi - -exit $lint_exit_code