-
Notifications
You must be signed in to change notification settings - Fork 7
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
Handle problems detected by used linters #80
Milestone
Comments
arcticicestudio
added a commit
that referenced
this issue
Jul 20, 2019
The problems in the code base detected by the linters that have been integrated in GH-62 through GolangCI have been handled by refactoring the affected implementations. This helps to improve the overall code quality and prevents possible errors. 1. Removed unused function parameters detected by unparam (1). 1. `(*cmdOptions).prepare` - `cmd` is unused: cmd/snowsaw/bootstrap/bootstrap.go:51:30 (2) ```go func (o *cmdOptions) prepare(cmd *cobra.Command, args []string) { ^ ``` 2. `(*cmdOptions).run` - `cmd` is unused: cmd/snowsaw/bootstrap/bootstrap.go:100:26 (2) ```go func (o *cmdOptions) run(cmd *cobra.Command, args []string) { ^ ``` 3. `(*cmdOptions).run` - `args` is unused: cmd/snowsaw/bootstrap/bootstrap.go:100:46 (2) ```go func (o *cmdOptions) run(cmd *cobra.Command, args []string) { ^ ``` 2. Improved function names and code flows detected by golint (3). 1. func `NewJsonEncoder` should be `NewJSONEncoder`: pkg/config/encoder/json/json.go:34:6 (4) ```go func NewJsonEncoder() Encoder { ^ ``` 2. var `ExtensionsJson` should be `ExtensionsJSON`: pkg/config/encoder/constants.go:26:2 (5) ```go ExtensionsJson = "json" ^ ``` 3. if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary): pkg/prt/printer.go:121:9 (6) ```go } else { ^ ``` 4. exported func Load returns unexported type *builder.builder, which can be annoying to use: pkg/config/builder/builder.go:39:32 (7) ```go func Load(files ...*file.File) *builder { ^ ``` 3. Improved code style smells detected by gocritic (8). 1. assignOp: replace `format = format + "\n"` with `format += "\n"`: pkg/prt/printer.go:179:4 (9) ```go format = format + "\n" ^ ``` 2. paramTypeCombine: `func(v Verbosity, w io.Writer, prefix string, format string, args ...interface{})` could be replaced with `func(v Verbosity, w io.Writer, prefix, format string, args ...interface{})`: pkg/prt/printer.go:176:1 (10) ```go func (p *printerConfig) withNewLine(v Verbosity, w io.Writer, ^ prefix string, format string, args ...interface{}) { ``` 3. emptyStringTest: replace `len(parts[0]) == 0` with `parts[0] == ""`: pkg/snowblock/task/shell/shell.go:165:5 (11) ```go if len(parts[0]) == 0 { ^ ``` 4. elseif: can replace 'else {if cond {}}' with 'else if cond {}': cmd/snowsaw/bootstrap/bootstrap.go:57:9 (12) ```go } else { ^ ``` 4. Remove unnecessary type conversions detected by unconvert (13). 1. unnecessary conversion: pkg/prt/printer.go:132:16 (14) ```go *v = Verbosity(l) ^ ``` References: (1) https://github.com/mvdan/unparam (2) https://github.com/arcticicestudio/snowsaw/blob/9366c4a9c6d59dd0fccad12fbc413842ea751fa6/cmd/snowsaw/bootstrap/bootstrap.go#L51 (3) https://github.com/golang/lint (4) https://github.com/arcticicestudio/snowsaw/blob/5aa483e7e5e45888254aa4d0143d2afb898b4332/pkg/config/encoder/json/json.go#L34 (5) https://github.com/arcticicestudio/snowsaw/blob/008edbcb509af2cb5ced942d679fa3845a4ec1e1/pkg/config/encoder/constants.go#L26 (6) https://github.com/arcticicestudio/snowsaw/blob/79afc12ebc15620fd94e78416e0b49a68bbf2eb6/pkg/prt/printer.go#L121 (7) https://github.com/arcticicestudio/snowsaw/blob/dea6ab56b7410a8cbc8901818703d5ab1ace5c87/pkg/config/builder/builder.go#L39 (8) https://github.com/go-critic/go-critic (9) https://github.com/arcticicestudio/snowsaw/blob/79afc12ebc15620fd94e78416e0b49a68bbf2eb6/pkg/prt/printer.go#L179 (10) https://github.com/arcticicestudio/snowsaw/blob/79afc12ebc15620fd94e78416e0b49a68bbf2eb6/pkg/prt/printer.go#L176 (11) https://github.com/arcticicestudio/snowsaw/blob/a78810b7ccb5ddb8e80929d54fb7c461a1b80a1c/pkg/snowblock/task/shell/shell.go#L165 (12) https://github.com/arcticicestudio/snowsaw/blob/9366c4a9c6d59dd0fccad12fbc413842ea751fa6/cmd/snowsaw/bootstrap/bootstrap.go#L57 (13) https://github.com/mdempsky/unconvert (14) https://github.com/arcticicestudio/snowsaw/blob/79afc12ebc15620fd94e78416e0b49a68bbf2eb6/pkg/prt/printer.go#L132 Epic: GH-33 Resolves GH-80
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The problems in the current code base detected by the linters that have been integrated in #62 through GolangCI should be handled by refactoring the affected implementations.
This helps to improve the overall code quality and prevents possible errors.
(*cmdOptions).prepare
-cmd
is unused: cmd/snowsaw/bootstrap/bootstrap.go:51:30(*cmdOptions).run
-cmd
is unused: cmd/snowsaw/bootstrap/bootstrap.go💯26(*cmdOptions).run
-args
is unused: cmd/snowsaw/bootstrap/bootstrap.go💯46NewJsonEncoder
should beNewJSONEncoder
: pkg/config/encoder/json/json.go:34:6ExtensionsJson
should beExtensionsJSON
: pkg/config/encoder/constants.go:26:2format = format + "\n"
withformat += "\n"
: pkg/prt/printer.go:179:4func(v Verbosity, w io.Writer, prefix string, format string, args ...interface{})
could be replaced withfunc(v Verbosity, w io.Writer, prefix, format string, args ...interface{})
: pkg/prt/printer.go:176:1len(parts[0]) == 0
withparts[0] == ""
: pkg/snowblock/task/shell/shell.go:165:5The text was updated successfully, but these errors were encountered: