From 575ecc1aeaa08292061905ee989f4d533b439044 Mon Sep 17 00:00:00 2001 From: Thomas Timmers Date: Wed, 27 Aug 2025 22:08:57 +0200 Subject: [PATCH 1/3] Use correct secrets --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a49bddb..a745caa 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -38,7 +38,7 @@ jobs: uses: sonarsource/sonarqube-scan-action@v4 env: SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }} - SONAR_HOST_URL: https://sonarqube.collibra.dev + SONAR_HOST_URL: ${{ secrets.SONARQUBE_URL }} with: args: > -Dsonar.pullrequest.github.repository=collibra/go-set @@ -49,7 +49,7 @@ jobs: continue-on-error: true env: SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }} - SONAR_HOST_URL: https://sonarqube.collibra.dev + SONAR_HOST_URL: ${{ secrets.SONARQUBE_URL }} - name: FOSSA Scan uses: fossas/fossa-action@v1 From 7c80e77860d9b3dbb5a63e5be8150ffea56da08c Mon Sep 17 00:00:00 2001 From: Thomas Timmers Date: Wed, 27 Aug 2025 22:14:51 +0200 Subject: [PATCH 2/3] Update go lint + config --- .github/workflows/build.yml | 2 +- .golangci.yml | 135 +++++++++++++++++++++++++----------- 2 files changed, 97 insertions(+), 40 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a745caa..e46da73 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,7 +26,7 @@ jobs: - name: Lint uses: golangci/golangci-lint-action@v8 with: - version: v2.1.6 + version: v2.4.0 - name: Build run: go build ./... diff --git a/.golangci.yml b/.golangci.yml index 4d1215f..9f2943a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,35 +1,56 @@ version: "2" run: + modules-download-mode: readonly issues-exit-code: 1 tests: false output: + formats: + text: + path: stdout + print-linter-name: true + print-issued-lines: true + colors: true + checkstyle: + # Output path can be either `stdout`, `stderr` or path to the file to write to. + # Default: stdout + path: .tests/golangci-lint.xml + path-prefix: "" linters: default: none enable: - asasalint + - asciicheck + - bidichk - bodyclose - copyloopvar + - cyclop + #- depguard #We should create a correct config to enabe depguard - dogsled - dupl - - dupword - - durationcheck + - embeddedstructfieldcheck - errcheck - errorlint - exhaustive + - exptostd - forbidigo - goconst - gocritic - gocyclo - gosec - govet + - grouper - ineffassign + - intrange - misspell + # - mnd # Magic numbers should be fixed and enable gomnd, - nakedret - nilerr - nolintlint - prealloc - predeclared + - promlinter + - reassign - revive - staticcheck - thelper @@ -37,33 +58,27 @@ linters: - unconvert - unparam - unused + - usestdlibvars + - wastedassign - whitespace - - wsl + # - wrapcheck # TODO: A separate ticket is created to enable wrapcheck linter as this will require quite some changes (Jira: DEV-141302) + - wsl_v5 + # - wsl # TODO: Collibra: This is disabled temporarily so we can comment out code while doing the lift and shift to CHI (Jira: DEV-135346) settings: cyclop: max-complexity: 20 - package-average: 0 - errorlint: - errorf: true - errorf-multi: true - asserts: true - comparison: true - exhaustive: - default-signifies-exhaustive: true goconst: min-len: 2 min-occurrences: 3 gocritic: disabled-checks: - dupImport - - ifElseChain - octalLiteral - whyNoLint - - wrapperFunc - - importShadow - - unnamedResult - - hugeParam - - commentFormatting + - importShadow # not important for now + - unnamedResult # not important for now + - hugeParam # TODO + # - commentFormatting - paramTypeCombine enabled-tags: - diagnostic @@ -71,13 +86,56 @@ linters: - opinionated - performance - style - gosec: - excludes: - - G404 + settings: + ifElseChain: + minThreshold: 3 govet: enable: + - appends + - asmdecl + - assign + - atomic + - atomicalign + - bools + - buildtag + - cgocall + - composites + - copylocks + - deepequalerrors + - defers + - directive + - errorsas + - findcall + - framepointer + - httpresponse + - ifaceassert + - loopclosure + - lostcancel + - nilfunc + - printf + - reflectvaluecompare - shadow + - shift + - sigchanyzer + - slog + - sortslice + - stdmethods + - stringintconv + - structtag + - testinggoroutine + - tests + - unmarshal + - unreachable + - unsafeptr + - unusedresult + - unusedwrite + exhaustive: + default-signifies-exhaustive: true + mnd: + ignored-functions: + - math.* # Magic number generation, should be fixed and removed? nolintlint: + allow-unused: true require-explanation: false require-specific: false predeclared: @@ -91,20 +149,19 @@ linters: checks: - all - -ST1003 + - -SA4023 # TODO: Collibra: This is added temporarily to allow trailing comments in the code. (Jira: DEV-135346) + wsl_v5: + branch-max-lines: 5 + disable: + - decl + - send + # TODO: Collibra: This is added temporarily to allow trailing comments in the code. (Jira: DEV-135346) + # allow-trailing-comment: true + wrapcheck: - ignore-sigs: - - .Errorf( - - errors.New( - - errors.Unwrap( - - .Wrap( - - .Wrapf( - - .WithMessage( - - .WithMessagef( - - .WithStack( - - go-multierror.Append( - wsl: - allow-assign-and-anything: true - allow-cuddle-declarations: true + ignore-package-globs: + - github.com/collibra/access-governance-backend/internal/shared/gerror + exclusions: generated: lax presets: @@ -113,23 +170,23 @@ linters: - legacy - std-error-handling rules: - - linters: - - cyclop - path: (.+)_test\.go + - path: (.+)\.go$ + text: string `email` has (\d+) occurrences, make it a constant paths: + - (.+)wire_gen\.go + - internal/graphql/generated/generated.go - third_party$ - builtin$ - examples$ issues: uniq-by-line: false - new-from-merge-base: main # ONLY lint new changes that are not in main branch + max-same-issues: 0 formatters: enable: - gofmt - - goimports exclusions: generated: lax paths: - third_party$ - builtin$ - - examples$ + - examples$ \ No newline at end of file From f7ceae39534e3e72c9687abe4f665f74e40b4cf9 Mon Sep 17 00:00:00 2001 From: Thomas Timmers Date: Wed, 27 Aug 2025 22:16:11 +0200 Subject: [PATCH 3/3] Revert golang lint config --- .golangci.yml | 133 +++++++++++++++----------------------------------- 1 file changed, 38 insertions(+), 95 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 9f2943a..ea30d4a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,56 +1,35 @@ version: "2" run: - modules-download-mode: readonly issues-exit-code: 1 tests: false output: - formats: - text: - path: stdout - print-linter-name: true - print-issued-lines: true - colors: true - checkstyle: - # Output path can be either `stdout`, `stderr` or path to the file to write to. - # Default: stdout - path: .tests/golangci-lint.xml - path-prefix: "" linters: default: none enable: - asasalint - - asciicheck - - bidichk - bodyclose - copyloopvar - - cyclop - #- depguard #We should create a correct config to enabe depguard - dogsled - dupl - - embeddedstructfieldcheck + - dupword + - durationcheck - errcheck - errorlint - exhaustive - - exptostd - forbidigo - goconst - gocritic - gocyclo - gosec - govet - - grouper - ineffassign - - intrange - misspell - # - mnd # Magic numbers should be fixed and enable gomnd, - nakedret - nilerr - nolintlint - prealloc - predeclared - - promlinter - - reassign - revive - staticcheck - thelper @@ -58,27 +37,33 @@ linters: - unconvert - unparam - unused - - usestdlibvars - - wastedassign - whitespace - # - wrapcheck # TODO: A separate ticket is created to enable wrapcheck linter as this will require quite some changes (Jira: DEV-141302) - - wsl_v5 - # - wsl # TODO: Collibra: This is disabled temporarily so we can comment out code while doing the lift and shift to CHI (Jira: DEV-135346) + - wsl settings: cyclop: max-complexity: 20 + package-average: 0 + errorlint: + errorf: true + errorf-multi: true + asserts: true + comparison: true + exhaustive: + default-signifies-exhaustive: true goconst: min-len: 2 min-occurrences: 3 gocritic: disabled-checks: - dupImport + - ifElseChain - octalLiteral - whyNoLint - - importShadow # not important for now - - unnamedResult # not important for now - - hugeParam # TODO - # - commentFormatting + - wrapperFunc + - importShadow + - unnamedResult + - hugeParam + - commentFormatting - paramTypeCombine enabled-tags: - diagnostic @@ -86,56 +71,13 @@ linters: - opinionated - performance - style - settings: - ifElseChain: - minThreshold: 3 + gosec: + excludes: + - G404 govet: enable: - - appends - - asmdecl - - assign - - atomic - - atomicalign - - bools - - buildtag - - cgocall - - composites - - copylocks - - deepequalerrors - - defers - - directive - - errorsas - - findcall - - framepointer - - httpresponse - - ifaceassert - - loopclosure - - lostcancel - - nilfunc - - printf - - reflectvaluecompare - shadow - - shift - - sigchanyzer - - slog - - sortslice - - stdmethods - - stringintconv - - structtag - - testinggoroutine - - tests - - unmarshal - - unreachable - - unsafeptr - - unusedresult - - unusedwrite - exhaustive: - default-signifies-exhaustive: true - mnd: - ignored-functions: - - math.* # Magic number generation, should be fixed and removed? nolintlint: - allow-unused: true require-explanation: false require-specific: false predeclared: @@ -149,19 +91,20 @@ linters: checks: - all - -ST1003 - - -SA4023 # TODO: Collibra: This is added temporarily to allow trailing comments in the code. (Jira: DEV-135346) - wsl_v5: - branch-max-lines: 5 - disable: - - decl - - send - # TODO: Collibra: This is added temporarily to allow trailing comments in the code. (Jira: DEV-135346) - # allow-trailing-comment: true - wrapcheck: - ignore-package-globs: - - github.com/collibra/access-governance-backend/internal/shared/gerror - + ignore-sigs: + - .Errorf( + - errors.New( + - errors.Unwrap( + - .Wrap( + - .Wrapf( + - .WithMessage( + - .WithMessagef( + - .WithStack( + - go-multierror.Append( + wsl: + allow-assign-and-anything: true + allow-cuddle-declarations: true exclusions: generated: lax presets: @@ -170,20 +113,20 @@ linters: - legacy - std-error-handling rules: - - path: (.+)\.go$ - text: string `email` has (\d+) occurrences, make it a constant + - linters: + - cyclop + path: (.+)_test\.go paths: - - (.+)wire_gen\.go - - internal/graphql/generated/generated.go - third_party$ - builtin$ - examples$ issues: uniq-by-line: false - max-same-issues: 0 + new-from-merge-base: main # ONLY lint new changes that are not in main branch formatters: enable: - gofmt + - goimports exclusions: generated: lax paths: