Linters
#246
Replies: 1 comment 1 reply
-
+1 from me! |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Linters
Status: accepted
Date: 2021-11-10
Authors: @yitsushi
Deciders: @Callisto13 @jmickey @richardcase @yitsushi
Context
A few linters are disabled and they can improve the code, and the linter tool
(golangci-lint) was misconfigured and a lot of
linters-settings
options weresimply ignored.
Scope
Enable all linters and set reasonable exception list and linter settings.
Decision
gci
This makes the import list easier to read and see what imports are from external,
built-in, or internal packages.
Example
godox
No
TODO
,FIXME
, orBUG
comments should live in the code without filedissues to track them. The reason is simple: if we have a comment with "todo",
it has the same value as not having that comment at all, because no one will
care about it.
We can mark block with
TODO
,FIXME
, orBUG
if we have a GitHub issues tofix it. We can annotate these comments with an GitHub reference at the end of
the line.
Example
// TODO: we may hide this within the firecracker plugin. #179
gochecknoglobals
The official description has all the information.
lll
Long lines are hard to read and hard to edit. Most of the time if a line is too
long, it can be reduced with a different pattern (for example Options pattern
for functions), or can be re-formatted into multiple lines.
Exception:
If a line contains the
https://
substring, it will be ignored automatically.wsl
This linter has a lot of rules and they make the code easier to read.
Example
One big block of code
Without empty lines
With empty lines
Error check
With empty lines
With empty lines
Description on ignored linters
It is possible to add a
//nolint
command for a specific file, block, or line,but it's not recommended. If it has a reason why we need that
//nolint
, tellus a why.
Example
Consequences
todo
comments have a GitHub reference.maintanence
orcolor
.Beta Was this translation helpful? Give feedback.
All reactions