-
Notifications
You must be signed in to change notification settings - Fork 0
Project code checks
This guide describes the use of the mgechev/revive project.
When you enable this revive, every build will fail unless it meets the requirements defined by rules in a configuration file. This is a strained way of how to enforce proper code style.
Since revive lints the individual files in separate goroutines, it outperforms golint about 4 times. Also, revive can be extended by custom rules.
To enable checks during a build, two additional lines are required in Dockerfile:
RUN go get -u github.com/mgechev/revive
RUN revive -formatter stylish -config revive-config.toml -exclude ./vendor/... ./...The first command downloads the package via go get.
The second command invokes the check:
-
-formatter stylishformats the output message to the most suitable form for a build log. The list of available formatter can be found here. -
-config revive-config.tomlpasses the configuration file to revive. The content of the configuration file will be described below. -
-exclude ./vendor/...excludes the vendor directory from checks. -
./...will check every file in a project.
This is an example of recommended configuration:
# When set to false, ignores files with "GENERATED" header, similar to golint
ignoreGeneratedHeader = true
# Sets the default severity to "warning"
severity = "warning"
# Sets the default failure confidence. This means that linting errors
# with less than 0.8 confidence will be ignored.
confidence = 0.8
# Sets the error code for failures with severity "error"
errorCode = 10
# Sets the error code for failures with severity "warning"
warningCode = 11
[rule.blank-imports]
[rule.context-as-argument]
[rule.context-keys-type]
[rule.dot-imports]
[rule.error-return]
[rule.error-strings]
[rule.error-naming]
[rule.exported]
[rule.if-return]
[rule.increment-decrement]
[rule.var-naming]
[rule.var-declaration]
[rule.package-comments]
[rule.range]
[rule.receiver-naming]
[rule.time-naming]
[rule.unexported-return]
[rule.indent-error-flow]
[rule.errorf]
[rule.empty-block]
[rule.superfluous-else]
[rule.unused-parameter]
[rule.unreachable-code]Description of used configuration can be found here.
The list of available rules with description can be found here here.
-
FE / Angular
-
Golang
-
DevOps
-
Agile process and SCRUM
-
Internship
-
Bootcamp