Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Create common golangci-lint config #108

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
66 changes: 66 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
run:
timeout: 5m

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plus:

  # This is very important, bugs in tests are not acceptable either.
  tests: true

  # With the read-only mode linter will fail if go.mod file is outdated.
  modules-download-mode: readonly

  # Keep this empty to use the Go version from the go.mod file.
  go: ""


linters:
enable:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's sort enabled checks please.

- bidichk
- bodyclose
- dogsled
- dupl
- errcheck
- errorlint
- exportloopref
- gocheckcompilerdirectives
- goconst
- gocritic
- gofmt
- gofumpt
- goimports
- revive
- gosec
- gosimple
- govet
- ineffassign
- lll
- loggercheck
- misspell
- nakedret
- nilerr
- nilnil
- nolintlint
- prealloc
- protogetter
- exportloopref
- staticcheck
- stylecheck
- typecheck
- unconvert
- unused
- wastedassign
- whitespace
- nolintlint
- asciicheck
- dupword

issues:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on https://olegk.dev/go-linters-configuration-the-right-version (shameless plug):

issues:
  # I found it strange to skip the errors, setting 0 to have all the results.
  max-issues-per-linter: 0

  # Same here, nothing should be skipped to not miss errors.
  max-same-issues: 0

exclude-rules:
- path: _test\.go
linters:
- gosec
- revive
- linters:
- lll
source: "https://"
max-same-issues: 50

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on https://olegk.dev/go-linters-configuration-the-right-version (shameless plug):

output:
  # Must have. Easier to understand the output.
  print-linter-name: true

  # No, no skips, everything should be reported.
  uniq-by-line: false

  # To be honest no idea when this can be needed, maybe a multi-module setup?
  path-prefix: ""

  # Slightly easier to follow the results + getting deterministic output.
  sort-results: true

linters-settings:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plus

  nakedret:
    # No naked returns, ever.
    max-func-lines: 1

dogsled:
max-blank-identifiers: 3
misspell:
locale: US
goimports:
local-prefixes: github.com/celestiaorg/<past_repo_name_here>
dupl:
threshold: 200
gofumpt:
extra-rules: true
Loading