-
-
Notifications
You must be signed in to change notification settings - Fork 51
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
golangci lint #76
Merged
jorgerojas26
merged 15 commits into
jorgerojas26:main
from
ccoveille-forks:golangci-lint
Jul 17, 2024
Merged
golangci lint #76
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
ff0a6f5
chore: use Go canonical way to return errors
ccoVeille 9fa9e27
chore: use the canonical name for error variable
ccoVeille 32801a9
ci: add golangci-lint configuration file
ccoVeille 5a45711
fix: catch errors reported by errcheck linter
ccoVeille b5c64eb
fix: make sure to catch all errors in drivers
ccoVeille eb50649
ci: enable more linters
ccoVeille 280d93e
chore: fix import orders
ccoVeille f0e8b75
chore: remove dot import and use type alias
ccoVeille 2fb9a4f
chore: remove else when previous if ends with a return
ccoVeille 76f23b2
chore: remove type or default value when obvious
ccoVeille 0110f98
chore: use go initialism for variable name
ccoVeille 6f22fa1
chore: no uppercase constant in Go
ccoVeille e6ff2b3
chore: remove suspicious blank imports
ccoVeille 2b0ffc4
fix: make sure to use the database name when getting table columns
ccoVeille 451cce7
ci: enable golang-lint in GitHub actions
ccoVeille File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,11 @@ jobs: | |
- | ||
name: Set up Go | ||
uses: actions/setup-go@v5 | ||
|
||
- | ||
name: Golangci-lint | ||
uses: golangci/[email protected] | ||
|
||
- | ||
name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v6 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
--- | ||
# golangci-lint configuration file made by @ccoVeille | ||
# Source: https://github.com/ccoVeille/golangci-lint-config-examples/ | ||
# Author: @ccoVeille | ||
# License: MIT | ||
# Variant: 03-safe | ||
# Version: v1.0.0 | ||
# | ||
linters: | ||
# some linters are enabled by default | ||
# https://golangci-lint.run/usage/linters/ | ||
# | ||
# enable some extra linters | ||
enable: | ||
# Errcheck is a program for checking for unchecked errors in Go code. | ||
- errcheck | ||
|
||
# Linter for Go source code that specializes in simplifying code. | ||
- gosimple | ||
|
||
# Vet examines Go source code and reports suspicious constructs. | ||
- govet | ||
|
||
# Detects when assignments to existing variables are not used. | ||
- ineffassign | ||
|
||
# It's a set of rules from staticcheck. See https://staticcheck.io/ | ||
- staticcheck | ||
|
||
# Fast, configurable, extensible, flexible, and beautiful linter for Go. | ||
# Drop-in replacement of golint. | ||
- revive | ||
|
||
# check imports order and makes it always deterministic. | ||
- gci | ||
|
||
# make sure to use t.Helper() when needed | ||
- thelper | ||
|
||
# mirror suggests rewrites to avoid unnecessary []byte/string conversion | ||
- mirror | ||
|
||
# detect the possibility to use variables/constants from the Go standard library. | ||
- usestdlibvars | ||
|
||
# Finds commonly misspelled English words. | ||
- misspell | ||
|
||
# Checks for duplicate words in the source code. | ||
- dupword | ||
|
||
linters-settings: | ||
gci: # define the section orders for imports | ||
sections: | ||
# Standard section: captures all standard packages. | ||
- standard | ||
# Default section: catchall that is not standard or custom | ||
- default | ||
# linters that related to local tool, so they should be separated | ||
- localmodule | ||
|
||
revive: | ||
rules: | ||
# these are the default revive rules | ||
# you can remove the whole "rules" node if you want | ||
# BUT | ||
# ! /!\ they all need to be present when you want to add more rules than the default ones | ||
# otherwise, you won't have the default rules, but only the ones you define in the "rules" node | ||
|
||
# Blank import should be only in a main or test package, or have a comment justifying it. | ||
- name: blank-imports | ||
|
||
# context.Context() should be the first parameter of a function when provided as argument. | ||
- name: context-as-argument | ||
arguments: | ||
- allowTypesBefore: "*testing.T" | ||
|
||
# Basic types should not be used as a key in `context.WithValue` | ||
- name: context-keys-type | ||
|
||
# Importing with `.` makes the programs much harder to understand | ||
- name: dot-imports | ||
|
||
# Empty blocks make code less readable and could be a symptom of a bug or unfinished refactoring. | ||
- name: empty-block | ||
|
||
# for better readability, variables of type `error` must be named with the prefix `err`. | ||
- name: error-naming | ||
|
||
# for better readability, the errors should be last in the list of returned values by a function. | ||
- name: error-return | ||
|
||
# for better readability, error messages should not be capitalized or end with punctuation or a newline. | ||
- name: error-strings | ||
|
||
# report when replacing `errors.New(fmt.Sprintf())` with `fmt.Errorf()` is possible | ||
- name: errorf | ||
|
||
# incrementing an integer variable by 1 is recommended to be done using the `++` operator | ||
- name: increment-decrement | ||
|
||
# highlights redundant else-blocks that can be eliminated from the code | ||
- name: indent-error-flow | ||
|
||
# This rule suggests a shorter way of writing ranges that do not use the second value. | ||
- name: range | ||
|
||
# receiver names in a method should reflect the struct name (p for Person, for example) | ||
- name: receiver-naming | ||
|
||
# redefining built in names (true, false, append, make) can lead to bugs very difficult to detect. | ||
- name: redefines-builtin-id | ||
|
||
# redundant else-blocks that can be eliminated from the code. | ||
- name: superfluous-else | ||
|
||
# prevent confusing name for variables when using `time` package | ||
- name: time-naming | ||
|
||
# warns when an exported function or method returns a value of an un-exported type. | ||
- name: unexported-return | ||
|
||
# spots and proposes to remove unreachable code. also helps to spot errors | ||
- name: unreachable-code | ||
|
||
# Functions or methods with unused parameters can be a symptom of an unfinished refactoring or a bug. | ||
- name: unused-parameter | ||
|
||
# report when a variable declaration can be simplified | ||
- name: var-declaration | ||
|
||
# warns when initialism, variable or package naming conventions are not followed. | ||
- name: var-naming | ||
|
||
dupword: | ||
# Keywords used to ignore detection. | ||
# Default: [] | ||
ignore: | ||
# - "blah" # this will accept "blah blah …" as a valid duplicate word | ||
|
||
misspell: | ||
# Correct spellings using locale preferences for US or UK. | ||
# Setting locale to US will correct the British spelling of 'colour' to 'color'. | ||
# Default ("") is to use a neutral variety of English. | ||
locale: US | ||
|
||
# List of words to ignore | ||
# among the one defined in https://github.com/golangci/misspell/blob/master/words.go | ||
ignore-words: | ||
# - valor | ||
# - and | ||
|
||
# Extra word corrections. | ||
extra-words: | ||
# - typo: "whattever" | ||
# correction: "whatever" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm noticing I added this one on the release process, so only when something is tagged
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed by #80 80