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

Conversation

walldiss
Copy link
Member

@walldiss walldiss commented Jun 7, 2024

Introduce common golangci-lint config that can be reused across celestiaorg repos. The list of suggested linters is based on what is currently used in https://github.com/celestiaorg/celestia-node. Feel free to suggest linters to include / exclude.

@walldiss walldiss added the enhancement New feature or request label Jun 7, 2024
@walldiss walldiss self-assigned this Jun 7, 2024
@walldiss walldiss requested a review from MSevey as a code owner June 7, 2024 17:18
@MSevey
Copy link
Member

MSevey commented Jun 7, 2024

are you thinking this will be a reference file or that you want a common reuseable workflow to call this file?

@walldiss
Copy link
Member Author

I'm thinking it could be a good reference for others to follow the rules we found useful in Node. It can be imported optionally, but I would suggest making a local copy in case the config needs to be modified in accordance with local contextual requirements.

timeout: 5m

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.

source: "https://"
max-same-issues: 50

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

- 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

- 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

@@ -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: ""

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants