From 390c5b3e8b1cef66c0d878d4af6c3e5537fc1f6f Mon Sep 17 00:00:00 2001 From: "Xinwei Xiong (cubxxw)" <3293172751nss@gmail.com> Date: Tue, 2 Apr 2024 17:27:24 +0800 Subject: [PATCH] feat: add code lint --- .gitignore | 1 - .golangci.yml | 46 ++++++++++++++++++++++++++-------------------- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/.gitignore b/.gitignore index 5142fe551..fb8d428d2 100644 --- a/.gitignore +++ b/.gitignore @@ -34,7 +34,6 @@ deployments/charts/generated-configs/ ### OpenIM Config ### .env config/config.yaml -config/openim.yaml config/alertmanager.yml config/prometheus.yml config/email.tmpl diff --git a/.golangci.yml b/.golangci.yml index 6b8469b62..f0ca3a010 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -39,19 +39,19 @@ run: # from this option's value (see skip-dirs-use-default). # "/" will be replaced by current OS file path separator to properly work # on Windows. - skip-dirs: - - components - - docs - - util - - .*~ - - api/swagger/docs - - server/docs - - components/mnt/config/certs - - logs + # skip-dirs: + # - components + # - docs + # - util + # - .*~ + # - api/swagger/docs + # - server/docs + # - components/mnt/config/certs + # - logs # default is true. Enables skipping of directories: # vendor$, third_party$, testdata$, examples$, Godeps$, builtin$ - skip-dirs-use-default: true + # skip-dirs-use-default: true # which files to skip: they will be analyzed, but issues from them # won't be reported. Default value is empty list, but there is @@ -59,15 +59,15 @@ run: # autogenerated files. If it's not please let us know. # "/" will be replaced by current OS file path separator to properly work # on Windows. - skip-files: - - ".*\\.my\\.go$" - - _test.go - - ".*_test.go" - - "mocks/" - - ".github/" - - "logs/" - - "_output/" - - "components/" + # skip-files: + # - ".*\\.my\\.go$" + # - _test.go + # - ".*_test.go" + # - "mocks/" + # - ".github/" + # - "logs/" + # - "_output/" + # - "components/" # by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules": # If invoked with -mod=readonly, the go command is disallowed from the implicit @@ -87,7 +87,7 @@ run: # output configuration options output: # colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number" - format: colored-line-number + # format: colored-line-number # print lines of code with issue, default is true print-issued-lines: true @@ -150,6 +150,11 @@ linters-settings: comparison: true exhaustive: + # Program elements to check for exhaustiveness. + # Default: [ switch ] + check: + - switch + - map # check switch statements in generated files also check-generated: false # indicates that switch statements are to be considered exhaustive if a @@ -772,6 +777,7 @@ linters: - dupword - errname - gci + - exhaustive - gocritic - goprintffuncname - gomnd