diff --git a/.github/linters/.golangci.yml b/.github/linters/.golangci.yml new file mode 100644 index 00000000..a20bc769 --- /dev/null +++ b/.github/linters/.golangci.yml @@ -0,0 +1,38 @@ +run: + timeout: 5m + skip-files: + - generated.* + +issues: + new: true + +linters: + enable: + - asciicheck + - bodyclose + - deadcode + - depguard + - gci + - gocritic + - gofmt + - gofumpt + - goimports + - goprintffuncname + - gosimple + - govet + - ineffassign + - misspell + - nilerr + - nlreturn + - rowserrcheck + - staticcheck + - structcheck + - stylecheck + - typecheck + - unconvert + - unused + - unparam + - varcheck + - whitespace + disable: + - errcheck diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 85b159db..39901ce8 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -1,32 +1,26 @@ name: golangci-lint on: push: - tags: - - v* branches: - master - - main + paths: + - "**/*.go" + - ".github/workflows/golangci-lint.yml" pull_request: + types: [opened, synchronize, reopened] + paths: + - "**/*.go" + - ".github/workflows/golangci-lint.yml" jobs: - golangci: - name: lint + lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - name: Checkout codebase + uses: actions/checkout@v2 + - name: golangci-lint uses: golangci/golangci-lint-action@v2 with: - # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. - version: v1.29 - - # Optional: working directory, useful for monorepos -# working-directory: ./ - - # Optional: golangci-lint command line arguments. - args: --timeout=5m --print-issued-lines=true --print-linter-name=true --uniq-by-line=true - - # Optional: show only new issues if it's a pull request. The default value is `false`. + version: latest + args: --config=.github/linters/.golangci.yml only-new-issues: true - - # Optional: if set to true then the action will use pre-installed Go - # skip-go-installation: true \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index f625016e..5ccd3645 100644 --- a/.travis.yml +++ b/.travis.yml @@ -55,13 +55,7 @@ before_install: - docker exec etcd-gcr-v3.3.25 /bin/sh -c "ETCDCTL_API=3 /usr/local/bin/etcdctl put current.string hello" - docker exec etcd-gcr-v3.3.25 /bin/sh -c "ETCDCTL_API=3 /usr/local/bin/etcdctl put current.serialize.name test" - docker exec etcd-gcr-v3.3.25 /bin/sh -c "ETCDCTL_API=3 /usr/local/bin/etcdctl put sub.sub.key1 sub.sub.key" -install: - - go get -u honnef.co/go/tools/cmd/staticcheck - - go get -u github.com/mdempsky/unconvert - - go get -u github.com/gordonklaus/ineffassign before_script: - - # - - psql --version # - prepare for orm unit tests - sh -c "if [ '$ORM_DRIVER' = 'postgres' ]; then psql -c 'create database orm_test;' -U postgres; fi" @@ -77,9 +71,5 @@ after_success: - bash <(curl -s https://codecov.io/bash) script: - GO111MODULE=on go test -coverprofile=coverage.txt -covermode=atomic ./... - - staticcheck -show-ignored -checks "-ST1017,-U1000,-ST1005,-S1034,-S1012,-SA4006,-SA6005,-SA1019,-SA1024" ./ - - unconvert $(go list ./... | grep -v /vendor/) - - ineffassign . - - find . ! \( -path './vendor' -prune \) -type f -name '*.go' -print0 | xargs -0 gofmt -l -s addons: postgresql: "9.6" diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a8bb518..988f4a84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,6 @@ # developing + +- Lint: use golangci-lint. [4619](https://github.com/beego/beego/pull/4619) - Chore: update dependencies. [4611](https://github.com/beego/beego/pull/4611) - Update orm_test.go/TestInsertOrUpdate with table-driven. [4609](https://github.com/beego/beego/pull/4609) - Add: Resp() method for web.Controller. [4588](https://github.com/beego/beego/pull/4588) @@ -41,7 +43,9 @@ - Optimize AddAutoPrefix: only register one router in case-insensitive mode. [4582](https://github.com/beego/beego/pull/4582) - Init exceptMethod by using reflection. [4583](https://github.com/beego/beego/pull/4583) - Deprecated BeeMap and replace all usage with `sync.map` [4616](https://github.com/beego/beego/pull/4616) + ## Fix Sonar + - [4608](https://github.com/beego/beego/pull/4608) - [4473](https://github.com/beego/beego/pull/4473) - [4474](https://github.com/beego/beego/pull/4474)