diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 9c866cb..1b77b1e 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -10,7 +10,7 @@ jobs: test: strategy: matrix: - go-version: [1.20.x] + go-version: [1.22.x] platform: [ubuntu-latest] runs-on: ${{ matrix.platform }} steps: @@ -32,7 +32,7 @@ jobs: lint: strategy: matrix: - go-version: [1.20.x] + go-version: [1.22.x] platform: [ubuntu-latest] runs-on: ${{ matrix.platform }} steps: @@ -41,12 +41,12 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v3 with: - version: v1.51.1 + version: v1.59.1 args: -v --config config/.golangci-no-plugin.yml lint-plugin: strategy: matrix: - go: [1.20.x] + go: [1.22.x] os: [ubuntu-latest] name: lint-plugin runs-on: ${{ matrix.os }} @@ -58,7 +58,7 @@ jobs: name: Checkout code - name: Install golangci-lint run: | - go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.1 + go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.1 - name: Build plugin run: | go build --buildmode plugin -o cerrl.so plugin/cerrl.go @@ -71,7 +71,7 @@ jobs: # lint-plugin: # strategy: # matrix: -# go: [1.20.x] +# go: [1.22.x] # os: [ubuntu-latest] # name: lint-plugin # runs-on: ${{ matrix.os }} @@ -83,7 +83,7 @@ jobs: # name: Checkout code # - name: Install golangci-lint # run: | -# go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.48.0 +# go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.1 # - name: Build plugin # run: | # curl -L -o go-lint-cerrl.zip https://github.com/edenlabllc/go-lint-cerrl/archive/refs/tags/v0.1.0.zip diff --git a/config/.golangci-no-plugin.yml b/config/.golangci-no-plugin.yml index 7e43c8c..a88b4ec 100644 --- a/config/.golangci-no-plugin.yml +++ b/config/.golangci-no-plugin.yml @@ -118,6 +118,18 @@ linters-settings: # in the sense that it will only allow these assignments to be cuddled with variables being appended. # Default: true strict-append: false + depguard: + rules: + prevent_unmaintained_packages: + list-mode: lax + files: + - $all + - "!$test" + allow: + - $gostd + deny: + - pkg: io/ioutil + desc: "replaced by io and os packages since Go 1.16: https://tip.golang.org/doc/go1.16#ioutil" nestif: # Minimal complexity of if statements to report. @@ -187,4 +199,4 @@ issues: text: "unnecessaryDefer:" run: timeout: 10m - go: '1.20' \ No newline at end of file + go: '1.22' diff --git a/config/.golangci-plugin-only.yml b/config/.golangci-plugin-only.yml index 199d799..15b127b 100644 --- a/config/.golangci-plugin-only.yml +++ b/config/.golangci-plugin-only.yml @@ -20,4 +20,4 @@ issues: run: timeout: 10m - go: '1.20' \ No newline at end of file + go: '1.20' diff --git a/config/.golangci.yml b/config/.golangci.yml index c98c4ea..2bf6229 100644 --- a/config/.golangci.yml +++ b/config/.golangci.yml @@ -122,6 +122,18 @@ linters-settings: # in the sense that it will only allow these assignments to be cuddled with variables being appended. # Default: true strict-append: false + depguard: + rules: + prevent_unmaintained_packages: + list-mode: lax + files: + - $all + - "!$test" + allow: + - $gostd + deny: + - pkg: io/ioutil + desc: "replaced by io and os packages since Go 1.16: https://tip.golang.org/doc/go1.16#ioutil" nestif: # Minimal complexity of if statements to report. @@ -194,4 +206,4 @@ issues: run: timeout: 10m - go: '1.20' \ No newline at end of file + go: '1.22' diff --git a/docker/docker-compose-lint.sh b/docker/docker-compose-lint.sh index 6322331..b70021a 100644 --- a/docker/docker-compose-lint.sh +++ b/docker/docker-compose-lint.sh @@ -2,7 +2,7 @@ cd /app -go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.1 +go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.1 go build --buildmode plugin -o /tmp/cerrl.so plugin/cerrl.go diff --git a/docker/docker-compose-lint.yaml b/docker/docker-compose-lint.yaml index be2159e..7e3f02d 100644 --- a/docker/docker-compose-lint.yaml +++ b/docker/docker-compose-lint.yaml @@ -2,7 +2,7 @@ version: '3.7' services: golangci-lint-docker-compose: - image: golang:1.20 + image: golang:1.22 container_name: golangci-lint-docker-compose volumes: - ..:/app diff --git a/go.mod b/go.mod index 92c40f1..12278a5 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,10 @@ module github.com/edenlabllc/go-lint-cerrl -go 1.20 +go 1.22 -require golang.org/x/tools v0.5.0 +require golang.org/x/tools v0.22.0 require ( - golang.org/x/mod v0.7.0 // indirect - golang.org/x/sys v0.4.0 // indirect + golang.org/x/mod v0.18.0 // indirect + golang.org/x/sync v0.7.0 // indirect ) diff --git a/go.sum b/go.sum index b1157d0..16f2f69 100644 --- a/go.sum +++ b/go.sum @@ -1,12 +1,6 @@ -golang.org/x/mod v0.6.0 h1:b9gGHsz9/HhJ3HF5DHQytPpuwocVTChQJK3AvoLRD5I= -golang.org/x/mod v0.6.0/go.mod h1:4mET923SAdbXp2ki8ey+zGs1SLqsuM2Y0uvdZR/fUNI= -golang.org/x/mod v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA= -golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18= -golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/tools v0.2.0 h1:G6AHpWxTMGY1KyEYoAQ5WTtIekUUvDNjan3ugu60JvE= -golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA= -golang.org/x/tools v0.5.0 h1:+bSpV5HIeWkuvgaMfI3UmKRThoTA5ODJTUd8T17NO+4= -golang.org/x/tools v0.5.0/go.mod h1:N+Kgy78s5I24c24dU8OfWNEotWjutIs8SnJvn5IDq+k= +golang.org/x/mod v0.18.0 h1:5+9lSbEzPSdWkH32vYPBwEpX8KwDbM52Ud9xBUvNlb0= +golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA= +golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c= diff --git a/pkg/cerrl/cerrl.go b/pkg/cerrl/cerrl.go index a3d95e6..8eae627 100644 --- a/pkg/cerrl/cerrl.go +++ b/pkg/cerrl/cerrl.go @@ -50,6 +50,7 @@ func run(pass *analysis.Pass) (interface{}, error) { isImportFinished = false cerrPkgName = "" } + if is.Path != nil && strings.HasSuffix(is.Path.Value, `/pkg/cerror"`) { // is.Name == nil means the import has no alias if is.Name == nil { @@ -58,6 +59,7 @@ func run(pass *analysis.Pass) (interface{}, error) { cerrPkgName = is.Name.Name } } + return }