diff --git a/.github/.golangci.yml b/.github/.golangci.yml new file mode 100644 index 00000000..429e23ab --- /dev/null +++ b/.github/.golangci.yml @@ -0,0 +1,57 @@ +# This is the configuration for golangci-lint for the restic project. +# +# A sample config with all settings is here: +# https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml + +linters: + # only enable the linters listed below + disable-all: true + enable: + # make sure all errors returned by functions are handled + - errcheck + + # find unused code + - deadcode + + # show how code can be simplified + - gosimple + + # # make sure code is formatted + - gofmt + + # examine code and report suspicious constructs, such as Printf calls whose + # arguments do not align with the format string + - govet + + # make sure names and comments are used according to the conventions + - revive + + # detect when assignments to existing variables are not used + - ineffassign + + # run static analysis and find errors + - staticcheck + + # find unused variables, functions, structs, types, etc. + - unused + + # find unused struct fields + - structcheck + + # find unused global variables + - varcheck + + # parse and typecheck code + - typecheck + +issues: + # don't use the default exclude rules, this hides (among others) ignored + # errors from Close() calls + exclude-use-default: false + + # list of things to not warn about + exclude: + # revive: do not warn about missing comments for exported stuff + - exported (function|method|var|type|const) .* should have comment or be unexported + # revive: ignore constants in all caps + - don't use ALL_CAPS in Go names; use CamelCase \ No newline at end of file diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml new file mode 100644 index 00000000..5df05a68 --- /dev/null +++ b/.github/workflows/golangci-lint.yml @@ -0,0 +1,42 @@ +name: golangci-lint +on: + push: + branches: + - master + - main + pull_request: + +permissions: + contents: read + # Optional: allow read access to pull request. Use with `only-new-issues` option. + pull-requests: read + +# cancel the in-progress workflow when PR is refreshed. +concurrency: + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} + cancel-in-progress: true + + +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v4 + with: + go-version: '1.21' + cache: false + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + # Require: The version of golangci-lint to use. + # When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version. + # When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit. + version: v1.54 + + # Optional: show only new issues if it's a pull request. The default value is `false`. + only-new-issues: true + + # Optional: The mode to install golangci-lint. It can be 'binary' or 'goinstall'. + install-mode: "goinstall" \ No newline at end of file