diff --git a/.automation/test/golang/golang_fix_01.go b/.automation/test/golang/golang_fix_01.go new file mode 100644 index 00000000000..0b39e9189d5 --- /dev/null +++ b/.automation/test/golang/golang_fix_01.go @@ -0,0 +1,9 @@ +// This is a package comment +package main + +import "fmt" + +func main() { +fmt.Println("hello world") +nicolas() +} diff --git a/.automation/test/golang/golang_fix_02.go b/.automation/test/golang/golang_fix_02.go new file mode 100644 index 00000000000..426a5bbcd0f --- /dev/null +++ b/.automation/test/golang/golang_fix_02.go @@ -0,0 +1,8 @@ +// This is a package comment +package main + +import "fmt" + +func nicolas() { +fmt.Println("hello world") +} diff --git a/.github/linters/.golangci.yml b/.github/linters/.golangci.yml index 5088d6310e4..01021999d82 100644 --- a/.github/linters/.golangci.yml +++ b/.github/linters/.golangci.yml @@ -1,40 +1,11 @@ ---- -######################### -######################### -## Golang Linter rules ## -######################### -######################### - -# configure golangci-lint -# see https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml -issues: - exclude-rules: - - path: _test\.go - linters: - - dupl - - gosec - - goconst linters: + disable-all: true enable: - - golint - - gosec - - unconvert - - gocyclo - - goconst - - goimports - - maligned + - gofmt - gocritic -linters-settings: - errcheck: - # report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`; - # default is false: such cases aren't reported by default. - check-blank: true - govet: - # report about shadowed variables - check-shadowing: true - gocyclo: - # minimal code complexity to report, 30 by default - min-complexity: 15 - maligned: - # print struct with more effective memory layout or not, false by default - suggest-new: true + - gosimple + - govet + - ineffassign + - staticcheck + - typecheck + - unused diff --git a/CHANGELOG.md b/CHANGELOG.md index 70eee5f6d2f..31df523d3d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), Note: Can be used with `oxsecurity/megalinter@beta` in your GitHub Action mega-linter.yml file, or with `oxsecurity/megalinter:beta` docker image -- cljstyle: Remove default value for configuration file name +- Linter enhancements & fixes + - cljstyle: Remove default value for configuration file name + - golangci-lint : Add autofix capability using **--fix** argument - Linter versions upgrades - [clj-kondo](https://github.com/borkdude/clj-kondo) from 2023.05.18 to **2023.05.26** on 2023-06-01 diff --git a/TEMPLATES/.golangci.yml b/TEMPLATES/.golangci.yml index 5088d6310e4..4e6e87fe846 100644 --- a/TEMPLATES/.golangci.yml +++ b/TEMPLATES/.golangci.yml @@ -1,40 +1,11 @@ ---- -######################### -######################### -## Golang Linter rules ## -######################### -######################### - -# configure golangci-lint -# see https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml -issues: - exclude-rules: - - path: _test\.go - linters: - - dupl - - gosec - - goconst linters: + disable-all: true enable: - - golint - - gosec - - unconvert - - gocyclo - - goconst - - goimports - - maligned + - gofmt - gocritic -linters-settings: - errcheck: - # report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`; - # default is false: such cases aren't reported by default. - check-blank: true - govet: - # report about shadowed variables - check-shadowing: true - gocyclo: - # minimal code complexity to report, 30 by default - min-complexity: 15 - maligned: - # print struct with more effective memory layout or not, false by default - suggest-new: true + - gosimple + - govet + - ineffassign + - staticcheck + - typecheck + - unused \ No newline at end of file diff --git a/megalinter/descriptors/go.megalinter-descriptor.yml b/megalinter/descriptors/go.megalinter-descriptor.yml index bdc1d19dc0a..5f1024eb27c 100644 --- a/megalinter/descriptors/go.megalinter-descriptor.yml +++ b/megalinter/descriptors/go.megalinter-descriptor.yml @@ -19,6 +19,7 @@ linters: cli_lint_mode: list_of_files cli_lint_extra_args: - "run" + cli_lint_fix_arg_name: --fix cli_version_arg_name: "version" version_extract_regex: "((\\d+(\\.\\d+)+)|(master))" examples: