Skip to content

Handle problems detected by used linters #80

@arcticicestudio

Description

@arcticicestudio

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.

  1. Remove unused function parameters detected by unparam.
    1. (*cmdOptions).prepare - cmd is unused: cmd/snowsaw/bootstrap/bootstrap.go:51:30
      func (o *cmdOptions) prepare(cmd *cobra.Command, args []string) {
                                   ^
    2. (*cmdOptions).run - cmd is unused: cmd/snowsaw/bootstrap/bootstrap.go💯26
      func (o *cmdOptions) run(cmd *cobra.Command, args []string) {
                               ^
    3. (*cmdOptions).run - args is unused: cmd/snowsaw/bootstrap/bootstrap.go💯46
      func (o *cmdOptions) run(cmd *cobra.Command, args []string) {
                                                   ^
  2. Improve function names and code flows detected by golint.
    1. func NewJsonEncoder should be NewJSONEncoder: pkg/config/encoder/json/json.go:34:6
      func NewJsonEncoder() Encoder {
           ^
    2. var ExtensionsJson should be ExtensionsJSON: pkg/config/encoder/constants.go:26:2
      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
      } else {
             ^
    4. exported func Load returns unexported type *builder.builder, which can be annoying to use: pkg/config/builder/builder.go:39:32
      func Load(files ...*file.File) *builder {
                                     ^
  3. Improve code style smells detected by gocritic.
    1. assignOp: replace format = format + "\n" with format += "\n": pkg/prt/printer.go:179:4
      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
      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
      if len(parts[0]) == 0 {
         ^
    4. elseif: can replace 'else {if cond {}}' with 'else if cond {}': cmd/snowsaw/bootstrap/bootstrap.go:57:9
      } else {
             ^
  4. Remove unnecessary type conversions detected by unconvert.
    1. unnecessary conversion: pkg/prt/printer.go:132:16
      *v = Verbosity(l)
                    ^

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions