Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/code-health-foascli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ jobs:
go-version-file: 'tools/cli/go.mod'
cache: false # see https://github.com/golangci/golangci-lint-action/issues/807
- name: golangci-lint
uses: golangci/golangci-lint-action@55c2c1448f86e01eaae002a5a3a9624417608d84
uses: golangci/golangci-lint-action@1481404843c368bc19ca9406f87d6e0fc97bdcfd
with:
version: v1.64.5
version: v2.0.1
working-directory: tools/cli
- name: Checkout GitHub actions
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
Expand Down
129 changes: 129 additions & 0 deletions tools/cli/.golangci.bck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# TO BE REMOVED IN https://jira.mongodb.org/browse/CLOUDP-308470

linters-settings:
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
govet:
enable:
- shadow

revive:
# see https://github.com/mgechev/revive#available-rules for details.
ignore-generated-header: true
severity: warning
rules:
- name: blank-imports
- name: context-as-argument
- name: context-keys-type
- name: defer
- name: dot-imports
- name: error-return
- name: error-strings
- name: error-naming
- name: early-return
- name: errorf
- name: exported
- name: import-shadowing
- name: indent-error-flow
- name: if-return
- name: increment-decrement
- name: var-naming
- name: var-declaration
- name: package-comments
- name: range
- name: receiver-naming
- name: time-naming
- name: unexported-return
- name: indent-error-flow
- name: errorf
- name: empty-block
- name: superfluous-else
- name: struct-tag
- name: unused-parameter
- name: unreachable-code
- name: redefines-builtin-id
- name: unused-receiver
- name: constant-logical-expr
- name: confusing-naming
- name: unnecessary-stmt
- name: use-any
- name: imports-blocklist
arguments:
- "github.com/pkg/errors"
misspell:
locale: US
lll:
line-length: 150
nestif:
# minimal complexity of if statements to report, 5 by default
min-complexity: 7
funlen:
lines: 360
statements: 120
gci:
sections:
- standard
- default
linters:
disable-all: true
enable:
- copyloopvar # copyloopvar is a linter detects places where loop variables are copied
- dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f())
- errcheck # errcheck is a program for checking for unchecked errors in Go code. These unchecked errors can be critical bugs in some cases
- errorlint # Errorlint is a linter that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13.
- exhaustive # check exhaustiveness of enum switch statements
- copyloopvar # copyloopvar is a linter detects places where loop variables are copied. Replaces exportloopref since Go1.22
- funlen # Tool for detection of long functions
- gci # Gci controls golang package import order and makes it always deterministic. [fast: true, auto-fix: false]
- gocritic # Provides diagnostics that check for bugs, performance and style issues.
- godot # Check if comments end in a period [fast: true, auto-fix: true]
- gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification
- goimports # Check import statements are formatted according to the 'goimport' command. Reformat imports in autofix mode.
- goprintffuncname # Checks that printf-like functions are named with `f` at the end.
- gosec # Inspects source code for security problems
- gosimple # Linter for Go source code that specializes in simplifying code
- govet # Vet examines Go source code and reports suspicious constructs. It is roughly the same as 'go vet' and uses its passes.
- ineffassign # Detects when assignments to existing variables are not used
- lll # Reports long lines
- makezero # Finds slice declarations with non-zero initial length
- misspell # Finds commonly misspelled English words
- nakedret # Checks that functions with naked returns are not longer than a maximum size (can be zero).
- noctx # Finds sending http request without context.Context
- nolintlint # Reports ill-formed or insufficient nolint directives
- perfsprint # Checks that fmt.Sprintf can be replaced with a faster alternative.
- prealloc # Finds slice declarations that could potentially be pre-allocated
- predeclared # find code that shadows one of Go's predeclared identifiers
- revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint.
- rowserrcheck # checks whether Rows.Err of rows is checked successfully
- staticcheck # It's a set of rules from staticcheck. It's not the same thing as the staticcheck binary. The author of staticcheck doesn't support or approve the use of staticcheck as a library inside golangci-lint.
- stylecheck # Stylecheck is a replacement for golint
- tenv # tenv is analyzer that detects using os.Setenv instead of t.Setenv since Go1.17
- testifylint # Checks usage of github.com/stretchr/testify.
- thelper # thelper detects tests helpers which is not start with t.Helper() method.
- unconvert # Remove unnecessary type conversions
- unused # Checks Go code for unused constants, variables, functions and types
- whitespace # Whitespace is a linter that checks for unnecessary newlines at the start and end of functions, if, for, etc.

# don't enable:
# - deadcode
# - varcheck
# - structcheck
# - depguard # Go linter that checks if package imports are in a list of acceptable packages [fast: true, auto-fix: false]
# - gocyclo # we already have funlen lint
# - dupl # we have a lot of duplicate test cases
# - gochecknoinits # we need the init function for the provider
# - gochecknoglobals # we need some global variables
# - unparam # Forces to create global variables when one variable is repeated in different functions
# - goerr113 # It does not allow you to return an error, you need to save the error in a variable to do it
# - goconst
# - gocognit

run:
timeout: 10m
tests: true
modules-download-mode: readonly
Loading
Loading