From 04c091c0b7a5ffa2684c251463fba03345a2df12 Mon Sep 17 00:00:00 2001 From: ifooth Date: Mon, 18 Sep 2023 10:34:20 +0800 Subject: [PATCH] Update: add bcs-webconsole-lint.yml --- .github/workflows/bcs-webconsole-lint.yml | 21 ++++++ .golangci.yaml | 35 --------- .golangci.yml | 79 ++++++++++++++++++++ bcs-services/bcs-webconsole/.golangci.yml | 89 +++++++++++++++++++++++ 4 files changed, 189 insertions(+), 35 deletions(-) create mode 100644 .github/workflows/bcs-webconsole-lint.yml delete mode 100644 .golangci.yaml create mode 100644 .golangci.yml create mode 100644 bcs-services/bcs-webconsole/.golangci.yml diff --git a/.github/workflows/bcs-webconsole-lint.yml b/.github/workflows/bcs-webconsole-lint.yml new file mode 100644 index 0000000000..b4ae12825a --- /dev/null +++ b/.github/workflows/bcs-webconsole-lint.yml @@ -0,0 +1,21 @@ +name: lint +on: [push, pull_request] +jobs: + lint: + name: lint + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v3 + - name: setup go + uses: actions/setup-go@v3 + with: + go-version-file: go.mod + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + version: v1.54.2 + args: --timeout=30m --issues-exit-code=0 + working-directory: ./bcs-services/bcs-webconsole + - name: go mod tidy check + uses: katexochen/go-tidy-check@v2 diff --git a/.golangci.yaml b/.golangci.yaml deleted file mode 100644 index 30b5344091..0000000000 --- a/.golangci.yaml +++ /dev/null @@ -1,35 +0,0 @@ -run: - timeout: 1m - -issues: - exclude-use-default: false - # Excluding configuration per-path, per-linter, per-text and per-source - exclude-rules: - # 仅保留 should have comment or be unexported - - linters: - - revive - text: "should be of the form|consider calling this" - -linters: - disable-all: true - enable: - # enable by default - - errcheck - - gosimple - - govet - - ineffassign - - staticcheck - - typecheck - - unused - # custom - - revive - -linters-settings: - revive: - rules: - - name: exported - severity: warning - disabled: false - arguments: - - checkPrivateReceivers - - sayRepetitiveInsteadOfStutters diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000000..cc7c19caea --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,79 @@ +run: + timeout: 5m + +issues: + # 显示所有 issue + max-issues-per-linter: 0 + max-same-issues: 0 + exclude-use-default: false + +linters: + disable-all: true + enable: + # enable by default + - errcheck + - gosimple + - govet + - ineffassign + - staticcheck + - unused + + # custom + - goconst + - gocyclo + - gofmt + - goheader + - goimports + - gosec + - misspell + - nakedret + - revive + - unconvert + - unparam + +linters-settings: + # 只开启特定的规则 + errcheck: + exclude-functions: + - (*os.File).Close + - (io.Closer).Close + - os.RemoveAll + govet: + check-shadowing: true + gocyclo: + min-complexity: 30 + gosec: + includes: + - G201 # SQL query construction using format string + - G202 # SQL query construction using string concatenation + - G101 # Look for hard coded credentials + - G401 # Detect the usage of DES, RC4, MD5 or SHA1 + - G402 # Look for bad TLS connection settings + - G403 # Ensure minimum RSA key length of 2048 bits + - G404 # Insecure random number source (rand) + - G504 # Import blocklist: net/http/cgi + goheader: + template: |- + * Tencent is pleased to support the open source community by making Blueking Container Service available. + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + misspell: + locale: US + revive: + rules: + - name: exported + severity: warning + disabled: false + arguments: + - checkPrivateReceivers + - sayRepetitiveInsteadOfStutters + - name: package-comments + severity: warning + disabled: false diff --git a/bcs-services/bcs-webconsole/.golangci.yml b/bcs-services/bcs-webconsole/.golangci.yml new file mode 100644 index 0000000000..fb35b121ea --- /dev/null +++ b/bcs-services/bcs-webconsole/.golangci.yml @@ -0,0 +1,89 @@ +run: + timeout: 5m + +issues: + # 显示所有 issue + max-issues-per-linter: 0 + max-same-issues: 0 + exclude-use-default: false + +linters: + disable-all: true + enable: + # enable by default + - errcheck + - gosimple + - govet + - ineffassign + - staticcheck + - unused + + # custom + - gci + - goconst + - gocyclo + - gofmt + - goheader + - goimports + - gosec + - misspell + - nakedret + - revive + - unconvert + - unparam + +linters-settings: + # 只开启特定的规则 + errcheck: + exclude-functions: + - (*os.File).Close + - (io.Closer).Close + - (net/http.ResponseWriter).Write + - io.Copy + - os.RemoveAll + govet: + check-shadowing: true + gocyclo: + min-complexity: 30 + goimports: + local-prefixes: github.com/Tencent/bk-bcs/bcs-services/bcs-webconsole + gci: + sections: + - standard + - default + - prefix(github.com/Tencent/bk-bcs/bcs-services/bcs-webconsole) + gosec: + includes: + - G201 # SQL query construction using format string + - G202 # SQL query construction using string concatenation + - G101 # Look for hard coded credentials + - G401 # Detect the usage of DES, RC4, MD5 or SHA1 + - G402 # Look for bad TLS connection settings + - G403 # Ensure minimum RSA key length of 2048 bits + - G404 # Insecure random number source (rand) + - G504 # Import blocklist: net/http/cgi + goheader: + template: |- + * Tencent is pleased to support the open source community by making Blueking Container Service available. + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + misspell: + locale: US + revive: + rules: + - name: exported + severity: warning + disabled: false + arguments: + - checkPrivateReceivers + - sayRepetitiveInsteadOfStutters + - name: package-comments + severity: warning + disabled: false