From 8f31699cba64ce54a9fb15932de6927407515765 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Tue, 18 Feb 2025 16:39:01 +0100 Subject: [PATCH 01/13] docs: update JSONSchema, reference, and index --- .golangci.next.reference.yml | 93 +++++++++------ docs/src/docs/index.mdx | 4 +- jsonschema/golangci.next.jsonschema.json | 140 ++++++++++++++++------- 3 files changed, 153 insertions(+), 84 deletions(-) diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index 05fddf8419a9..fc0354df73d2 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -4080,45 +4080,62 @@ issues: # output configuration options output: # The formats used to render issues. - # Formats: - # - `colored-line-number` - # - `line-number` - # - `json` - # - `colored-tab` - # - `tab` - # - `html` - # - `checkstyle` - # - `code-climate` - # - `junit-xml` - # - `junit-xml-extended` - # - `github-actions` - # - `teamcity` - # - `sarif` - # Output path can be either `stdout`, `stderr` or path to the file to write to. - # - # For the CLI flag (`--out-format`), multiple formats can be specified by separating them by comma. - # The output can be specified for each of them by separating format name and path by colon symbol. - # Example: "--out-format=checkstyle:report.xml,json:stdout,colored-line-number" - # The CLI flag (`--out-format`) override the configuration file. - # - # Default: - # formats: - # - format: colored-line-number - # path: stdout formats: - - format: json - path: stderr - - format: checkstyle - path: report.xml - - format: colored-line-number - - # Print lines of code with issue. - # Default: true - print-issued-lines: false - - # Print linter name in the end of issue text. - # Default: true - print-linter-name: false + # (line-number) + text: + # Output path can be either `stdout`, `stderr` or path to the file to write to. + # Default: stdout + path: ./path/to/report.txt + # Print linter name in the end of issue text. + # Default: true + print-linter-name: false + # Print lines of code with issue. + # Default: true + print-issued-lines: false + # Use colors. + # Default: true + colors: false + json: + # Output path can be either `stdout`, `stderr` or path to the file to write to. + # Default: stdout + path: ./path/to/output.json + tab: + # Output path can be either `stdout`, `stderr` or path to the file to write to. + # Default: stdout + path: stdout + # Print linter name in the end of issue text. + # Default: true + print-linter-name: true + # Use colors. + # Default: true + colors: false + html: + # Output path can be either `stdout`, `stderr` or path to the file to write to. + # Default: stdout + path: ./path/to/output.html + checkstyle: + # Output path can be either `stdout`, `stderr` or path to the file to write to. + # Default: stdout + path: ./path/to/output.xml + code-climate: + # Output path can be either `stdout`, `stderr` or path to the file to write to. + # Default: stdout + path: ./path/to/output.json + junit-xml: + # Output path can be either `stdout`, `stderr` or path to the file to write to. + # Default: stdout + path: ./path/to/output.xml + # Support extra JUnit XML fields. + # Default: false + extended: true + teamcity: + # Output path can be either `stdout`, `stderr` or path to the file to write to. + # Default: stdout + path: ./path/to/output.txt + sarif: + # Output path can be either `stdout`, `stderr` or path to the file to write to. + # Default: stdout + path: ./path/to/output.json # Add a prefix to the output file references. # Default: "" diff --git a/docs/src/docs/index.mdx b/docs/src/docs/index.mdx index 034f3a2ad8cb..e6ae9032cf6a 100644 --- a/docs/src/docs/index.mdx +++ b/docs/src/docs/index.mdx @@ -2,7 +2,7 @@ title: Introduction --- -import { FaTwitter, FaSlack } from "react-icons/fa"; +import { FaSlack } from "react-icons/fa"; import { IconContainer } from "lib/icons"; [![License](https://img.shields.io/github/license/golangci/golangci-lint)](https://github.com/golangci/golangci-lint/blob/HEAD/LICENSE) @@ -30,7 +30,7 @@ Follow the news and releases: - 🖥 [Integrations](/welcome/integrations) with VS Code, Sublime Text, GoLand, GNU Emacs, Vim, GitHub Actions. - 🥇 [A lot of linters](/usage/linters) included, no need to install them. - 📈 Minimum number of [false positives](/usage/false-positives) because of tuned default settings. -- 🔥 Nice output with colors, source code lines and marked `identifiers`. +- 🔥 Nice output with colors, source code lines (Text, JSON, Tab, HTML, Checkstyle, Code-Climate, JUnit-XML, Teamcity, SARIF). [Get started now!](/welcome/install) diff --git a/jsonschema/golangci.next.jsonschema.json b/jsonschema/golangci.next.jsonschema.json index 1d56eedb2922..79645d8bbe62 100644 --- a/jsonschema/golangci.next.jsonschema.json +++ b/jsonschema/golangci.next.jsonschema.json @@ -454,6 +454,29 @@ "cfg", "wd" ] + }, + "simple-format": { + "type": "object", + "additionalProperties": false, + "properties": { + "path": { + "$ref": "#/definitions/formats-path", + "default": "stdout" + } + } + }, + "formats-path" : { + "anyOf": [ + { + "enum": [ + "stdout", + "stderr" + ] + }, + { + "type": "string" + } + ] } }, "type": "object", @@ -530,54 +553,83 @@ "properties": { "formats": { "description": "Output formats to use.", - "type": "array", - "items": { - "type": "object", - "additionalProperties": false, - "properties": { - "path": { - "default": "stdout", - "anyOf": [ - { - "enum": [ "stdout", "stderr" ] - }, - { - "type": "string" - } - ] - }, - "format": { - "default": "colored-line-number", - "enum": [ - "colored-line-number", - "line-number", - "json", - "colored-tab", - "tab", - "html", - "checkstyle", - "code-climate", - "junit-xml", - "junit-xml-extended", - "github-actions", - "teamcity", - "sarif" - ] + "type": "object", + "additionalProperties": false, + "properties": { + "text": { + "type": "object", + "additionalProperties": false, + "properties": { + "path": { + "$ref": "#/definitions/formats-path", + "default": "stdout" + }, + "print-linter-name": { + "type": "boolean", + "default": true + }, + "print-issued-lines": { + "type": "boolean", + "default": true + }, + "colors": { + "type": "boolean", + "default": true + } + } + }, + "json": { + "$ref": "#/definitions/simple-format" + }, + "tab": { + "type": "object", + "additionalProperties": false, + "properties": { + "path": { + "$ref": "#/definitions/formats-path", + "default": "stdout" + }, + "print-linter-name": { + "type": "boolean", + "default": true + }, + "colors": { + "type": "boolean", + "default": true + } } }, - "required": ["format"] + "html": { + "$ref": "#/definitions/simple-format" + }, + "checkstyle": { + "$ref": "#/definitions/simple-format" + }, + "code-climate": { + "$ref": "#/definitions/simple-format" + }, + "junit-xml": { + "type": "object", + "additionalProperties": false, + "properties": { + "path": { + "$ref": "#/definitions/formats-path", + "default": "stdout" + }, + "extended": { + "type": "boolean", + "default": true + } + } + }, + "teamcity": { + "$ref": "#/definitions/simple-format" + }, + "sarif": { + "$ref": "#/definitions/simple-format" + } } }, - "print-issued-lines": { - "description": "Print lines of code with issue.", - "type": "boolean", - "default": true - }, - "print-linter-name": { - "description": "Print linter name in the end of issue text.", - "type": "boolean", - "default": true - }, "path-prefix": { "description": "Add a prefix to the output file references.", "type": "string", From 47e4360440b7cf07ba5ecb07cbf25cb3b9cf4a1e Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Tue, 18 Feb 2025 16:39:28 +0100 Subject: [PATCH 02/13] chore: remove GitHub Action format --- pkg/printers/githubaction.go | 52 ----------------- pkg/printers/githubaction_test.go | 95 ------------------------------- 2 files changed, 147 deletions(-) delete mode 100644 pkg/printers/githubaction.go delete mode 100644 pkg/printers/githubaction_test.go diff --git a/pkg/printers/githubaction.go b/pkg/printers/githubaction.go deleted file mode 100644 index d9cdb1e6e603..000000000000 --- a/pkg/printers/githubaction.go +++ /dev/null @@ -1,52 +0,0 @@ -package printers - -import ( - "fmt" - "io" - "path/filepath" - - "github.com/golangci/golangci-lint/pkg/result" -) - -const defaultGithubSeverity = "error" - -type GitHubAction struct { - w io.Writer -} - -// NewGitHubAction output format outputs issues according to GitHub Action. -// Deprecated -func NewGitHubAction(w io.Writer) *GitHubAction { - return &GitHubAction{w: w} -} - -func (p *GitHubAction) Print(issues []result.Issue) error { - for ind := range issues { - _, err := fmt.Fprintln(p.w, formatIssueAsGitHub(&issues[ind])) - if err != nil { - return err - } - } - return nil -} - -// print each line as: ::error file=app.js,line=10,col=15::Something went wrong -func formatIssueAsGitHub(issue *result.Issue) string { - severity := defaultGithubSeverity - if issue.Severity != "" { - severity = issue.Severity - } - - // Convert backslashes to forward slashes. - // This is needed when running on windows. - // Otherwise, GitHub won't be able to show the annotations pointing to the file path with backslashes. - file := filepath.ToSlash(issue.FilePath()) - - ret := fmt.Sprintf("::%s file=%s,line=%d", severity, file, issue.Line()) - if issue.Pos.Column != 0 { - ret += fmt.Sprintf(",col=%d", issue.Pos.Column) - } - - ret += fmt.Sprintf("::%s (%s)", issue.Text, issue.FromLinter) - return ret -} diff --git a/pkg/printers/githubaction_test.go b/pkg/printers/githubaction_test.go deleted file mode 100644 index d45fdb73dd05..000000000000 --- a/pkg/printers/githubaction_test.go +++ /dev/null @@ -1,95 +0,0 @@ -package printers - -import ( - "bytes" - "go/token" - "runtime" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/golangci/golangci-lint/pkg/result" -) - -func TestGitHubAction_Print(t *testing.T) { - issues := []result.Issue{ - { - FromLinter: "linter-a", - Severity: "warning", - Text: "some issue", - Pos: token.Position{ - Filename: "path/to/filea.go", - Offset: 2, - Line: 10, - Column: 4, - }, - }, - { - FromLinter: "linter-b", - Severity: "error", - Text: "another issue", - SourceLines: []string{ - "func foo() {", - "\tfmt.Println(\"bar\")", - "}", - }, - Pos: token.Position{ - Filename: "path/to/fileb.go", - Offset: 5, - Line: 300, - Column: 9, - }, - }, - } - - buf := new(bytes.Buffer) - printer := NewGitHubAction(buf) - - err := printer.Print(issues) - require.NoError(t, err) - - expected := `::warning file=path/to/filea.go,line=10,col=4::some issue (linter-a) -::error file=path/to/fileb.go,line=300,col=9::another issue (linter-b) -` - - assert.Equal(t, expected, buf.String()) -} - -func Test_formatIssueAsGitHub(t *testing.T) { - sampleIssue := result.Issue{ - FromLinter: "sample-linter", - Text: "some issue", - Pos: token.Position{ - Filename: "path/to/file.go", - Offset: 2, - Line: 10, - Column: 4, - }, - } - require.Equal(t, "::error file=path/to/file.go,line=10,col=4::some issue (sample-linter)", formatIssueAsGitHub(&sampleIssue)) - - sampleIssue.Pos.Column = 0 - require.Equal(t, "::error file=path/to/file.go,line=10::some issue (sample-linter)", formatIssueAsGitHub(&sampleIssue)) -} - -func Test_formatIssueAsGitHub_Windows(t *testing.T) { - if runtime.GOOS != "windows" { - t.Skip("Skipping test on non Windows") - } - - sampleIssue := result.Issue{ - FromLinter: "sample-linter", - Text: "some issue", - Pos: token.Position{ - Filename: "path\\to\\file.go", - Offset: 2, - Line: 10, - Column: 4, - }, - } - require.Equal(t, "::error file=path/to/file.go,line=10,col=4::some issue (sample-linter)", formatIssueAsGitHub(&sampleIssue)) - - sampleIssue.Pos.Column = 0 - require.Equal(t, "::error file=path/to/file.go,line=10::some issue (sample-linter)", formatIssueAsGitHub(&sampleIssue)) -} From 6127190e9f128b4c19e419ca4d3e9309e320b16b Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Tue, 18 Feb 2025 16:40:15 +0100 Subject: [PATCH 03/13] feat: new output format configuration --- pkg/commands/flagsets.go | 53 ++++++++-- pkg/commands/run.go | 4 +- pkg/config/loader.go | 20 ---- pkg/config/output.go | 88 +---------------- pkg/config/output_formats.go | 57 +++++++++++ pkg/config/output_test.go | 78 --------------- pkg/printers/printer.go | 187 +++++++++++++++++++++++------------ pkg/printers/printer_test.go | 60 +++++------ pkg/printers/tab.go | 7 +- pkg/printers/tab_test.go | 7 +- pkg/printers/text.go | 9 +- pkg/printers/text_test.go | 8 +- 12 files changed, 279 insertions(+), 299 deletions(-) create mode 100644 pkg/config/output_formats.go diff --git a/pkg/commands/flagsets.go b/pkg/commands/flagsets.go index 67a774315eb9..c2767f7aad66 100644 --- a/pkg/commands/flagsets.go +++ b/pkg/commands/flagsets.go @@ -72,12 +72,6 @@ func setupRunFlagSet(v *viper.Viper, fs *pflag.FlagSet) { } func setupOutputFlagSet(v *viper.Viper, fs *pflag.FlagSet) { - internal.AddFlagAndBind(v, fs, fs.String, "out-format", "output.formats", config.OutFormatColoredLineNumber, - formatList("Formats of output:", config.AllOutputFormats)) - internal.AddFlagAndBind(v, fs, fs.Bool, "print-issued-lines", "output.print-issued-lines", true, - color.GreenString("Print lines of code with issue")) - internal.AddFlagAndBind(v, fs, fs.Bool, "print-linter-name", "output.print-linter-name", true, - color.GreenString("Print linter name in issue line")) internal.AddFlagAndBind(v, fs, fs.Bool, "sort-results", "output.sort-results", false, color.GreenString("Sort linter results")) internal.AddFlagAndBind(v, fs, fs.StringSlice, "sort-order", "output.sort-order", nil, @@ -85,6 +79,53 @@ func setupOutputFlagSet(v *viper.Viper, fs *pflag.FlagSet) { internal.AddFlagAndBind(v, fs, fs.String, "path-prefix", "output.path-prefix", "", color.GreenString("Path prefix to add to output")) internal.AddFlagAndBind(v, fs, fs.Bool, "show-stats", "output.show-stats", false, color.GreenString("Show statistics per linter")) + + setupOutputFormatsFlagSet(v, fs) +} + +func setupOutputFormatsFlagSet(v *viper.Viper, fs *pflag.FlagSet) { + outputPathDesc := "Output path can be either `stdout`, `stderr` or path to the file to write to." + printLinterNameDesc := "Print linter name in the end of issue text." + colorsDesc := "Use colors." + + internal.AddFlagAndBind(v, fs, fs.String, "output.text.path", "output.formats.text.path", "", + color.GreenString(outputPathDesc)) + internal.AddFlagAndBind(v, fs, fs.Bool, "output.text.print-linter-name", "output.formats.text.print-linter-name", true, + color.GreenString(printLinterNameDesc)) + internal.AddFlagAndBind(v, fs, fs.Bool, "output.text.print-issued-lines", "output.formats.text.print-issued-lines", true, + color.GreenString("Print lines of code with issue.")) + internal.AddFlagAndBind(v, fs, fs.Bool, "output.text.colors", "output.formats.text.colors", true, + color.GreenString(colorsDesc)) + + internal.AddFlagAndBind(v, fs, fs.String, "output.json.path", "output.formats.json.path", "", + color.GreenString(outputPathDesc)) + + internal.AddFlagAndBind(v, fs, fs.String, "output.tab.path", "output.formats.tab.path", "", + color.GreenString(outputPathDesc)) + internal.AddFlagAndBind(v, fs, fs.Bool, "output.tab.print-linter-name", "output.formats.tab.print-linter-name", + true, color.GreenString(printLinterNameDesc)) + internal.AddFlagAndBind(v, fs, fs.Bool, "output.tab.colors", "output.formats.tab.colors", true, + color.GreenString(colorsDesc)) + + internal.AddFlagAndBind(v, fs, fs.String, "output.html.path", "output.formats.html.path", "", + color.GreenString(outputPathDesc)) + + internal.AddFlagAndBind(v, fs, fs.String, "output.checkstyle.path", "output.formats.checkstyle.path", "", + color.GreenString(outputPathDesc)) + + internal.AddFlagAndBind(v, fs, fs.String, "output.code-climate.path", "output.formats.code-climate.path", "", + color.GreenString(outputPathDesc)) + + internal.AddFlagAndBind(v, fs, fs.String, "output.junit-xml.path", "output.formats.junit-xml.path", "", + color.GreenString(outputPathDesc)) + internal.AddFlagAndBind(v, fs, fs.Bool, "output.junit-xml.extended", "output.formats.junit-xml.extended", true, + color.GreenString("Support extra JUnit XML fields.")) + + internal.AddFlagAndBind(v, fs, fs.String, "output.teamcity.path", "output.formats.teamcity.path", "", + color.GreenString(outputPathDesc)) + + internal.AddFlagAndBind(v, fs, fs.String, "output.sarif.path", "output.formats.sarif.path", "", + color.GreenString(outputPathDesc)) } //nolint:gomnd // magic numbers here is ok diff --git a/pkg/commands/run.go b/pkg/commands/run.go index 3aa467daef3f..00096542f5a8 100644 --- a/pkg/commands/run.go +++ b/pkg/commands/run.go @@ -194,13 +194,11 @@ func (c *runCommand) preRunE(_ *cobra.Command, args []string) error { c.dbManager = dbManager - printer, err := printers.NewPrinter(c.log, &c.cfg.Output, c.reportData, c.cfg.GetBasePath()) + c.printer, err = printers.NewPrinter(c.log, &c.cfg.Output.Formats, c.reportData, c.cfg.GetBasePath()) if err != nil { return err } - c.printer = printer - c.goenv = goutil.NewEnv(c.log.Child(logutils.DebugKeyGoEnv)) c.fileCache = fsutils.NewFileCache() diff --git a/pkg/config/loader.go b/pkg/config/loader.go index 7079d90c1990..61e3a2aea038 100644 --- a/pkg/config/loader.go +++ b/pkg/config/loader.go @@ -370,26 +370,6 @@ func (l *Loader) handleDeprecation() error { l.cfg.Issues.UniqByLine = *l.cfg.Output.UniqByLine } - // Deprecated since v1.57.0 - if l.cfg.Output.Format != "" { - l.log.Warnf("The configuration option `output.format` is deprecated, please use `output.formats`") - - var f OutputFormats - err := f.UnmarshalText([]byte(l.cfg.Output.Format)) - if err != nil { - return fmt.Errorf("unmarshal output format: %w", err) - } - - l.cfg.Output.Formats = f - } - - for _, format := range l.cfg.Output.Formats { - if format.Format == OutFormatGithubActions { - l.log.Warnf("The output format `%s` is deprecated, please use `%s`", OutFormatGithubActions, OutFormatColoredLineNumber) - break // To avoid repeating the message if there are several usages of github-actions format. - } - } - // Deprecated since v1.59.0 if l.cfg.Issues.ExcludeGeneratedStrict != nil { l.log.Warnf("The configuration option `issues.exclude-generated-strict` is deprecated, please use `issues.exclude-generated`") diff --git a/pkg/config/output.go b/pkg/config/output.go index caddb095c960..7c0dd70bc3d0 100644 --- a/pkg/config/output.go +++ b/pkg/config/output.go @@ -7,49 +7,12 @@ import ( "strings" ) -const ( - OutFormatJSON = "json" - OutFormatLineNumber = "line-number" - OutFormatColoredLineNumber = "colored-line-number" - OutFormatTab = "tab" - OutFormatColoredTab = "colored-tab" - OutFormatCheckstyle = "checkstyle" - OutFormatCodeClimate = "code-climate" - OutFormatHTML = "html" - OutFormatJUnitXML = "junit-xml" - OutFormatJUnitXMLExtended = "junit-xml-extended" - OutFormatGithubActions = "github-actions" // Deprecated - OutFormatTeamCity = "teamcity" - OutFormatSarif = "sarif" -) - -var AllOutputFormats = []string{ - OutFormatJSON, - OutFormatLineNumber, - OutFormatColoredLineNumber, - OutFormatTab, - OutFormatColoredTab, - OutFormatCheckstyle, - OutFormatCodeClimate, - OutFormatHTML, - OutFormatJUnitXML, - OutFormatJUnitXMLExtended, - OutFormatGithubActions, - OutFormatTeamCity, - OutFormatSarif, -} - type Output struct { - Formats OutputFormats `mapstructure:"formats"` - PrintIssuedLine bool `mapstructure:"print-issued-lines"` - PrintLinterName bool `mapstructure:"print-linter-name"` - SortResults bool `mapstructure:"sort-results"` - SortOrder []string `mapstructure:"sort-order"` - PathPrefix string `mapstructure:"path-prefix"` - ShowStats bool `mapstructure:"show-stats"` - - // Deprecated: use Formats instead. - Format string `mapstructure:"format"` + Formats Formats `mapstructure:"formats"` + SortResults bool `mapstructure:"sort-results"` + SortOrder []string `mapstructure:"sort-order"` + PathPrefix string `mapstructure:"path-prefix"` + ShowStats bool `mapstructure:"show-stats"` // Deprecated: use [Issues.UniqByLine] instead. UniqByLine *bool `mapstructure:"uniq-by-line"` @@ -74,46 +37,5 @@ func (o *Output) Validate() error { } } - for _, format := range o.Formats { - err := format.Validate() - if err != nil { - return err - } - } - - return nil -} - -type OutputFormat struct { - Format string `mapstructure:"format"` - Path string `mapstructure:"path"` -} - -func (o *OutputFormat) Validate() error { - if o.Format == "" { - return errors.New("the format is required") - } - - if !slices.Contains(AllOutputFormats, o.Format) { - return fmt.Errorf("unsupported output format %q", o.Format) - } - - return nil -} - -type OutputFormats []OutputFormat - -func (p *OutputFormats) UnmarshalText(text []byte) error { - formats := strings.Split(string(text), ",") - - for _, item := range formats { - format, path, _ := strings.Cut(item, ":") - - *p = append(*p, OutputFormat{ - Path: path, - Format: format, - }) - } - return nil } diff --git a/pkg/config/output_formats.go b/pkg/config/output_formats.go new file mode 100644 index 000000000000..26b2a0dec7c4 --- /dev/null +++ b/pkg/config/output_formats.go @@ -0,0 +1,57 @@ +package config + +type Formats struct { + Text Text `mapstructure:"text"` + JSON SimpleStyle `mapstructure:"json"` + Tab Tab `mapstructure:"tab"` + HTML SimpleStyle `mapstructure:"html"` + Checkstyle SimpleStyle `mapstructure:"checkstyle"` + CodeClimate SimpleStyle `mapstructure:"code-climate"` + JUnitXML JUnitXML `mapstructure:"junit-xml"` + TeamCity SimpleStyle `mapstructure:"team-city"` + Sarif SimpleStyle `mapstructure:"sarif"` +} + +func (f *Formats) IsEmpty() bool { + styles := []SimpleStyle{ + f.Text.SimpleStyle, + f.JSON, + f.Tab.SimpleStyle, + f.HTML, + f.Checkstyle, + f.CodeClimate, + f.JUnitXML.SimpleStyle, + f.TeamCity, + f.Sarif, + } + + for _, style := range styles { + if style.Path != "" { + return false + } + } + + return true +} + +type SimpleStyle struct { + Path string `mapstructure:"path"` +} + +type Text struct { + SimpleStyle `mapstructure:",squash"` + PrintLinterName bool `mapstructure:"print-linter-name"` + PrintIssuedLine bool `mapstructure:"print-issued-lines"` + Colors bool `mapstructure:"colors"` +} + +type Tab struct { + SimpleStyle `mapstructure:",squash"` + PrintLinterName bool `mapstructure:"print-linter-name"` + UseColors bool `mapstructure:"use-colors"` +} + +type JUnitXML struct { + SimpleStyle `mapstructure:",squash"` + Extended bool `mapstructure:"extended"` +} diff --git a/pkg/config/output_test.go b/pkg/config/output_test.go index 0379cfc44b76..6d8aad17953f 100644 --- a/pkg/config/output_test.go +++ b/pkg/config/output_test.go @@ -80,84 +80,6 @@ func TestOutput_Validate_error(t *testing.T) { }, expected: `the sort-order name "linter" is repeated several times`, }, - { - desc: "unsupported format", - settings: &Output{ - Formats: []OutputFormat{ - { - Format: "test", - }, - }, - }, - expected: `unsupported output format "test"`, - }, - } - - for _, test := range testCases { - t.Run(test.desc, func(t *testing.T) { - t.Parallel() - - err := test.settings.Validate() - require.EqualError(t, err, test.expected) - }) - } -} - -func TestOutputFormat_Validate(t *testing.T) { - testCases := []struct { - desc string - settings *OutputFormat - }{ - { - desc: "only format", - settings: &OutputFormat{ - Format: "json", - }, - }, - { - desc: "format and path (relative)", - settings: &OutputFormat{ - Format: "json", - Path: "./example.json", - }, - }, - { - desc: "format and path (absolute)", - settings: &OutputFormat{ - Format: "json", - Path: "/tmp/example.json", - }, - }, - } - - for _, test := range testCases { - t.Run(test.desc, func(t *testing.T) { - t.Parallel() - - err := test.settings.Validate() - require.NoError(t, err) - }) - } -} - -func TestOutputFormat_Validate_error(t *testing.T) { - testCases := []struct { - desc string - settings *OutputFormat - expected string - }{ - { - desc: "empty", - settings: &OutputFormat{}, - expected: "the format is required", - }, - { - desc: "unsupported format", - settings: &OutputFormat{ - Format: "test", - }, - expected: `unsupported output format "test"`, - }, } for _, test := range testCases { diff --git a/pkg/printers/printer.go b/pkg/printers/printer.go index 613e4abec8f9..90fa3dc6e32c 100644 --- a/pkg/printers/printer.go +++ b/pkg/printers/printer.go @@ -15,15 +15,20 @@ import ( "github.com/golangci/golangci-lint/pkg/result" ) +const ( + outputStdOut = "stdout" + outputStdErr = "stderr" +) + const defaultFileMode = 0o644 type issuePrinter interface { Print(issues []result.Issue) error } -// Printer prints issues +// Printer prints issues. type Printer struct { - cfg *config.Output + cfg *config.Formats reportData *report.Data basePath string @@ -34,7 +39,7 @@ type Printer struct { } // NewPrinter creates a new Printer. -func NewPrinter(log logutils.Log, cfg *config.Output, reportData *report.Data, basePath string) (*Printer, error) { +func NewPrinter(log logutils.Log, cfg *config.Formats, reportData *report.Data, basePath string) (*Printer, error) { if log == nil { return nil, errors.New("missing log argument in constructor") } @@ -55,97 +60,149 @@ func NewPrinter(log logutils.Log, cfg *config.Output, reportData *report.Data, b }, nil } -// Print prints issues based on the formats defined +// Print prints issues based on the formats defined. +// +//nolint:gocyclo,funlen // the complexity is related to the number of formats. func (c *Printer) Print(issues []result.Issue) error { - for _, format := range c.cfg.Formats { - err := c.printReports(issues, format) + if c.cfg.IsEmpty() { + c.cfg.Text.SimpleStyle.Path = outputStdOut + } + + var printers []issuePrinter + + if c.cfg.Text.Path != "" { + w, closer, err := c.createWriter(&c.cfg.Text.SimpleStyle) if err != nil { - return err + return fmt.Errorf("can't create output for %s: %w", c.cfg.Text.Path, err) } + + defer closer() + + printers = append(printers, NewText(c.log, w, &c.cfg.Text)) } - return nil -} + if c.cfg.JSON.Path != "" { + w, closer, err := c.createWriter(&c.cfg.JSON) + if err != nil { + return fmt.Errorf("can't create output for %s: %w", c.cfg.JSON.Path, err) + } -func (c *Printer) printReports(issues []result.Issue, format config.OutputFormat) error { - w, shouldClose, err := c.createWriter(format.Path) - if err != nil { - return fmt.Errorf("can't create output for %s: %w", format.Path, err) + defer closer() + + printers = append(printers, NewJSON(w, c.reportData)) } - defer func() { - if file, ok := w.(io.Closer); shouldClose && ok { - _ = file.Close() + if c.cfg.Tab.Path != "" { + w, closer, err := c.createWriter(&c.cfg.Sarif) + if err != nil { + return fmt.Errorf("can't create output for %s: %w", c.cfg.Sarif.Path, err) } - }() - p, err := c.createPrinter(format.Format, w) - if err != nil { - return err + defer closer() + + printers = append(printers, NewTab(c.log, w, &c.cfg.Tab)) + } + + if c.cfg.HTML.Path != "" { + w, closer, err := c.createWriter(&c.cfg.HTML) + if err != nil { + return fmt.Errorf("can't create output for %s: %w", c.cfg.HTML.Path, err) + } + + defer closer() + + printers = append(printers, NewHTML(w)) + } + + if c.cfg.Checkstyle.Path != "" { + w, closer, err := c.createWriter(&c.cfg.Checkstyle) + if err != nil { + return fmt.Errorf("can't create output for %s: %w", c.cfg.Checkstyle.Path, err) + } + + defer closer() + + printers = append(printers, NewCheckstyle(c.log, w)) } - if err = p.Print(issues); err != nil { - return fmt.Errorf("can't print %d issues: %w", len(issues), err) + if c.cfg.CodeClimate.Path != "" { + w, closer, err := c.createWriter(&c.cfg.CodeClimate) + if err != nil { + return fmt.Errorf("can't create output for %s: %w", c.cfg.CodeClimate.Path, err) + } + + defer closer() + + printers = append(printers, NewCodeClimate(c.log, w)) + } + + if c.cfg.JUnitXML.Path != "" { + w, closer, err := c.createWriter(&c.cfg.JUnitXML.SimpleStyle) + if err != nil { + return fmt.Errorf("can't create output for %s: %w", c.cfg.JUnitXML.Path, err) + } + + defer closer() + + printers = append(printers, NewJUnitXML(w, c.cfg.JUnitXML.Extended)) + } + + if c.cfg.TeamCity.Path != "" { + w, closer, err := c.createWriter(&c.cfg.TeamCity) + if err != nil { + return fmt.Errorf("can't create output for %s: %w", c.cfg.TeamCity.Path, err) + } + + defer closer() + + printers = append(printers, NewTeamCity(c.log, w)) + } + + if c.cfg.Sarif.Path != "" { + w, closer, err := c.createWriter(&c.cfg.Sarif) + if err != nil { + return fmt.Errorf("can't create output for %s: %w", c.cfg.Sarif.Path, err) + } + + defer closer() + + printers = append(printers, NewSarif(c.log, w)) + } + + for _, printer := range printers { + err := printer.Print(issues) + if err != nil { + return err + } } return nil } -func (c *Printer) createWriter(path string) (io.Writer, bool, error) { - if path == "" || path == "stdout" { - return c.stdOut, false, nil +func (c *Printer) createWriter(cfg *config.SimpleStyle) (io.Writer, func(), error) { + if cfg.Path == "" || cfg.Path == outputStdOut { + return c.stdOut, func() {}, nil } - if path == "stderr" { - return c.stdErr, false, nil + if cfg.Path == outputStdErr { + return c.stdErr, func() {}, nil } - if !filepath.IsAbs(path) { - path = filepath.Join(c.basePath, path) + if !filepath.IsAbs(cfg.Path) { + cfg.Path = filepath.Join(c.basePath, cfg.Path) } - err := os.MkdirAll(filepath.Dir(path), os.ModePerm) + err := os.MkdirAll(filepath.Dir(cfg.Path), os.ModePerm) if err != nil { - return nil, false, err + return nil, func() {}, err } - f, err := os.OpenFile(path, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, defaultFileMode) + f, err := os.OpenFile(cfg.Path, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, defaultFileMode) if err != nil { - return nil, false, err + return nil, func() {}, err } - return f, true, nil -} - -func (c *Printer) createPrinter(format string, w io.Writer) (issuePrinter, error) { - var p issuePrinter - - switch format { - case config.OutFormatJSON: - p = NewJSON(w, c.reportData) - case config.OutFormatLineNumber, config.OutFormatColoredLineNumber: - p = NewText(c.log, w, c.cfg.PrintLinterName, c.cfg.PrintIssuedLine, format == config.OutFormatColoredLineNumber) - case config.OutFormatTab, config.OutFormatColoredTab: - p = NewTab(c.log, w, c.cfg.PrintLinterName, format == config.OutFormatColoredTab) - case config.OutFormatCheckstyle: - p = NewCheckstyle(c.log, w) - case config.OutFormatCodeClimate: - p = NewCodeClimate(c.log, w) - case config.OutFormatHTML: - p = NewHTML(w) - case config.OutFormatJUnitXML, config.OutFormatJUnitXMLExtended: - p = NewJUnitXML(w, format == config.OutFormatJUnitXMLExtended) - case config.OutFormatGithubActions: - p = NewGitHubAction(w) - case config.OutFormatTeamCity: - p = NewTeamCity(c.log, w) - case config.OutFormatSarif: - p = NewSarif(c.log, w) - default: - return nil, fmt.Errorf("unknown output format %q", format) - } - - return p, nil + return f, func() { _ = f.Close() }, nil } type severitySanitizer struct { diff --git a/pkg/printers/printer_test.go b/pkg/printers/printer_test.go index f0ec639e0d33..e52bdb94266f 100644 --- a/pkg/printers/printer_test.go +++ b/pkg/printers/printer_test.go @@ -37,25 +37,20 @@ func TestPrinter_Print_stdout(t *testing.T) { testCases := []struct { desc string - cfg *config.Output + cfg *config.Formats expected string }{ { - desc: "stdout (implicit)", - cfg: &config.Output{ - Formats: []config.OutputFormat{ - {Format: "line-number"}, - }, - }, + desc: "stdout (implicit)", + cfg: &config.Formats{}, expected: "golden-line-number.txt", }, { desc: "stdout (explicit)", - cfg: &config.Output{ - Formats: []config.OutputFormat{ - { - Format: "line-number", - Path: "stdout", + cfg: &config.Formats{ + Text: config.Text{ + SimpleStyle: config.SimpleStyle{ + Path: "stdout", }, }, }, @@ -97,11 +92,10 @@ func TestPrinter_Print_stderr(t *testing.T) { data := &report.Data{} unmarshalFile(t, "in-report-data.json", data) - cfg := &config.Output{ - Formats: []config.OutputFormat{ - { - Format: "line-number", - Path: "stderr", + cfg := &config.Formats{ + Text: config.Text{ + SimpleStyle: config.SimpleStyle{ + Path: "stderr", }, }, } @@ -136,11 +130,10 @@ func TestPrinter_Print_file(t *testing.T) { outputPath := filepath.Join(t.TempDir(), "report.txt") - cfg := &config.Output{ - Formats: []config.OutputFormat{ - { - Format: "line-number", - Path: outputPath, + cfg := &config.Formats{ + Text: config.Text{ + SimpleStyle: config.SimpleStyle{ + Path: outputPath, }, }, } @@ -180,19 +173,16 @@ func TestPrinter_Print_multiple(t *testing.T) { outputPath := filepath.Join(t.TempDir(), "teamcity.txt") - cfg := &config.Output{ - Formats: []config.OutputFormat{ - { - Format: "teamcity", - Path: outputPath, - }, - { - Format: "json", - Path: "", - }, - { - Format: "line-number", - Path: "stderr", + cfg := &config.Formats{ + TeamCity: config.SimpleStyle{ + Path: outputPath, + }, + JSON: config.SimpleStyle{ + Path: "stdout", + }, + Text: config.Text{ + SimpleStyle: config.SimpleStyle{ + Path: "stderr", }, }, } diff --git a/pkg/printers/tab.go b/pkg/printers/tab.go index ac04ab0fbe3a..b027412b07c8 100644 --- a/pkg/printers/tab.go +++ b/pkg/printers/tab.go @@ -7,6 +7,7 @@ import ( "github.com/fatih/color" + "github.com/golangci/golangci-lint/pkg/config" "github.com/golangci/golangci-lint/pkg/logutils" "github.com/golangci/golangci-lint/pkg/result" ) @@ -20,10 +21,10 @@ type Tab struct { w io.Writer } -func NewTab(log logutils.Log, w io.Writer, printLinterName, useColors bool) *Tab { +func NewTab(log logutils.Log, w io.Writer, cfg *config.Tab) *Tab { return &Tab{ - printLinterName: printLinterName, - useColors: useColors, + printLinterName: cfg.PrintLinterName, + useColors: cfg.UseColors, log: log.Child(logutils.DebugKeyTabPrinter), w: w, } diff --git a/pkg/printers/tab_test.go b/pkg/printers/tab_test.go index 4fc9fa034589..99b0e4f6886e 100644 --- a/pkg/printers/tab_test.go +++ b/pkg/printers/tab_test.go @@ -9,6 +9,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/golangci/golangci-lint/pkg/config" "github.com/golangci/golangci-lint/pkg/logutils" "github.com/golangci/golangci-lint/pkg/result" ) @@ -87,7 +88,11 @@ path/to/fileb.go:300:9 another issue buf := new(bytes.Buffer) - printer := NewTab(logutils.NewStderrLog(logutils.DebugKeyEmpty), buf, test.printLinterName, test.useColors) + printer := NewTab(logutils.NewStderrLog(logutils.DebugKeyEmpty), buf, &config.Tab{ + SimpleStyle: config.SimpleStyle{}, + PrintLinterName: test.printLinterName, + UseColors: test.useColors, + }) err := printer.Print(issues) require.NoError(t, err) diff --git a/pkg/printers/text.go b/pkg/printers/text.go index 9e60408f0400..9be9a1dc5947 100644 --- a/pkg/printers/text.go +++ b/pkg/printers/text.go @@ -7,6 +7,7 @@ import ( "github.com/fatih/color" + "github.com/golangci/golangci-lint/pkg/config" "github.com/golangci/golangci-lint/pkg/logutils" "github.com/golangci/golangci-lint/pkg/result" ) @@ -21,11 +22,11 @@ type Text struct { w io.Writer } -func NewText(log logutils.Log, w io.Writer, printLinterName, printIssuedLine, useColors bool) *Text { +func NewText(log logutils.Log, w io.Writer, cfg *config.Text) *Text { return &Text{ - printLinterName: printLinterName, - printIssuedLine: printIssuedLine, - useColors: useColors, + printLinterName: cfg.PrintLinterName, + printIssuedLine: cfg.PrintIssuedLine, + useColors: cfg.Colors, log: log.Child(logutils.DebugKeyTextPrinter), w: w, } diff --git a/pkg/printers/text_test.go b/pkg/printers/text_test.go index 55eda1827914..49d212f1e639 100644 --- a/pkg/printers/text_test.go +++ b/pkg/printers/text_test.go @@ -9,6 +9,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/golangci/golangci-lint/pkg/config" "github.com/golangci/golangci-lint/pkg/logutils" "github.com/golangci/golangci-lint/pkg/result" ) @@ -115,7 +116,12 @@ path/to/fileb.go:300:9: another issue buf := new(bytes.Buffer) - printer := NewText(logutils.NewStderrLog(logutils.DebugKeyEmpty), buf, test.printLinterName, test.printIssuedLine, test.useColors) + printer := NewText(logutils.NewStderrLog(logutils.DebugKeyEmpty), buf, &config.Text{ + SimpleStyle: config.SimpleStyle{}, + PrintLinterName: test.printLinterName, + PrintIssuedLine: test.printIssuedLine, + Colors: test.useColors, + }) err := printer.Print(issues) require.NoError(t, err) From 000fdf14e601d91f2ec12b67f5d1519132b54ab3 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Tue, 18 Feb 2025 16:40:30 +0100 Subject: [PATCH 04/13] chore: update scripts --- scripts/bench/bench_local.sh | 4 ++-- scripts/bench/bench_version.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/bench/bench_local.sh b/scripts/bench/bench_local.sh index 78b40286ccf0..d3d6b2bf1474 100755 --- a/scripts/bench/bench_local.sh +++ b/scripts/bench/bench_local.sh @@ -46,5 +46,5 @@ go build -trimpath -ldflags '-s -w' -o golangci-lint ./cmd/golangci-lint ## Run hyperfine --warmup 1 \ --n 'local' --prepare './golangci-lint cache clean' "./golangci-lint run --issues-exit-code 0 --print-issued-lines=false --enable-only ${LINTER}" \ --n "${VERSION}" --prepare "./golangci-lint-${VERSION} cache clean" "./golangci-lint-${VERSION} run --issues-exit-code 0 --print-issued-lines=false --enable-only ${LINTER}" +-n 'local' --prepare './golangci-lint cache clean' "./golangci-lint run --issues-exit-code 0 ---output.text.print-issued-lines=false --enable-only ${LINTER}" \ +-n "${VERSION}" --prepare "./golangci-lint-${VERSION} cache clean" "./golangci-lint-${VERSION} run --issues-exit-code 0 ---output.text.print-issued-lines=false --enable-only ${LINTER}" diff --git a/scripts/bench/bench_version.sh b/scripts/bench/bench_version.sh index 2933421c8dd4..cbe6ffce19b3 100755 --- a/scripts/bench/bench_version.sh +++ b/scripts/bench/bench_version.sh @@ -54,5 +54,5 @@ install "${VERSION_NEW}" ## Run hyperfine --warmup 1 \ --n "${VERSION_OLD}" --prepare "./golangci-lint-${VERSION_OLD} cache clean" "./golangci-lint-${VERSION_OLD} run --issues-exit-code 0 --print-issued-lines=false --enable-only ${LINTER}" \ --n "${VERSION_NEW}" --prepare "./golangci-lint-${VERSION_NEW} cache clean" "./golangci-lint-${VERSION_NEW} run --issues-exit-code 0 --print-issued-lines=false --enable-only ${LINTER}" +-n "${VERSION_OLD}" --prepare "./golangci-lint-${VERSION_OLD} cache clean" "./golangci-lint-${VERSION_OLD} run --issues-exit-code 0 --output.text.print-issued-lines=false --enable-only ${LINTER}" \ +-n "${VERSION_NEW}" --prepare "./golangci-lint-${VERSION_NEW} cache clean" "./golangci-lint-${VERSION_NEW} run --issues-exit-code 0 --output.text.print-issued-lines=false --enable-only ${LINTER}" From 310150d94a5a30873af3120db6cd236a2a86e818 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Tue, 18 Feb 2025 16:40:55 +0100 Subject: [PATCH 05/13] tests: update integration tests --- test/output_test.go | 21 +++++++++------------ test/run_test.go | 14 +++++++------- test/testshared/integration/fix.go | 6 +++--- test/testshared/integration/run.go | 2 +- 4 files changed, 20 insertions(+), 23 deletions(-) diff --git a/test/output_test.go b/test/output_test.go index 026395e5d2e4..86eddd0546d2 100644 --- a/test/output_test.go +++ b/test/output_test.go @@ -21,9 +21,9 @@ func TestOutput_lineNumber(t *testing.T) { testshared.NewRunnerBuilder(t). WithArgs( "--disable-all", - "--print-issued-lines=false", - "--print-linter-name=false", - "--out-format=line-number", + "--output.text.print-issued-lines=false", + "--output.text.print-linter-name=false", + "--output.text.path=stdout", ). WithDirectives(sourcePath). WithTargetPath(sourcePath). @@ -40,9 +40,7 @@ func TestOutput_Stderr(t *testing.T) { testshared.NewRunnerBuilder(t). WithArgs( "--disable-all", - "--print-issued-lines=false", - "--print-linter-name=false", - "--out-format=json:stderr", + "--output.json.path=stderr", ). WithDirectives(sourcePath). WithTargetPath(sourcePath). @@ -60,9 +58,7 @@ func TestOutput_File(t *testing.T) { testshared.NewRunnerBuilder(t). WithArgs( "--disable-all", - "--print-issued-lines=false", - "--print-linter-name=false", - fmt.Sprintf("--out-format=json:%s", resultPath), + fmt.Sprintf("--output.json.path=%s", resultPath), ). WithDirectives(sourcePath). WithTargetPath(sourcePath). @@ -82,9 +78,10 @@ func TestOutput_Multiple(t *testing.T) { testshared.NewRunnerBuilder(t). WithArgs( "--disable-all", - "--print-issued-lines=false", - "--print-linter-name=false", - "--out-format=line-number,json:stdout", + "--output.text.print-issued-lines=false", + "--output.text.print-linter-name=false", + "--output.text.path=stdout", + "--output.json.path=stdout", ). WithDirectives(sourcePath). WithTargetPath(sourcePath). diff --git a/test/run_test.go b/test/run_test.go index d6493dd41538..f540fe7d9730 100644 --- a/test/run_test.go +++ b/test/run_test.go @@ -269,7 +269,7 @@ func TestLineDirectiveProcessedFiles(t *testing.T) { { desc: "lite loading", args: []string{ - "--print-issued-lines=false", + "--output.text.print-issued-lines=false", "--exclude-use-default=false", "-Erevive", }, @@ -284,7 +284,7 @@ func TestLineDirectiveProcessedFiles(t *testing.T) { { desc: "full loading", args: []string{ - "--print-issued-lines=false", + "--output.text.print-issued-lines=false", "--exclude-use-default=false", "-Erevive,govet", }, @@ -351,7 +351,7 @@ func TestSortedResults(t *testing.T) { testshared.NewRunnerBuilder(t). WithNoConfig(). - WithArgs("--print-issued-lines=false", test.opt). + WithArgs("--output.text.print-issued-lines=false", test.opt). WithTargetPath(testdataDir, "sort_results"). WithBinPath(binPath). Runner(). @@ -367,7 +367,7 @@ func TestSkippedDirsNoMatchArg(t *testing.T) { testshared.NewRunnerBuilder(t). WithNoConfig(). WithArgs( - "--print-issued-lines=false", + "--output.text.print-issued-lines=false", "--exclude-dirs", dir, "-Erevive", ). @@ -384,7 +384,7 @@ func TestSkippedDirsTestdata(t *testing.T) { testshared.NewRunnerBuilder(t). WithNoConfig(). WithArgs( - "--print-issued-lines=false", + "--output.text.print-issued-lines=false", "-Erevive", ). WithTargetPath(testdataDir, "skipdirs", "..."). @@ -504,7 +504,7 @@ func TestAbsPathDirAnalysis(t *testing.T) { testshared.NewRunnerBuilder(t). WithNoConfig(). WithArgs( - "--print-issued-lines=false", + "--output.text.print-issued-lines=false", "-Erevive", ). WithTargetPath(absDir). @@ -523,7 +523,7 @@ func TestAbsPathFileAnalysis(t *testing.T) { testshared.NewRunnerBuilder(t). WithNoConfig(). WithArgs( - "--print-issued-lines=false", + "--output.text.print-issued-lines=false", "-Erevive", ). WithTargetPath(absDir). diff --git a/test/testshared/integration/fix.go b/test/testshared/integration/fix.go index ddd5c5e5ab95..11a0fcdb19ea 100644 --- a/test/testshared/integration/fix.go +++ b/test/testshared/integration/fix.go @@ -67,9 +67,9 @@ func runFix(t *testing.T, extraArgs ...string) { testshared.NewRunnerBuilder(t). WithArgs("--disable-all", - "--print-issued-lines=false", - "--print-linter-name=false", - "--out-format=line-number", + "--output.text.print-issued-lines=false", + "--output.text.print-linter-name=false", + "--output.text.path=stdout", "--fix"). WithArgs(extraArgs...). WithRunContext(rc). diff --git a/test/testshared/integration/run.go b/test/testshared/integration/run.go index 9b0dac15c837..3aa6e289c202 100644 --- a/test/testshared/integration/run.go +++ b/test/testshared/integration/run.go @@ -63,7 +63,7 @@ func testOneSource(t *testing.T, log *logutils.StderrLog, binPath, sourcePath st args := []string{ "--disable-all", - "--out-format=json", + "--output.json.path=stdout", "--max-same-issues=100", "--max-issues-per-linter=100", } From 56f24e4277939769bf670c278d7e74de66d4ebbf Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Tue, 18 Feb 2025 16:55:34 +0100 Subject: [PATCH 06/13] feat: add configuration version field --- .golangci.next.reference.yml | 2 ++ jsonschema/golangci.next.jsonschema.json | 5 +++++ pkg/config/config.go | 2 ++ pkg/golinters/copyloopvar/testdata/copyloopvar.yml | 2 ++ pkg/golinters/cyclop/testdata/cyclop.yml | 2 ++ pkg/golinters/decorder/testdata/decorder_custom.yml | 2 ++ pkg/golinters/depguard/testdata/depguard.yml | 2 ++ .../depguard/testdata/depguard_additional_guards.yml | 2 ++ .../depguard/testdata/depguard_ignore_file_rules.yml | 2 ++ pkg/golinters/dupl/testdata/dupl.yml | 2 ++ pkg/golinters/dupword/testdata/dupword_ignore_the.yml | 2 ++ .../errcheck/testdata/errcheck_exclude_functions.yml | 2 ++ pkg/golinters/errcheck/testdata/errcheck_ignore_default.yml | 2 ++ pkg/golinters/errcheck/testdata/errcheck_type_assertions.yml | 2 ++ pkg/golinters/errchkjson/testdata/errchkjson.yml | 2 ++ .../testdata/errchkjson_check_error_free_encoding.yml | 3 +++ pkg/golinters/errchkjson/testdata/errchkjson_no_exported.yml | 2 ++ pkg/golinters/errorlint/testdata/errorlint_asserts.yml | 2 ++ pkg/golinters/errorlint/testdata/errorlint_comparison.yml | 2 ++ pkg/golinters/errorlint/testdata/errorlint_errorf.yml | 2 ++ pkg/golinters/exhaustive/testdata/exhaustive_default.yml | 2 ++ .../exhaustive/testdata/exhaustive_ignore_enum_members.yml | 2 ++ pkg/golinters/exhaustruct/testdata/exhaustruct_custom.yml | 2 ++ .../fatcontext/testdata/fatcontext_structpointer.yml | 2 ++ pkg/golinters/forbidigo/testdata/forbidigo.yml | 2 ++ .../forbidigo/testdata/forbidigo_include_godoc_examples.yml | 2 ++ pkg/golinters/forbidigo/testdata/forbidigo_struct.yml | 2 ++ pkg/golinters/funlen/testdata/funlen.yml | 2 ++ pkg/golinters/gci/testdata/gci.yml | 2 ++ .../ginkgolinter/testdata/ginkgolinter_allow_havelen0.yml | 2 ++ pkg/golinters/ginkgolinter/testdata/ginkgolinter_default.yml | 2 ++ .../ginkgolinter/testdata/ginkgolinter_suppress_async.yml | 2 ++ .../ginkgolinter/testdata/ginkgolinter_suppress_compare.yml | 2 ++ .../ginkgolinter/testdata/ginkgolinter_suppress_err.yml | 2 ++ .../testdata/ginkgolinter_suppress_focused_containers.yml | 2 ++ .../ginkgolinter/testdata/ginkgolinter_suppress_len.yml | 2 ++ .../ginkgolinter/testdata/ginkgolinter_suppress_nil.yml | 2 ++ .../gochecksumtype/testdata/gochecksumtype_custom.yml | 2 ++ pkg/golinters/gocognit/testdata/gocognit.yml | 2 ++ pkg/golinters/goconst/testdata/goconst_calls_enabled.yml | 2 ++ pkg/golinters/goconst/testdata/goconst_dont_ignore.yml | 2 ++ pkg/golinters/goconst/testdata/goconst_ignore.yml | 2 ++ pkg/golinters/gocritic/testdata/gocritic-fix.yml | 2 ++ pkg/golinters/gocritic/testdata/gocritic.yml | 2 ++ pkg/golinters/gocritic/testdata/gocritic_configDir.yml | 2 ++ pkg/golinters/gocyclo/testdata/gocyclo.yml | 2 ++ pkg/golinters/godox/testdata/godox.yml | 2 ++ pkg/golinters/gofmt/testdata/gofmt_no_simplify.yml | 2 ++ pkg/golinters/gofmt/testdata/gofmt_rewrite_rules.yml | 2 ++ pkg/golinters/gofumpt/testdata/gofumpt-fix.yml | 2 ++ pkg/golinters/gofumpt/testdata/gofumpt_with_extra.yml | 2 ++ pkg/golinters/goheader/testdata/goheader-fix.yml | 2 ++ pkg/golinters/goheader/testdata/goheader.yml | 2 ++ pkg/golinters/goimports/testdata/goimports_local.yml | 2 ++ pkg/golinters/gomodguard/testdata/gomodguard.yml | 2 ++ pkg/golinters/gosec/testdata/gosec.yml | 2 ++ pkg/golinters/gosec/testdata/gosec_global_option.yml | 2 ++ pkg/golinters/gosec/testdata/gosec_nosec.yml | 2 ++ pkg/golinters/gosec/testdata/gosec_severity_confidence.yml | 2 ++ .../gosmopolitan/testdata/gosmopolitan_allow_time_local.yml | 2 ++ .../gosmopolitan/testdata/gosmopolitan_dont_ignore_tests.yml | 2 ++ .../gosmopolitan/testdata/gosmopolitan_escape_hatches.yml | 2 ++ pkg/golinters/gosmopolitan/testdata/gosmopolitan_scripts.yml | 2 ++ pkg/golinters/govet/testdata/govet.yml | 2 ++ pkg/golinters/govet/testdata/govet_fieldalignment.yml | 2 ++ pkg/golinters/govet/testdata/govet_fix.yml | 2 ++ pkg/golinters/govet/testdata/govet_ifaceassert.yml | 2 ++ pkg/golinters/grouper/testdata/grouper.yml | 2 ++ pkg/golinters/iface/testdata/iface_all.yml | 2 ++ pkg/golinters/iface/testdata/iface_fix.yml | 2 ++ pkg/golinters/iface/testdata/iface_identical.yml | 2 ++ pkg/golinters/iface/testdata/iface_opaque.yml | 2 ++ pkg/golinters/iface/testdata/iface_unused.yml | 2 ++ pkg/golinters/importas/testdata/importas.yml | 2 ++ .../importas/testdata/importas_several_empty_aliases.yml | 2 ++ pkg/golinters/importas/testdata/importas_strict.yml | 2 ++ .../inamedparam/testdata/inamedparam_skip_single_param.yml | 2 ++ pkg/golinters/ireturn/testdata/ireturn_allow.yml | 2 ++ pkg/golinters/ireturn/testdata/ireturn_reject_generics.yml | 2 ++ pkg/golinters/ireturn/testdata/ireturn_reject_stdlib.yml | 2 ++ pkg/golinters/lll/testdata/lll.yml | 2 ++ pkg/golinters/lll/testdata/lll_import.yml | 2 ++ pkg/golinters/loggercheck/testdata/loggercheck_custom.yml | 2 ++ .../loggercheck/testdata/loggercheck_kitlogonly.yml | 2 ++ pkg/golinters/loggercheck/testdata/loggercheck_logronly.yml | 2 ++ .../loggercheck/testdata/loggercheck_noprintflike.yml | 2 ++ .../loggercheck/testdata/loggercheck_requirestringkey.yml | 2 ++ pkg/golinters/loggercheck/testdata/loggercheck_slogonly.yml | 2 ++ pkg/golinters/loggercheck/testdata/loggercheck_zaponly.yml | 2 ++ pkg/golinters/maintidx/testdata/maintidx_under_100.yml | 2 ++ pkg/golinters/makezero/testdata/makezero_always.yml | 2 ++ pkg/golinters/misspell/testdata/misspell.yml | 2 ++ pkg/golinters/misspell/testdata/misspell_custom.yml | 2 ++ pkg/golinters/musttag/testdata/musttag.yml | 2 ++ pkg/golinters/nestif/testdata/nestif.yml | 2 ++ pkg/golinters/nilnil/testdata/nilnil_detect_opposite.yml | 2 ++ pkg/golinters/nilnil/testdata/nilnil_pointers_only.yml | 2 ++ pkg/golinters/nlreturn/testdata/nlreturn-block-size.yml | 2 ++ pkg/golinters/nolintlint/testdata/nolintlint.yml | 2 ++ pkg/golinters/nolintlint/testdata/nolintlint_unused.yml | 2 ++ .../nonamedreturns/testdata/nonamedreturns_custom.yml | 2 ++ pkg/golinters/paralleltest/testdata/paralleltest_custom.yml | 2 ++ pkg/golinters/perfsprint/testdata/perfsprint_custom.yml | 2 ++ pkg/golinters/predeclared/testdata/predeclared_custom.yml | 2 ++ pkg/golinters/reassign/testdata/reassign_patterns.yml | 2 ++ pkg/golinters/revive/testdata/revive-fix.yml | 2 ++ pkg/golinters/revive/testdata/revive.yml | 2 ++ .../sloglint/testdata/sloglint_args_on_sep_lines.yml | 2 ++ pkg/golinters/sloglint/testdata/sloglint_attr_only.yml | 2 ++ pkg/golinters/sloglint/testdata/sloglint_context_only.yml | 2 ++ pkg/golinters/sloglint/testdata/sloglint_forbidden_keys.yml | 2 ++ pkg/golinters/sloglint/testdata/sloglint_key_naming_case.yml | 2 ++ pkg/golinters/sloglint/testdata/sloglint_kv_only.yml | 2 ++ pkg/golinters/sloglint/testdata/sloglint_no_raw_keys.yml | 2 ++ pkg/golinters/sloglint/testdata/sloglint_static_msg.yml | 2 ++ pkg/golinters/spancheck/testdata/spancheck_enable_all.yml | 2 ++ pkg/golinters/spancheck/testdata/spancheck_keep_default.yml | 2 ++ pkg/golinters/tagalign/testdata/tagalign_align_only.yml | 2 ++ pkg/golinters/tagalign/testdata/tagalign_order_only.yml | 2 ++ pkg/golinters/tagalign/testdata/tagalign_sort_only.yml | 2 ++ pkg/golinters/tagalign/testdata/tagalign_strict.yml | 2 ++ .../tagliatelle/testdata/tagliatelle_ignored_fields.yml | 2 ++ pkg/golinters/tenv/testdata/tenv_all.yml | 2 ++ .../testifylint/testdata/testifylint_bool_compare_only.yml | 2 ++ .../testifylint/testdata/testifylint_formatter_only.yml | 2 ++ .../testifylint/testdata/testifylint_require_error_only.yml | 2 ++ pkg/golinters/thelper/testdata/thelper.yml | 2 ++ .../usestdlibvars/testdata/usestdlibvars_non_default.yml | 2 ++ .../usetesting/testdata/usetesting_configuration.yml | 2 ++ .../usetesting/testdata/usetesting_go124_configuration.yml | 2 ++ pkg/golinters/whitespace/testdata/whitespace-fix.yml | 2 ++ pkg/golinters/whitespace/testdata/whitespace.yml | 2 ++ pkg/golinters/wsl/testdata/wsl.yml | 2 ++ test/testdata/configs/default_exclude.yml | 4 +++- test/testdata/configs/multiple-issues-fix.yml | 2 ++ test/testdata/configs/output.yml | 2 ++ test/testdata/configs/path-except.yml | 2 ++ test/testdata/linedirective/dupl.yml | 2 ++ test/testdata/linedirective/gomodguard.yml | 2 ++ test/testdata/linedirective/lll.yml | 2 ++ test/testdata_etc/unused_exported/golangci.yml | 2 ++ 141 files changed, 287 insertions(+), 1 deletion(-) diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index fc0354df73d2..ff6192a7521c 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -4,6 +4,8 @@ # This file is not a configuration example, # it contains the exhaustive configuration with explanations of the options. +version: "2" + linters: # Disable all linters. # Default: false diff --git a/jsonschema/golangci.next.jsonschema.json b/jsonschema/golangci.next.jsonschema.json index 79645d8bbe62..76f02d15c137 100644 --- a/jsonschema/golangci.next.jsonschema.json +++ b/jsonschema/golangci.next.jsonschema.json @@ -481,7 +481,12 @@ }, "type": "object", "additionalProperties": false, + "required": ["version"], "properties": { + "version": { + "type": "string", + "default": "2" + }, "run": { "description": "Options for analysis running,", "type": "object", diff --git a/pkg/config/config.go b/pkg/config/config.go index 10327d5f31b1..7038371e9fa2 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -20,6 +20,8 @@ type Config struct { cfgDir string // Path to the directory containing golangci-lint config file. basePath string // Path the root directory related to [Run.RelativePathMode]. + Version string `mapstructure:"version"` + Run Run `mapstructure:"run"` Output Output `mapstructure:"output"` diff --git a/pkg/golinters/copyloopvar/testdata/copyloopvar.yml b/pkg/golinters/copyloopvar/testdata/copyloopvar.yml index 284c7396facd..89be6e5e54c1 100644 --- a/pkg/golinters/copyloopvar/testdata/copyloopvar.yml +++ b/pkg/golinters/copyloopvar/testdata/copyloopvar.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: copyloopvar: check-alias: true diff --git a/pkg/golinters/cyclop/testdata/cyclop.yml b/pkg/golinters/cyclop/testdata/cyclop.yml index abc1deb1b34f..6341d8616f2b 100644 --- a/pkg/golinters/cyclop/testdata/cyclop.yml +++ b/pkg/golinters/cyclop/testdata/cyclop.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: cyclop: max-complexity: 15 diff --git a/pkg/golinters/decorder/testdata/decorder_custom.yml b/pkg/golinters/decorder/testdata/decorder_custom.yml index 0ef8e49b3976..9a12dec5978b 100644 --- a/pkg/golinters/decorder/testdata/decorder_custom.yml +++ b/pkg/golinters/decorder/testdata/decorder_custom.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: decorder: dec-order: diff --git a/pkg/golinters/depguard/testdata/depguard.yml b/pkg/golinters/depguard/testdata/depguard.yml index 133b9adf2b82..ced24821d180 100644 --- a/pkg/golinters/depguard/testdata/depguard.yml +++ b/pkg/golinters/depguard/testdata/depguard.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: depguard: rules: diff --git a/pkg/golinters/depguard/testdata/depguard_additional_guards.yml b/pkg/golinters/depguard/testdata/depguard_additional_guards.yml index 0894d2eed80a..c50cfca9d21d 100644 --- a/pkg/golinters/depguard/testdata/depguard_additional_guards.yml +++ b/pkg/golinters/depguard/testdata/depguard_additional_guards.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: depguard: rules: diff --git a/pkg/golinters/depguard/testdata/depguard_ignore_file_rules.yml b/pkg/golinters/depguard/testdata/depguard_ignore_file_rules.yml index c71f7895188c..2849ca458615 100644 --- a/pkg/golinters/depguard/testdata/depguard_ignore_file_rules.yml +++ b/pkg/golinters/depguard/testdata/depguard_ignore_file_rules.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: depguard: rules: diff --git a/pkg/golinters/dupl/testdata/dupl.yml b/pkg/golinters/dupl/testdata/dupl.yml index 8abf10175e0c..f63f092b164a 100644 --- a/pkg/golinters/dupl/testdata/dupl.yml +++ b/pkg/golinters/dupl/testdata/dupl.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: dupl: threshold: 20 diff --git a/pkg/golinters/dupword/testdata/dupword_ignore_the.yml b/pkg/golinters/dupword/testdata/dupword_ignore_the.yml index 6fdb846444ae..53b4d4ac5724 100644 --- a/pkg/golinters/dupword/testdata/dupword_ignore_the.yml +++ b/pkg/golinters/dupword/testdata/dupword_ignore_the.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: dupword: ignore: diff --git a/pkg/golinters/errcheck/testdata/errcheck_exclude_functions.yml b/pkg/golinters/errcheck/testdata/errcheck_exclude_functions.yml index fcf07927a6d1..568661336826 100644 --- a/pkg/golinters/errcheck/testdata/errcheck_exclude_functions.yml +++ b/pkg/golinters/errcheck/testdata/errcheck_exclude_functions.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: errcheck: check-blank: true diff --git a/pkg/golinters/errcheck/testdata/errcheck_ignore_default.yml b/pkg/golinters/errcheck/testdata/errcheck_ignore_default.yml index fe801445f7ae..21a7c4f91797 100644 --- a/pkg/golinters/errcheck/testdata/errcheck_ignore_default.yml +++ b/pkg/golinters/errcheck/testdata/errcheck_ignore_default.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: errcheck: check-blank: true diff --git a/pkg/golinters/errcheck/testdata/errcheck_type_assertions.yml b/pkg/golinters/errcheck/testdata/errcheck_type_assertions.yml index aa2ba20a422d..2c900b7d6f99 100644 --- a/pkg/golinters/errcheck/testdata/errcheck_type_assertions.yml +++ b/pkg/golinters/errcheck/testdata/errcheck_type_assertions.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: errcheck: check-type-assertions: true diff --git a/pkg/golinters/errchkjson/testdata/errchkjson.yml b/pkg/golinters/errchkjson/testdata/errchkjson.yml index d7d534574241..e276c56fac2b 100644 --- a/pkg/golinters/errchkjson/testdata/errchkjson.yml +++ b/pkg/golinters/errchkjson/testdata/errchkjson.yml @@ -1,2 +1,4 @@ +version: "2" + issues: max-issues-per-linter: 100 diff --git a/pkg/golinters/errchkjson/testdata/errchkjson_check_error_free_encoding.yml b/pkg/golinters/errchkjson/testdata/errchkjson_check_error_free_encoding.yml index 0186bef7de95..1fccc634b928 100644 --- a/pkg/golinters/errchkjson/testdata/errchkjson_check_error_free_encoding.yml +++ b/pkg/golinters/errchkjson/testdata/errchkjson_check_error_free_encoding.yml @@ -1,5 +1,8 @@ +version: "2" + issues: max-issues-per-linter: 100 + linters-settings: errchkjson: check-error-free-encoding: true diff --git a/pkg/golinters/errchkjson/testdata/errchkjson_no_exported.yml b/pkg/golinters/errchkjson/testdata/errchkjson_no_exported.yml index b62e297c6160..d808eb69e624 100644 --- a/pkg/golinters/errchkjson/testdata/errchkjson_no_exported.yml +++ b/pkg/golinters/errchkjson/testdata/errchkjson_no_exported.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: errchkjson: report-no-exported: true diff --git a/pkg/golinters/errorlint/testdata/errorlint_asserts.yml b/pkg/golinters/errorlint/testdata/errorlint_asserts.yml index 5e00e940930d..712431ac3c40 100644 --- a/pkg/golinters/errorlint/testdata/errorlint_asserts.yml +++ b/pkg/golinters/errorlint/testdata/errorlint_asserts.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: errorlint: errorf: false diff --git a/pkg/golinters/errorlint/testdata/errorlint_comparison.yml b/pkg/golinters/errorlint/testdata/errorlint_comparison.yml index 8c9783d63b3c..07680450cbd0 100644 --- a/pkg/golinters/errorlint/testdata/errorlint_comparison.yml +++ b/pkg/golinters/errorlint/testdata/errorlint_comparison.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: errorlint: errorf: false diff --git a/pkg/golinters/errorlint/testdata/errorlint_errorf.yml b/pkg/golinters/errorlint/testdata/errorlint_errorf.yml index 6d647f9230a7..bb10224e6b99 100644 --- a/pkg/golinters/errorlint/testdata/errorlint_errorf.yml +++ b/pkg/golinters/errorlint/testdata/errorlint_errorf.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: errorlint: errorf: true diff --git a/pkg/golinters/exhaustive/testdata/exhaustive_default.yml b/pkg/golinters/exhaustive/testdata/exhaustive_default.yml index 03f2bf902863..d57057c264ca 100644 --- a/pkg/golinters/exhaustive/testdata/exhaustive_default.yml +++ b/pkg/golinters/exhaustive/testdata/exhaustive_default.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: exhaustive: default-signifies-exhaustive: true diff --git a/pkg/golinters/exhaustive/testdata/exhaustive_ignore_enum_members.yml b/pkg/golinters/exhaustive/testdata/exhaustive_ignore_enum_members.yml index d5b8e2166d9f..0c460db84b41 100644 --- a/pkg/golinters/exhaustive/testdata/exhaustive_ignore_enum_members.yml +++ b/pkg/golinters/exhaustive/testdata/exhaustive_ignore_enum_members.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: exhaustive: ignore-enum-members: "West$" diff --git a/pkg/golinters/exhaustruct/testdata/exhaustruct_custom.yml b/pkg/golinters/exhaustruct/testdata/exhaustruct_custom.yml index a2cb20f96528..6064b0fcf2a9 100644 --- a/pkg/golinters/exhaustruct/testdata/exhaustruct_custom.yml +++ b/pkg/golinters/exhaustruct/testdata/exhaustruct_custom.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: exhaustruct: include: diff --git a/pkg/golinters/fatcontext/testdata/fatcontext_structpointer.yml b/pkg/golinters/fatcontext/testdata/fatcontext_structpointer.yml index 95924ee1d7d6..0a62d5fe4bdd 100644 --- a/pkg/golinters/fatcontext/testdata/fatcontext_structpointer.yml +++ b/pkg/golinters/fatcontext/testdata/fatcontext_structpointer.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: fatcontext: check-struct-pointers: true diff --git a/pkg/golinters/forbidigo/testdata/forbidigo.yml b/pkg/golinters/forbidigo/testdata/forbidigo.yml index 11efcefad859..f52130687625 100644 --- a/pkg/golinters/forbidigo/testdata/forbidigo.yml +++ b/pkg/golinters/forbidigo/testdata/forbidigo.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: forbidigo: forbid: diff --git a/pkg/golinters/forbidigo/testdata/forbidigo_include_godoc_examples.yml b/pkg/golinters/forbidigo/testdata/forbidigo_include_godoc_examples.yml index 8bf10328866a..caf8d35d3af4 100644 --- a/pkg/golinters/forbidigo/testdata/forbidigo_include_godoc_examples.yml +++ b/pkg/golinters/forbidigo/testdata/forbidigo_include_godoc_examples.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: forbidigo: exclude-godoc-examples: false diff --git a/pkg/golinters/forbidigo/testdata/forbidigo_struct.yml b/pkg/golinters/forbidigo/testdata/forbidigo_struct.yml index 84d05c579b64..fc2b63a99fa7 100644 --- a/pkg/golinters/forbidigo/testdata/forbidigo_struct.yml +++ b/pkg/golinters/forbidigo/testdata/forbidigo_struct.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: forbidigo: analyze-types: true diff --git a/pkg/golinters/funlen/testdata/funlen.yml b/pkg/golinters/funlen/testdata/funlen.yml index 47acaaf42dff..ef39b55f71a1 100644 --- a/pkg/golinters/funlen/testdata/funlen.yml +++ b/pkg/golinters/funlen/testdata/funlen.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: funlen: lines: 20 diff --git a/pkg/golinters/gci/testdata/gci.yml b/pkg/golinters/gci/testdata/gci.yml index 3291610acc8b..4d259112001d 100644 --- a/pkg/golinters/gci/testdata/gci.yml +++ b/pkg/golinters/gci/testdata/gci.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: gci: sections: diff --git a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_allow_havelen0.yml b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_allow_havelen0.yml index 8309f8590559..929ef47fa077 100644 --- a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_allow_havelen0.yml +++ b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_allow_havelen0.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: ginkgolinter: allow-havelen-zero: true diff --git a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_default.yml b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_default.yml index 5c8b6a8f3a15..019cbba58dcf 100644 --- a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_default.yml +++ b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_default.yml @@ -1,2 +1,4 @@ +version: "2" + linters-settings: ginkgolinter: {} diff --git a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_async.yml b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_async.yml index cb074cddfd8f..2cc9ad84304a 100644 --- a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_async.yml +++ b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_async.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: ginkgolinter: suppress-async-assertion: true diff --git a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_compare.yml b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_compare.yml index 75ff24d8ff06..a5abb9e5fcd2 100644 --- a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_compare.yml +++ b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_compare.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: ginkgolinter: suppress-compare-assertion: true diff --git a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_err.yml b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_err.yml index 080942d0c802..c93086a4f4bb 100644 --- a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_err.yml +++ b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_err.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: ginkgolinter: suppress-err-assertion: true diff --git a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_focused_containers.yml b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_focused_containers.yml index 83f49e878b9e..ca9b2cc3807d 100644 --- a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_focused_containers.yml +++ b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_focused_containers.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: ginkgolinter: forbid-focus-container: true diff --git a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_len.yml b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_len.yml index db9e0a285d7f..e964619832c3 100644 --- a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_len.yml +++ b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_len.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: ginkgolinter: suppress-len-assertion: true diff --git a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_nil.yml b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_nil.yml index d15ab8c3edd7..53512a80e020 100644 --- a/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_nil.yml +++ b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_nil.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: ginkgolinter: suppress-nil-assertion: true diff --git a/pkg/golinters/gochecksumtype/testdata/gochecksumtype_custom.yml b/pkg/golinters/gochecksumtype/testdata/gochecksumtype_custom.yml index 361ba1f94dfa..ae9e64cba14c 100644 --- a/pkg/golinters/gochecksumtype/testdata/gochecksumtype_custom.yml +++ b/pkg/golinters/gochecksumtype/testdata/gochecksumtype_custom.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: gochecksumtype: default-signifies-exhaustive: false diff --git a/pkg/golinters/gocognit/testdata/gocognit.yml b/pkg/golinters/gocognit/testdata/gocognit.yml index 451443caf1a6..9970f3b8c493 100644 --- a/pkg/golinters/gocognit/testdata/gocognit.yml +++ b/pkg/golinters/gocognit/testdata/gocognit.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: gocognit: min-complexity: 2 diff --git a/pkg/golinters/goconst/testdata/goconst_calls_enabled.yml b/pkg/golinters/goconst/testdata/goconst_calls_enabled.yml index 5d0d09585f7d..c9e54c7c519c 100644 --- a/pkg/golinters/goconst/testdata/goconst_calls_enabled.yml +++ b/pkg/golinters/goconst/testdata/goconst_calls_enabled.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: goconst: ignore-calls: false diff --git a/pkg/golinters/goconst/testdata/goconst_dont_ignore.yml b/pkg/golinters/goconst/testdata/goconst_dont_ignore.yml index fed6e5b28707..c2abf80ec968 100644 --- a/pkg/golinters/goconst/testdata/goconst_dont_ignore.yml +++ b/pkg/golinters/goconst/testdata/goconst_dont_ignore.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: goconst: ignore-tests: false diff --git a/pkg/golinters/goconst/testdata/goconst_ignore.yml b/pkg/golinters/goconst/testdata/goconst_ignore.yml index f0fd0c242bae..bfb70d3a9cb7 100644 --- a/pkg/golinters/goconst/testdata/goconst_ignore.yml +++ b/pkg/golinters/goconst/testdata/goconst_ignore.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: goconst: ignore-tests: true diff --git a/pkg/golinters/gocritic/testdata/gocritic-fix.yml b/pkg/golinters/gocritic/testdata/gocritic-fix.yml index 17580b4dd82a..1e215c56ef3d 100644 --- a/pkg/golinters/gocritic/testdata/gocritic-fix.yml +++ b/pkg/golinters/gocritic/testdata/gocritic-fix.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: gocritic: enabled-checks: diff --git a/pkg/golinters/gocritic/testdata/gocritic.yml b/pkg/golinters/gocritic/testdata/gocritic.yml index f5b7d147bb2a..7e03addb25f3 100644 --- a/pkg/golinters/gocritic/testdata/gocritic.yml +++ b/pkg/golinters/gocritic/testdata/gocritic.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: gocritic: disabled-checks: diff --git a/pkg/golinters/gocritic/testdata/gocritic_configDir.yml b/pkg/golinters/gocritic/testdata/gocritic_configDir.yml index 0c5336b6b37a..a4088504943b 100644 --- a/pkg/golinters/gocritic/testdata/gocritic_configDir.yml +++ b/pkg/golinters/gocritic/testdata/gocritic_configDir.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: gocritic: disabled-checks: diff --git a/pkg/golinters/gocyclo/testdata/gocyclo.yml b/pkg/golinters/gocyclo/testdata/gocyclo.yml index c42672fae94d..03de091856d5 100644 --- a/pkg/golinters/gocyclo/testdata/gocyclo.yml +++ b/pkg/golinters/gocyclo/testdata/gocyclo.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: gocyclo: min-complexity: 20 diff --git a/pkg/golinters/godox/testdata/godox.yml b/pkg/golinters/godox/testdata/godox.yml index d9bd4d44f6d2..2c49ffca2d7c 100644 --- a/pkg/golinters/godox/testdata/godox.yml +++ b/pkg/golinters/godox/testdata/godox.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: godox: keywords: diff --git a/pkg/golinters/gofmt/testdata/gofmt_no_simplify.yml b/pkg/golinters/gofmt/testdata/gofmt_no_simplify.yml index ceeaa00f9946..db4681a05d5f 100644 --- a/pkg/golinters/gofmt/testdata/gofmt_no_simplify.yml +++ b/pkg/golinters/gofmt/testdata/gofmt_no_simplify.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: gofmt: simplify: false diff --git a/pkg/golinters/gofmt/testdata/gofmt_rewrite_rules.yml b/pkg/golinters/gofmt/testdata/gofmt_rewrite_rules.yml index 7501927b3f9d..6ec30e153347 100644 --- a/pkg/golinters/gofmt/testdata/gofmt_rewrite_rules.yml +++ b/pkg/golinters/gofmt/testdata/gofmt_rewrite_rules.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: gofmt: rewrite-rules: diff --git a/pkg/golinters/gofumpt/testdata/gofumpt-fix.yml b/pkg/golinters/gofumpt/testdata/gofumpt-fix.yml index 921da9f4c15c..79d89c916f40 100644 --- a/pkg/golinters/gofumpt/testdata/gofumpt-fix.yml +++ b/pkg/golinters/gofumpt/testdata/gofumpt-fix.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: gofumpt: extra-rules: true diff --git a/pkg/golinters/gofumpt/testdata/gofumpt_with_extra.yml b/pkg/golinters/gofumpt/testdata/gofumpt_with_extra.yml index 921da9f4c15c..79d89c916f40 100644 --- a/pkg/golinters/gofumpt/testdata/gofumpt_with_extra.yml +++ b/pkg/golinters/gofumpt/testdata/gofumpt_with_extra.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: gofumpt: extra-rules: true diff --git a/pkg/golinters/goheader/testdata/goheader-fix.yml b/pkg/golinters/goheader/testdata/goheader-fix.yml index fa1371e3b1ee..f8b45f374772 100644 --- a/pkg/golinters/goheader/testdata/goheader-fix.yml +++ b/pkg/golinters/goheader/testdata/goheader-fix.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: goheader: values: diff --git a/pkg/golinters/goheader/testdata/goheader.yml b/pkg/golinters/goheader/testdata/goheader.yml index c20ed76c196f..2977c2b80ae4 100644 --- a/pkg/golinters/goheader/testdata/goheader.yml +++ b/pkg/golinters/goheader/testdata/goheader.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: goheader: template: MY {{title}} diff --git a/pkg/golinters/goimports/testdata/goimports_local.yml b/pkg/golinters/goimports/testdata/goimports_local.yml index cb8c0edf99f8..ab960708b0a9 100644 --- a/pkg/golinters/goimports/testdata/goimports_local.yml +++ b/pkg/golinters/goimports/testdata/goimports_local.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: goimports: local-prefixes: github.com/golangci/golangci-lint diff --git a/pkg/golinters/gomodguard/testdata/gomodguard.yml b/pkg/golinters/gomodguard/testdata/gomodguard.yml index d193142cfc09..9857547d7e61 100644 --- a/pkg/golinters/gomodguard/testdata/gomodguard.yml +++ b/pkg/golinters/gomodguard/testdata/gomodguard.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: gomodguard: allowed: diff --git a/pkg/golinters/gosec/testdata/gosec.yml b/pkg/golinters/gosec/testdata/gosec.yml index 41ea1cea5a51..d7cab9ac3616 100644 --- a/pkg/golinters/gosec/testdata/gosec.yml +++ b/pkg/golinters/gosec/testdata/gosec.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: gosec: includes: diff --git a/pkg/golinters/gosec/testdata/gosec_global_option.yml b/pkg/golinters/gosec/testdata/gosec_global_option.yml index fc0c3e27ac6f..79cfb23d4c73 100644 --- a/pkg/golinters/gosec/testdata/gosec_global_option.yml +++ b/pkg/golinters/gosec/testdata/gosec_global_option.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: gosec: config: diff --git a/pkg/golinters/gosec/testdata/gosec_nosec.yml b/pkg/golinters/gosec/testdata/gosec_nosec.yml index 2c4c81fa66ec..0013ee999c2f 100644 --- a/pkg/golinters/gosec/testdata/gosec_nosec.yml +++ b/pkg/golinters/gosec/testdata/gosec_nosec.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: gosec: config: diff --git a/pkg/golinters/gosec/testdata/gosec_severity_confidence.yml b/pkg/golinters/gosec/testdata/gosec_severity_confidence.yml index b813870a17fe..11c6d3fb9311 100644 --- a/pkg/golinters/gosec/testdata/gosec_severity_confidence.yml +++ b/pkg/golinters/gosec/testdata/gosec_severity_confidence.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: gosec: severity: "medium" diff --git a/pkg/golinters/gosmopolitan/testdata/gosmopolitan_allow_time_local.yml b/pkg/golinters/gosmopolitan/testdata/gosmopolitan_allow_time_local.yml index 22c14053bbcf..bb8c0bd8878f 100644 --- a/pkg/golinters/gosmopolitan/testdata/gosmopolitan_allow_time_local.yml +++ b/pkg/golinters/gosmopolitan/testdata/gosmopolitan_allow_time_local.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: gosmopolitan: allow-time-local: true diff --git a/pkg/golinters/gosmopolitan/testdata/gosmopolitan_dont_ignore_tests.yml b/pkg/golinters/gosmopolitan/testdata/gosmopolitan_dont_ignore_tests.yml index 099296be3be0..26605e957b05 100644 --- a/pkg/golinters/gosmopolitan/testdata/gosmopolitan_dont_ignore_tests.yml +++ b/pkg/golinters/gosmopolitan/testdata/gosmopolitan_dont_ignore_tests.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: gosmopolitan: ignore-tests: false diff --git a/pkg/golinters/gosmopolitan/testdata/gosmopolitan_escape_hatches.yml b/pkg/golinters/gosmopolitan/testdata/gosmopolitan_escape_hatches.yml index 4783f84eb690..2c6c9bcb281a 100644 --- a/pkg/golinters/gosmopolitan/testdata/gosmopolitan_escape_hatches.yml +++ b/pkg/golinters/gosmopolitan/testdata/gosmopolitan_escape_hatches.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: gosmopolitan: escape-hatches: diff --git a/pkg/golinters/gosmopolitan/testdata/gosmopolitan_scripts.yml b/pkg/golinters/gosmopolitan/testdata/gosmopolitan_scripts.yml index 4d61bc18f355..6b16c2712c8f 100644 --- a/pkg/golinters/gosmopolitan/testdata/gosmopolitan_scripts.yml +++ b/pkg/golinters/gosmopolitan/testdata/gosmopolitan_scripts.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: gosmopolitan: watch-for-scripts: diff --git a/pkg/golinters/govet/testdata/govet.yml b/pkg/golinters/govet/testdata/govet.yml index 8a0d68da612c..89f9d7d0edc2 100644 --- a/pkg/golinters/govet/testdata/govet.yml +++ b/pkg/golinters/govet/testdata/govet.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: govet: enable: diff --git a/pkg/golinters/govet/testdata/govet_fieldalignment.yml b/pkg/golinters/govet/testdata/govet_fieldalignment.yml index 63afaabe2b55..070757844449 100644 --- a/pkg/golinters/govet/testdata/govet_fieldalignment.yml +++ b/pkg/golinters/govet/testdata/govet_fieldalignment.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: govet: enable: diff --git a/pkg/golinters/govet/testdata/govet_fix.yml b/pkg/golinters/govet/testdata/govet_fix.yml index 5fa5a09bb44a..903535aeba05 100644 --- a/pkg/golinters/govet/testdata/govet_fix.yml +++ b/pkg/golinters/govet/testdata/govet_fix.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: govet: enable: diff --git a/pkg/golinters/govet/testdata/govet_ifaceassert.yml b/pkg/golinters/govet/testdata/govet_ifaceassert.yml index 72c55574cf6a..28e5c7c9b3b1 100644 --- a/pkg/golinters/govet/testdata/govet_ifaceassert.yml +++ b/pkg/golinters/govet/testdata/govet_ifaceassert.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: govet: enable: diff --git a/pkg/golinters/grouper/testdata/grouper.yml b/pkg/golinters/grouper/testdata/grouper.yml index e31d6df7ad9a..d7312efc8165 100644 --- a/pkg/golinters/grouper/testdata/grouper.yml +++ b/pkg/golinters/grouper/testdata/grouper.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: grouper: import-require-grouping: true diff --git a/pkg/golinters/iface/testdata/iface_all.yml b/pkg/golinters/iface/testdata/iface_all.yml index e00cb8970659..69f306bd92d6 100644 --- a/pkg/golinters/iface/testdata/iface_all.yml +++ b/pkg/golinters/iface/testdata/iface_all.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: iface: enable: diff --git a/pkg/golinters/iface/testdata/iface_fix.yml b/pkg/golinters/iface/testdata/iface_fix.yml index 79cac8560e3b..889884281475 100644 --- a/pkg/golinters/iface/testdata/iface_fix.yml +++ b/pkg/golinters/iface/testdata/iface_fix.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: iface: enable: diff --git a/pkg/golinters/iface/testdata/iface_identical.yml b/pkg/golinters/iface/testdata/iface_identical.yml index c6117380d661..195a1f6baec8 100644 --- a/pkg/golinters/iface/testdata/iface_identical.yml +++ b/pkg/golinters/iface/testdata/iface_identical.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: iface: enable: diff --git a/pkg/golinters/iface/testdata/iface_opaque.yml b/pkg/golinters/iface/testdata/iface_opaque.yml index 71bd7047cab7..b9b66466d963 100644 --- a/pkg/golinters/iface/testdata/iface_opaque.yml +++ b/pkg/golinters/iface/testdata/iface_opaque.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: iface: enable: diff --git a/pkg/golinters/iface/testdata/iface_unused.yml b/pkg/golinters/iface/testdata/iface_unused.yml index a0511b3dd3bd..8f1a26cfa9cb 100644 --- a/pkg/golinters/iface/testdata/iface_unused.yml +++ b/pkg/golinters/iface/testdata/iface_unused.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: iface: enable: diff --git a/pkg/golinters/importas/testdata/importas.yml b/pkg/golinters/importas/testdata/importas.yml index b06608500f7a..f144ff021e67 100644 --- a/pkg/golinters/importas/testdata/importas.yml +++ b/pkg/golinters/importas/testdata/importas.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: importas: alias: diff --git a/pkg/golinters/importas/testdata/importas_several_empty_aliases.yml b/pkg/golinters/importas/testdata/importas_several_empty_aliases.yml index 1f6b9a77e7f4..9ff17d87bb18 100644 --- a/pkg/golinters/importas/testdata/importas_several_empty_aliases.yml +++ b/pkg/golinters/importas/testdata/importas_several_empty_aliases.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: importas: alias: diff --git a/pkg/golinters/importas/testdata/importas_strict.yml b/pkg/golinters/importas/testdata/importas_strict.yml index 0f780f265787..d670be71c212 100644 --- a/pkg/golinters/importas/testdata/importas_strict.yml +++ b/pkg/golinters/importas/testdata/importas_strict.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: importas: no-unaliased: true diff --git a/pkg/golinters/inamedparam/testdata/inamedparam_skip_single_param.yml b/pkg/golinters/inamedparam/testdata/inamedparam_skip_single_param.yml index 8d95bf8cfb61..ce8cf550432b 100644 --- a/pkg/golinters/inamedparam/testdata/inamedparam_skip_single_param.yml +++ b/pkg/golinters/inamedparam/testdata/inamedparam_skip_single_param.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: inamedparam: skip-single-param: true diff --git a/pkg/golinters/ireturn/testdata/ireturn_allow.yml b/pkg/golinters/ireturn/testdata/ireturn_allow.yml index 05459dd7af73..758e39559e79 100644 --- a/pkg/golinters/ireturn/testdata/ireturn_allow.yml +++ b/pkg/golinters/ireturn/testdata/ireturn_allow.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: ireturn: allow: diff --git a/pkg/golinters/ireturn/testdata/ireturn_reject_generics.yml b/pkg/golinters/ireturn/testdata/ireturn_reject_generics.yml index 90289d1306ae..5d737162ea93 100644 --- a/pkg/golinters/ireturn/testdata/ireturn_reject_generics.yml +++ b/pkg/golinters/ireturn/testdata/ireturn_reject_generics.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: ireturn: reject: diff --git a/pkg/golinters/ireturn/testdata/ireturn_reject_stdlib.yml b/pkg/golinters/ireturn/testdata/ireturn_reject_stdlib.yml index c5e687f7c3d4..7c3c5a253f80 100644 --- a/pkg/golinters/ireturn/testdata/ireturn_reject_stdlib.yml +++ b/pkg/golinters/ireturn/testdata/ireturn_reject_stdlib.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: ireturn: reject: diff --git a/pkg/golinters/lll/testdata/lll.yml b/pkg/golinters/lll/testdata/lll.yml index 2e2fde53e908..f6f38b73c856 100644 --- a/pkg/golinters/lll/testdata/lll.yml +++ b/pkg/golinters/lll/testdata/lll.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: lll: tab-width: 4 diff --git a/pkg/golinters/lll/testdata/lll_import.yml b/pkg/golinters/lll/testdata/lll_import.yml index e281e3d24513..a1db8c2d190c 100644 --- a/pkg/golinters/lll/testdata/lll_import.yml +++ b/pkg/golinters/lll/testdata/lll_import.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: lll: tab-width: 4 diff --git a/pkg/golinters/loggercheck/testdata/loggercheck_custom.yml b/pkg/golinters/loggercheck/testdata/loggercheck_custom.yml index 6cee97fda463..e9322f3901ef 100644 --- a/pkg/golinters/loggercheck/testdata/loggercheck_custom.yml +++ b/pkg/golinters/loggercheck/testdata/loggercheck_custom.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: loggercheck: rules: diff --git a/pkg/golinters/loggercheck/testdata/loggercheck_kitlogonly.yml b/pkg/golinters/loggercheck/testdata/loggercheck_kitlogonly.yml index 698895cf4349..bab187dec33f 100644 --- a/pkg/golinters/loggercheck/testdata/loggercheck_kitlogonly.yml +++ b/pkg/golinters/loggercheck/testdata/loggercheck_kitlogonly.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: loggercheck: kitlog: true diff --git a/pkg/golinters/loggercheck/testdata/loggercheck_logronly.yml b/pkg/golinters/loggercheck/testdata/loggercheck_logronly.yml index b7ac0ddf2bd1..49a3f6d3e09b 100644 --- a/pkg/golinters/loggercheck/testdata/loggercheck_logronly.yml +++ b/pkg/golinters/loggercheck/testdata/loggercheck_logronly.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: loggercheck: logr: true diff --git a/pkg/golinters/loggercheck/testdata/loggercheck_noprintflike.yml b/pkg/golinters/loggercheck/testdata/loggercheck_noprintflike.yml index 9ef9b44ac5e6..6b1e68a20b99 100644 --- a/pkg/golinters/loggercheck/testdata/loggercheck_noprintflike.yml +++ b/pkg/golinters/loggercheck/testdata/loggercheck_noprintflike.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: loggercheck: no-printf-like: true diff --git a/pkg/golinters/loggercheck/testdata/loggercheck_requirestringkey.yml b/pkg/golinters/loggercheck/testdata/loggercheck_requirestringkey.yml index 62e5d8f8885c..5496a1f0fc43 100644 --- a/pkg/golinters/loggercheck/testdata/loggercheck_requirestringkey.yml +++ b/pkg/golinters/loggercheck/testdata/loggercheck_requirestringkey.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: loggercheck: require-string-key: true diff --git a/pkg/golinters/loggercheck/testdata/loggercheck_slogonly.yml b/pkg/golinters/loggercheck/testdata/loggercheck_slogonly.yml index 32dcdcadb5fb..8b4a57f3884e 100644 --- a/pkg/golinters/loggercheck/testdata/loggercheck_slogonly.yml +++ b/pkg/golinters/loggercheck/testdata/loggercheck_slogonly.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: loggercheck: logr: false diff --git a/pkg/golinters/loggercheck/testdata/loggercheck_zaponly.yml b/pkg/golinters/loggercheck/testdata/loggercheck_zaponly.yml index b662ecafc667..bc9bae967731 100644 --- a/pkg/golinters/loggercheck/testdata/loggercheck_zaponly.yml +++ b/pkg/golinters/loggercheck/testdata/loggercheck_zaponly.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: loggercheck: logr: false diff --git a/pkg/golinters/maintidx/testdata/maintidx_under_100.yml b/pkg/golinters/maintidx/testdata/maintidx_under_100.yml index 8d54963412e7..7f9f811d55ed 100644 --- a/pkg/golinters/maintidx/testdata/maintidx_under_100.yml +++ b/pkg/golinters/maintidx/testdata/maintidx_under_100.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: maintidx: under: 100 diff --git a/pkg/golinters/makezero/testdata/makezero_always.yml b/pkg/golinters/makezero/testdata/makezero_always.yml index d7d1fa656cfb..13496e131b36 100644 --- a/pkg/golinters/makezero/testdata/makezero_always.yml +++ b/pkg/golinters/makezero/testdata/makezero_always.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: makezero: always: true diff --git a/pkg/golinters/misspell/testdata/misspell.yml b/pkg/golinters/misspell/testdata/misspell.yml index d115cba91b06..485487f2eef1 100644 --- a/pkg/golinters/misspell/testdata/misspell.yml +++ b/pkg/golinters/misspell/testdata/misspell.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: misspell: locale: US diff --git a/pkg/golinters/misspell/testdata/misspell_custom.yml b/pkg/golinters/misspell/testdata/misspell_custom.yml index c0f3a27cfddb..1d88b6cd10b4 100644 --- a/pkg/golinters/misspell/testdata/misspell_custom.yml +++ b/pkg/golinters/misspell/testdata/misspell_custom.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: misspell: extra-words: diff --git a/pkg/golinters/musttag/testdata/musttag.yml b/pkg/golinters/musttag/testdata/musttag.yml index 399e236bb57b..4d81b9b65eac 100644 --- a/pkg/golinters/musttag/testdata/musttag.yml +++ b/pkg/golinters/musttag/testdata/musttag.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: musttag: functions: diff --git a/pkg/golinters/nestif/testdata/nestif.yml b/pkg/golinters/nestif/testdata/nestif.yml index e6c4fb0cf58b..21eefe5886f5 100644 --- a/pkg/golinters/nestif/testdata/nestif.yml +++ b/pkg/golinters/nestif/testdata/nestif.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: nestif: min-complexity: 1 diff --git a/pkg/golinters/nilnil/testdata/nilnil_detect_opposite.yml b/pkg/golinters/nilnil/testdata/nilnil_detect_opposite.yml index 1c2d5ef724fb..229bd33a280c 100644 --- a/pkg/golinters/nilnil/testdata/nilnil_detect_opposite.yml +++ b/pkg/golinters/nilnil/testdata/nilnil_detect_opposite.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: nilnil: detect-opposite: true diff --git a/pkg/golinters/nilnil/testdata/nilnil_pointers_only.yml b/pkg/golinters/nilnil/testdata/nilnil_pointers_only.yml index 42d89b34b120..5d6d6d6711df 100644 --- a/pkg/golinters/nilnil/testdata/nilnil_pointers_only.yml +++ b/pkg/golinters/nilnil/testdata/nilnil_pointers_only.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: nilnil: checked-types: diff --git a/pkg/golinters/nlreturn/testdata/nlreturn-block-size.yml b/pkg/golinters/nlreturn/testdata/nlreturn-block-size.yml index edb719386f54..d19799538959 100644 --- a/pkg/golinters/nlreturn/testdata/nlreturn-block-size.yml +++ b/pkg/golinters/nlreturn/testdata/nlreturn-block-size.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: nlreturn: block-size: 2 diff --git a/pkg/golinters/nolintlint/testdata/nolintlint.yml b/pkg/golinters/nolintlint/testdata/nolintlint.yml index b0cc6ebd7ec4..de4cd8235666 100644 --- a/pkg/golinters/nolintlint/testdata/nolintlint.yml +++ b/pkg/golinters/nolintlint/testdata/nolintlint.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: nolintlint: require-explanation: true diff --git a/pkg/golinters/nolintlint/testdata/nolintlint_unused.yml b/pkg/golinters/nolintlint/testdata/nolintlint_unused.yml index b92160a83fda..38d98f01bc9e 100644 --- a/pkg/golinters/nolintlint/testdata/nolintlint_unused.yml +++ b/pkg/golinters/nolintlint/testdata/nolintlint_unused.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: nolintlint: allow-unused: false diff --git a/pkg/golinters/nonamedreturns/testdata/nonamedreturns_custom.yml b/pkg/golinters/nonamedreturns/testdata/nonamedreturns_custom.yml index 8976df8af9fa..5564244c4c69 100644 --- a/pkg/golinters/nonamedreturns/testdata/nonamedreturns_custom.yml +++ b/pkg/golinters/nonamedreturns/testdata/nonamedreturns_custom.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: nonamedreturns: report-error-in-defer: true diff --git a/pkg/golinters/paralleltest/testdata/paralleltest_custom.yml b/pkg/golinters/paralleltest/testdata/paralleltest_custom.yml index cf0ad75474c3..74231a5cd1c3 100644 --- a/pkg/golinters/paralleltest/testdata/paralleltest_custom.yml +++ b/pkg/golinters/paralleltest/testdata/paralleltest_custom.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: paralleltest: ignore-missing: true diff --git a/pkg/golinters/perfsprint/testdata/perfsprint_custom.yml b/pkg/golinters/perfsprint/testdata/perfsprint_custom.yml index f813f99ac2ce..315c868e104f 100644 --- a/pkg/golinters/perfsprint/testdata/perfsprint_custom.yml +++ b/pkg/golinters/perfsprint/testdata/perfsprint_custom.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: perfsprint: int-conversion: false diff --git a/pkg/golinters/predeclared/testdata/predeclared_custom.yml b/pkg/golinters/predeclared/testdata/predeclared_custom.yml index 227775858212..38f20dc3bb2b 100644 --- a/pkg/golinters/predeclared/testdata/predeclared_custom.yml +++ b/pkg/golinters/predeclared/testdata/predeclared_custom.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: predeclared: ignore: "real,recover" diff --git a/pkg/golinters/reassign/testdata/reassign_patterns.yml b/pkg/golinters/reassign/testdata/reassign_patterns.yml index 5af124dbd4f1..5c0641e15740 100644 --- a/pkg/golinters/reassign/testdata/reassign_patterns.yml +++ b/pkg/golinters/reassign/testdata/reassign_patterns.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: reassign: patterns: diff --git a/pkg/golinters/revive/testdata/revive-fix.yml b/pkg/golinters/revive/testdata/revive-fix.yml index 763b3a10e3b6..0bdce293d714 100644 --- a/pkg/golinters/revive/testdata/revive-fix.yml +++ b/pkg/golinters/revive/testdata/revive-fix.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: revive: ignore-generated-header: true diff --git a/pkg/golinters/revive/testdata/revive.yml b/pkg/golinters/revive/testdata/revive.yml index 5c0c60561db7..76abf43b7867 100644 --- a/pkg/golinters/revive/testdata/revive.yml +++ b/pkg/golinters/revive/testdata/revive.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: revive: ignore-generated-header: true diff --git a/pkg/golinters/sloglint/testdata/sloglint_args_on_sep_lines.yml b/pkg/golinters/sloglint/testdata/sloglint_args_on_sep_lines.yml index 6f544b0239ee..9a143a1ab83a 100644 --- a/pkg/golinters/sloglint/testdata/sloglint_args_on_sep_lines.yml +++ b/pkg/golinters/sloglint/testdata/sloglint_args_on_sep_lines.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: sloglint: args-on-sep-lines: true diff --git a/pkg/golinters/sloglint/testdata/sloglint_attr_only.yml b/pkg/golinters/sloglint/testdata/sloglint_attr_only.yml index a61f2ab4185a..fc36fff9ef14 100644 --- a/pkg/golinters/sloglint/testdata/sloglint_attr_only.yml +++ b/pkg/golinters/sloglint/testdata/sloglint_attr_only.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: sloglint: attr-only: true diff --git a/pkg/golinters/sloglint/testdata/sloglint_context_only.yml b/pkg/golinters/sloglint/testdata/sloglint_context_only.yml index 2b0703cef2ab..6ebe740d938b 100644 --- a/pkg/golinters/sloglint/testdata/sloglint_context_only.yml +++ b/pkg/golinters/sloglint/testdata/sloglint_context_only.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: sloglint: context: "all" diff --git a/pkg/golinters/sloglint/testdata/sloglint_forbidden_keys.yml b/pkg/golinters/sloglint/testdata/sloglint_forbidden_keys.yml index 2b0d969cd63c..e39c39c43f5e 100644 --- a/pkg/golinters/sloglint/testdata/sloglint_forbidden_keys.yml +++ b/pkg/golinters/sloglint/testdata/sloglint_forbidden_keys.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: sloglint: forbidden-keys: diff --git a/pkg/golinters/sloglint/testdata/sloglint_key_naming_case.yml b/pkg/golinters/sloglint/testdata/sloglint_key_naming_case.yml index 653d8c0b480d..b53f3e7e0339 100644 --- a/pkg/golinters/sloglint/testdata/sloglint_key_naming_case.yml +++ b/pkg/golinters/sloglint/testdata/sloglint_key_naming_case.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: sloglint: key-naming-case: snake diff --git a/pkg/golinters/sloglint/testdata/sloglint_kv_only.yml b/pkg/golinters/sloglint/testdata/sloglint_kv_only.yml index b482546c64db..823539eb4f3a 100644 --- a/pkg/golinters/sloglint/testdata/sloglint_kv_only.yml +++ b/pkg/golinters/sloglint/testdata/sloglint_kv_only.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: sloglint: kv-only: true diff --git a/pkg/golinters/sloglint/testdata/sloglint_no_raw_keys.yml b/pkg/golinters/sloglint/testdata/sloglint_no_raw_keys.yml index 57db6dbaaff6..5a2e11328975 100644 --- a/pkg/golinters/sloglint/testdata/sloglint_no_raw_keys.yml +++ b/pkg/golinters/sloglint/testdata/sloglint_no_raw_keys.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: sloglint: no-raw-keys: true diff --git a/pkg/golinters/sloglint/testdata/sloglint_static_msg.yml b/pkg/golinters/sloglint/testdata/sloglint_static_msg.yml index e4898e97839b..8694822c69e7 100644 --- a/pkg/golinters/sloglint/testdata/sloglint_static_msg.yml +++ b/pkg/golinters/sloglint/testdata/sloglint_static_msg.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: sloglint: static-msg: true diff --git a/pkg/golinters/spancheck/testdata/spancheck_enable_all.yml b/pkg/golinters/spancheck/testdata/spancheck_enable_all.yml index 1ea3518098bb..ef90b1c54412 100644 --- a/pkg/golinters/spancheck/testdata/spancheck_enable_all.yml +++ b/pkg/golinters/spancheck/testdata/spancheck_enable_all.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: spancheck: checks: diff --git a/pkg/golinters/spancheck/testdata/spancheck_keep_default.yml b/pkg/golinters/spancheck/testdata/spancheck_keep_default.yml index 3197c7b5ff77..f10152005942 100644 --- a/pkg/golinters/spancheck/testdata/spancheck_keep_default.yml +++ b/pkg/golinters/spancheck/testdata/spancheck_keep_default.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: spancheck: extra-start-span-signatures: diff --git a/pkg/golinters/tagalign/testdata/tagalign_align_only.yml b/pkg/golinters/tagalign/testdata/tagalign_align_only.yml index 0895a58fb19e..6f989840df48 100644 --- a/pkg/golinters/tagalign/testdata/tagalign_align_only.yml +++ b/pkg/golinters/tagalign/testdata/tagalign_align_only.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: tagalign: sort: false diff --git a/pkg/golinters/tagalign/testdata/tagalign_order_only.yml b/pkg/golinters/tagalign/testdata/tagalign_order_only.yml index 4ea9664e05b7..9943e1bead9f 100644 --- a/pkg/golinters/tagalign/testdata/tagalign_order_only.yml +++ b/pkg/golinters/tagalign/testdata/tagalign_order_only.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: tagalign: align: false diff --git a/pkg/golinters/tagalign/testdata/tagalign_sort_only.yml b/pkg/golinters/tagalign/testdata/tagalign_sort_only.yml index 19e6444365c9..b77c94478097 100644 --- a/pkg/golinters/tagalign/testdata/tagalign_sort_only.yml +++ b/pkg/golinters/tagalign/testdata/tagalign_sort_only.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: tagalign: align: false diff --git a/pkg/golinters/tagalign/testdata/tagalign_strict.yml b/pkg/golinters/tagalign/testdata/tagalign_strict.yml index 84a0dd88c387..a1383326e8a7 100644 --- a/pkg/golinters/tagalign/testdata/tagalign_strict.yml +++ b/pkg/golinters/tagalign/testdata/tagalign_strict.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: tagalign: align: true diff --git a/pkg/golinters/tagliatelle/testdata/tagliatelle_ignored_fields.yml b/pkg/golinters/tagliatelle/testdata/tagliatelle_ignored_fields.yml index b80a481674fc..a907484250af 100644 --- a/pkg/golinters/tagliatelle/testdata/tagliatelle_ignored_fields.yml +++ b/pkg/golinters/tagliatelle/testdata/tagliatelle_ignored_fields.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: tagliatelle: case: diff --git a/pkg/golinters/tenv/testdata/tenv_all.yml b/pkg/golinters/tenv/testdata/tenv_all.yml index f0ae4fd226c4..a3a0de572ec7 100644 --- a/pkg/golinters/tenv/testdata/tenv_all.yml +++ b/pkg/golinters/tenv/testdata/tenv_all.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: tenv: all: true diff --git a/pkg/golinters/testifylint/testdata/testifylint_bool_compare_only.yml b/pkg/golinters/testifylint/testdata/testifylint_bool_compare_only.yml index cba8f1029490..cddaa30b1edd 100644 --- a/pkg/golinters/testifylint/testdata/testifylint_bool_compare_only.yml +++ b/pkg/golinters/testifylint/testdata/testifylint_bool_compare_only.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: testifylint: disable-all: true diff --git a/pkg/golinters/testifylint/testdata/testifylint_formatter_only.yml b/pkg/golinters/testifylint/testdata/testifylint_formatter_only.yml index 185fc39daedb..aca8ffaad304 100644 --- a/pkg/golinters/testifylint/testdata/testifylint_formatter_only.yml +++ b/pkg/golinters/testifylint/testdata/testifylint_formatter_only.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: testifylint: disable-all: true diff --git a/pkg/golinters/testifylint/testdata/testifylint_require_error_only.yml b/pkg/golinters/testifylint/testdata/testifylint_require_error_only.yml index 49a92d7ff6bf..4ddf2b235745 100644 --- a/pkg/golinters/testifylint/testdata/testifylint_require_error_only.yml +++ b/pkg/golinters/testifylint/testdata/testifylint_require_error_only.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: testifylint: disable-all: true diff --git a/pkg/golinters/thelper/testdata/thelper.yml b/pkg/golinters/thelper/testdata/thelper.yml index eaa8f403b206..6eeeb531596a 100644 --- a/pkg/golinters/thelper/testdata/thelper.yml +++ b/pkg/golinters/thelper/testdata/thelper.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: thelper: test: diff --git a/pkg/golinters/usestdlibvars/testdata/usestdlibvars_non_default.yml b/pkg/golinters/usestdlibvars/testdata/usestdlibvars_non_default.yml index f50ce6fc341e..269bb85fb367 100644 --- a/pkg/golinters/usestdlibvars/testdata/usestdlibvars_non_default.yml +++ b/pkg/golinters/usestdlibvars/testdata/usestdlibvars_non_default.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: usestdlibvars: http-method: false diff --git a/pkg/golinters/usetesting/testdata/usetesting_configuration.yml b/pkg/golinters/usetesting/testdata/usetesting_configuration.yml index fc877dd17f20..c100e213fa57 100644 --- a/pkg/golinters/usetesting/testdata/usetesting_configuration.yml +++ b/pkg/golinters/usetesting/testdata/usetesting_configuration.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: usetesting: os-create-temp: false diff --git a/pkg/golinters/usetesting/testdata/usetesting_go124_configuration.yml b/pkg/golinters/usetesting/testdata/usetesting_go124_configuration.yml index fc877dd17f20..c100e213fa57 100644 --- a/pkg/golinters/usetesting/testdata/usetesting_go124_configuration.yml +++ b/pkg/golinters/usetesting/testdata/usetesting_go124_configuration.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: usetesting: os-create-temp: false diff --git a/pkg/golinters/whitespace/testdata/whitespace-fix.yml b/pkg/golinters/whitespace/testdata/whitespace-fix.yml index dad470cee82d..2f047ff46988 100644 --- a/pkg/golinters/whitespace/testdata/whitespace-fix.yml +++ b/pkg/golinters/whitespace/testdata/whitespace-fix.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: whitespace: multi-if: true diff --git a/pkg/golinters/whitespace/testdata/whitespace.yml b/pkg/golinters/whitespace/testdata/whitespace.yml index dad470cee82d..2f047ff46988 100644 --- a/pkg/golinters/whitespace/testdata/whitespace.yml +++ b/pkg/golinters/whitespace/testdata/whitespace.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: whitespace: multi-if: true diff --git a/pkg/golinters/wsl/testdata/wsl.yml b/pkg/golinters/wsl/testdata/wsl.yml index 4197633eef95..2afb1c3f9c6c 100644 --- a/pkg/golinters/wsl/testdata/wsl.yml +++ b/pkg/golinters/wsl/testdata/wsl.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: wsl: allow-cuddle-declarations: false diff --git a/test/testdata/configs/default_exclude.yml b/test/testdata/configs/default_exclude.yml index 8c8699ee8e4c..9abbdb17985f 100644 --- a/test/testdata/configs/default_exclude.yml +++ b/test/testdata/configs/default_exclude.yml @@ -1,3 +1,5 @@ +version: "2" + issues: include: - - EXC0011 # include issues about comments from `stylecheck` \ No newline at end of file + - EXC0011 # include issues about comments from `stylecheck` diff --git a/test/testdata/configs/multiple-issues-fix.yml b/test/testdata/configs/multiple-issues-fix.yml index 451973c5a144..a60a68235687 100644 --- a/test/testdata/configs/multiple-issues-fix.yml +++ b/test/testdata/configs/multiple-issues-fix.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: gofumpt: extra-rules: true diff --git a/test/testdata/configs/output.yml b/test/testdata/configs/output.yml index d115cba91b06..485487f2eef1 100644 --- a/test/testdata/configs/output.yml +++ b/test/testdata/configs/output.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: misspell: locale: US diff --git a/test/testdata/configs/path-except.yml b/test/testdata/configs/path-except.yml index 712bbd5a6013..3f2261a241b0 100644 --- a/test/testdata/configs/path-except.yml +++ b/test/testdata/configs/path-except.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: forbidigo: forbid: diff --git a/test/testdata/linedirective/dupl.yml b/test/testdata/linedirective/dupl.yml index a4211c11c178..2091e83d5305 100644 --- a/test/testdata/linedirective/dupl.yml +++ b/test/testdata/linedirective/dupl.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: dupl: threshold: 10 diff --git a/test/testdata/linedirective/gomodguard.yml b/test/testdata/linedirective/gomodguard.yml index e6f4125ba952..9575bad2b1a0 100644 --- a/test/testdata/linedirective/gomodguard.yml +++ b/test/testdata/linedirective/gomodguard.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: gomodguard: allowed: diff --git a/test/testdata/linedirective/lll.yml b/test/testdata/linedirective/lll.yml index 0080469ba38c..435a556d06d0 100644 --- a/test/testdata/linedirective/lll.yml +++ b/test/testdata/linedirective/lll.yml @@ -1,3 +1,5 @@ +version: "2" + linters-settings: lll: line-length: 50 diff --git a/test/testdata_etc/unused_exported/golangci.yml b/test/testdata_etc/unused_exported/golangci.yml index 3370faa28f34..9e59f4dc832c 100644 --- a/test/testdata_etc/unused_exported/golangci.yml +++ b/test/testdata_etc/unused_exported/golangci.yml @@ -1,3 +1,5 @@ +version: "2" + linters: disable-all: true enable: From 410334dfd410a3645c1bb440dd9d3f8d77732d48 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Wed, 19 Feb 2025 13:35:11 +0100 Subject: [PATCH 07/13] review --- .golangci.next.reference.yml | 3 +-- docs/src/docs/index.mdx | 5 ++--- pkg/commands/flagsets.go | 2 +- pkg/config/output_formats.go | 38 ++++++++++++++++++------------------ pkg/printers/printer.go | 8 ++++---- pkg/printers/printer_test.go | 12 ++++++------ pkg/printers/tab.go | 6 +++--- pkg/printers/tab_test.go | 4 ++-- pkg/printers/text.go | 6 +++--- pkg/printers/text_test.go | 2 +- 10 files changed, 42 insertions(+), 44 deletions(-) diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index ff6192a7521c..c23f991f1bb8 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -4079,11 +4079,10 @@ issues: fix: true -# output configuration options +# Output configuration options. output: # The formats used to render issues. formats: - # (line-number) text: # Output path can be either `stdout`, `stderr` or path to the file to write to. # Default: stdout diff --git a/docs/src/docs/index.mdx b/docs/src/docs/index.mdx index e6ae9032cf6a..8037b04e36bf 100644 --- a/docs/src/docs/index.mdx +++ b/docs/src/docs/index.mdx @@ -2,8 +2,7 @@ title: Introduction --- -import { FaSlack } from "react-icons/fa"; -import { IconContainer } from "lib/icons"; + [![License](https://img.shields.io/github/license/golangci/golangci-lint)](https://github.com/golangci/golangci-lint/blob/HEAD/LICENSE) [![Release](https://img.shields.io/github/release/golangci/golangci-lint.svg)](https://github.com/golangci/golangci-lint/releases/latest) @@ -30,7 +29,7 @@ Follow the news and releases: - 🖥 [Integrations](/welcome/integrations) with VS Code, Sublime Text, GoLand, GNU Emacs, Vim, GitHub Actions. - 🥇 [A lot of linters](/usage/linters) included, no need to install them. - 📈 Minimum number of [false positives](/usage/false-positives) because of tuned default settings. -- 🔥 Nice output with colors, source code lines (Text, JSON, Tab, HTML, Checkstyle, Code-Climate, JUnit-XML, Teamcity, SARIF). +- 🔥 Nice output with colors and source code lines: text, JSON, tab, HTML, Checkstyle, Code-Climate, JUnit-XML, TeamCity, SARIF. [Get started now!](/welcome/install) diff --git a/pkg/commands/flagsets.go b/pkg/commands/flagsets.go index c2767f7aad66..11459353fe61 100644 --- a/pkg/commands/flagsets.go +++ b/pkg/commands/flagsets.go @@ -118,7 +118,7 @@ func setupOutputFormatsFlagSet(v *viper.Viper, fs *pflag.FlagSet) { internal.AddFlagAndBind(v, fs, fs.String, "output.junit-xml.path", "output.formats.junit-xml.path", "", color.GreenString(outputPathDesc)) - internal.AddFlagAndBind(v, fs, fs.Bool, "output.junit-xml.extended", "output.formats.junit-xml.extended", true, + internal.AddFlagAndBind(v, fs, fs.Bool, "output.junit-xml.extended", "output.formats.junit-xml.extended", false, color.GreenString("Support extra JUnit XML fields.")) internal.AddFlagAndBind(v, fs, fs.String, "output.teamcity.path", "output.formats.teamcity.path", "", diff --git a/pkg/config/output_formats.go b/pkg/config/output_formats.go index 26b2a0dec7c4..fd4fc30b135c 100644 --- a/pkg/config/output_formats.go +++ b/pkg/config/output_formats.go @@ -1,26 +1,26 @@ package config type Formats struct { - Text Text `mapstructure:"text"` - JSON SimpleStyle `mapstructure:"json"` - Tab Tab `mapstructure:"tab"` - HTML SimpleStyle `mapstructure:"html"` - Checkstyle SimpleStyle `mapstructure:"checkstyle"` - CodeClimate SimpleStyle `mapstructure:"code-climate"` - JUnitXML JUnitXML `mapstructure:"junit-xml"` - TeamCity SimpleStyle `mapstructure:"team-city"` - Sarif SimpleStyle `mapstructure:"sarif"` + Text Text `mapstructure:"text"` + JSON SimpleFormat `mapstructure:"json"` + Tab Tab `mapstructure:"tab"` + HTML SimpleFormat `mapstructure:"html"` + Checkstyle SimpleFormat `mapstructure:"checkstyle"` + CodeClimate SimpleFormat `mapstructure:"code-climate"` + JUnitXML JUnitXML `mapstructure:"junit-xml"` + TeamCity SimpleFormat `mapstructure:"teamcity"` + Sarif SimpleFormat `mapstructure:"sarif"` } func (f *Formats) IsEmpty() bool { - styles := []SimpleStyle{ - f.Text.SimpleStyle, + styles := []SimpleFormat{ + f.Text.SimpleFormat, f.JSON, - f.Tab.SimpleStyle, + f.Tab.SimpleFormat, f.HTML, f.Checkstyle, f.CodeClimate, - f.JUnitXML.SimpleStyle, + f.JUnitXML.SimpleFormat, f.TeamCity, f.Sarif, } @@ -34,24 +34,24 @@ func (f *Formats) IsEmpty() bool { return true } -type SimpleStyle struct { +type SimpleFormat struct { Path string `mapstructure:"path"` } type Text struct { - SimpleStyle `mapstructure:",squash"` + SimpleFormat `mapstructure:",squash"` PrintLinterName bool `mapstructure:"print-linter-name"` PrintIssuedLine bool `mapstructure:"print-issued-lines"` Colors bool `mapstructure:"colors"` } type Tab struct { - SimpleStyle `mapstructure:",squash"` + SimpleFormat `mapstructure:",squash"` PrintLinterName bool `mapstructure:"print-linter-name"` - UseColors bool `mapstructure:"use-colors"` + Colors bool `mapstructure:"colors"` } type JUnitXML struct { - SimpleStyle `mapstructure:",squash"` - Extended bool `mapstructure:"extended"` + SimpleFormat `mapstructure:",squash"` + Extended bool `mapstructure:"extended"` } diff --git a/pkg/printers/printer.go b/pkg/printers/printer.go index 90fa3dc6e32c..f50380f761a9 100644 --- a/pkg/printers/printer.go +++ b/pkg/printers/printer.go @@ -65,13 +65,13 @@ func NewPrinter(log logutils.Log, cfg *config.Formats, reportData *report.Data, //nolint:gocyclo,funlen // the complexity is related to the number of formats. func (c *Printer) Print(issues []result.Issue) error { if c.cfg.IsEmpty() { - c.cfg.Text.SimpleStyle.Path = outputStdOut + c.cfg.Text.SimpleFormat.Path = outputStdOut } var printers []issuePrinter if c.cfg.Text.Path != "" { - w, closer, err := c.createWriter(&c.cfg.Text.SimpleStyle) + w, closer, err := c.createWriter(&c.cfg.Text.SimpleFormat) if err != nil { return fmt.Errorf("can't create output for %s: %w", c.cfg.Text.Path, err) } @@ -137,7 +137,7 @@ func (c *Printer) Print(issues []result.Issue) error { } if c.cfg.JUnitXML.Path != "" { - w, closer, err := c.createWriter(&c.cfg.JUnitXML.SimpleStyle) + w, closer, err := c.createWriter(&c.cfg.JUnitXML.SimpleFormat) if err != nil { return fmt.Errorf("can't create output for %s: %w", c.cfg.JUnitXML.Path, err) } @@ -179,7 +179,7 @@ func (c *Printer) Print(issues []result.Issue) error { return nil } -func (c *Printer) createWriter(cfg *config.SimpleStyle) (io.Writer, func(), error) { +func (c *Printer) createWriter(cfg *config.SimpleFormat) (io.Writer, func(), error) { if cfg.Path == "" || cfg.Path == outputStdOut { return c.stdOut, func() {}, nil } diff --git a/pkg/printers/printer_test.go b/pkg/printers/printer_test.go index e52bdb94266f..c74ad057a684 100644 --- a/pkg/printers/printer_test.go +++ b/pkg/printers/printer_test.go @@ -49,7 +49,7 @@ func TestPrinter_Print_stdout(t *testing.T) { desc: "stdout (explicit)", cfg: &config.Formats{ Text: config.Text{ - SimpleStyle: config.SimpleStyle{ + SimpleFormat: config.SimpleFormat{ Path: "stdout", }, }, @@ -94,7 +94,7 @@ func TestPrinter_Print_stderr(t *testing.T) { cfg := &config.Formats{ Text: config.Text{ - SimpleStyle: config.SimpleStyle{ + SimpleFormat: config.SimpleFormat{ Path: "stderr", }, }, @@ -132,7 +132,7 @@ func TestPrinter_Print_file(t *testing.T) { cfg := &config.Formats{ Text: config.Text{ - SimpleStyle: config.SimpleStyle{ + SimpleFormat: config.SimpleFormat{ Path: outputPath, }, }, @@ -174,14 +174,14 @@ func TestPrinter_Print_multiple(t *testing.T) { outputPath := filepath.Join(t.TempDir(), "teamcity.txt") cfg := &config.Formats{ - TeamCity: config.SimpleStyle{ + TeamCity: config.SimpleFormat{ Path: outputPath, }, - JSON: config.SimpleStyle{ + JSON: config.SimpleFormat{ Path: "stdout", }, Text: config.Text{ - SimpleStyle: config.SimpleStyle{ + SimpleFormat: config.SimpleFormat{ Path: "stderr", }, }, diff --git a/pkg/printers/tab.go b/pkg/printers/tab.go index b027412b07c8..35e0c703fd12 100644 --- a/pkg/printers/tab.go +++ b/pkg/printers/tab.go @@ -15,7 +15,7 @@ import ( // Tab prints issues using tabulation as a field separator. type Tab struct { printLinterName bool - useColors bool + colors bool log logutils.Log w io.Writer @@ -24,7 +24,7 @@ type Tab struct { func NewTab(log logutils.Log, w io.Writer, cfg *config.Tab) *Tab { return &Tab{ printLinterName: cfg.PrintLinterName, - useColors: cfg.UseColors, + colors: cfg.Colors, log: log.Child(logutils.DebugKeyTabPrinter), w: w, } @@ -33,7 +33,7 @@ func NewTab(log logutils.Log, w io.Writer, cfg *config.Tab) *Tab { func (p *Tab) SprintfColored(ca color.Attribute, format string, args ...any) string { c := color.New(ca) - if !p.useColors { + if !p.colors { c.DisableColor() } diff --git a/pkg/printers/tab_test.go b/pkg/printers/tab_test.go index 99b0e4f6886e..464f75b3c810 100644 --- a/pkg/printers/tab_test.go +++ b/pkg/printers/tab_test.go @@ -89,9 +89,9 @@ path/to/fileb.go:300:9 another issue buf := new(bytes.Buffer) printer := NewTab(logutils.NewStderrLog(logutils.DebugKeyEmpty), buf, &config.Tab{ - SimpleStyle: config.SimpleStyle{}, + SimpleFormat: config.SimpleFormat{}, PrintLinterName: test.printLinterName, - UseColors: test.useColors, + Colors: test.useColors, }) err := printer.Print(issues) diff --git a/pkg/printers/text.go b/pkg/printers/text.go index 9be9a1dc5947..678311ad085c 100644 --- a/pkg/printers/text.go +++ b/pkg/printers/text.go @@ -16,7 +16,7 @@ import ( type Text struct { printLinterName bool printIssuedLine bool - useColors bool + colors bool log logutils.Log w io.Writer @@ -26,7 +26,7 @@ func NewText(log logutils.Log, w io.Writer, cfg *config.Text) *Text { return &Text{ printLinterName: cfg.PrintLinterName, printIssuedLine: cfg.PrintIssuedLine, - useColors: cfg.Colors, + colors: cfg.Colors, log: log.Child(logutils.DebugKeyTextPrinter), w: w, } @@ -35,7 +35,7 @@ func NewText(log logutils.Log, w io.Writer, cfg *config.Text) *Text { func (p *Text) SprintfColored(ca color.Attribute, format string, args ...any) string { c := color.New(ca) - if !p.useColors { + if !p.colors { c.DisableColor() } diff --git a/pkg/printers/text_test.go b/pkg/printers/text_test.go index 49d212f1e639..474deb256931 100644 --- a/pkg/printers/text_test.go +++ b/pkg/printers/text_test.go @@ -117,7 +117,7 @@ path/to/fileb.go:300:9: another issue buf := new(bytes.Buffer) printer := NewText(logutils.NewStderrLog(logutils.DebugKeyEmpty), buf, &config.Text{ - SimpleStyle: config.SimpleStyle{}, + SimpleFormat: config.SimpleFormat{}, PrintLinterName: test.printLinterName, PrintIssuedLine: test.printIssuedLine, Colors: test.useColors, From ce9d39e7ff488906c89efcaed9c7d6ff36caef26 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Wed, 19 Feb 2025 13:38:10 +0100 Subject: [PATCH 08/13] review --- pkg/printers/printer.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/printers/printer.go b/pkg/printers/printer.go index f50380f761a9..314ffb361e0d 100644 --- a/pkg/printers/printer.go +++ b/pkg/printers/printer.go @@ -93,9 +93,9 @@ func (c *Printer) Print(issues []result.Issue) error { } if c.cfg.Tab.Path != "" { - w, closer, err := c.createWriter(&c.cfg.Sarif) + w, closer, err := c.createWriter(&c.cfg.Tab.SimpleFormat) if err != nil { - return fmt.Errorf("can't create output for %s: %w", c.cfg.Sarif.Path, err) + return fmt.Errorf("can't create output for %s: %w", c.cfg.Tab.Path, err) } defer closer() From efdbd12ce6af75c3bb6c00016a41e2f535b90625 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Wed, 19 Feb 2025 13:44:46 +0100 Subject: [PATCH 09/13] review --- .golangci.next.reference.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index c23f991f1bb8..8ecd29fe197b 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -4083,6 +4083,8 @@ issues: output: # The formats used to render issues. formats: + # Reports issues in a text format with colors, line number, and linter name. + # This format is the default format. text: # Output path can be either `stdout`, `stderr` or path to the file to write to. # Default: stdout @@ -4096,10 +4098,12 @@ output: # Use colors. # Default: true colors: false + # Reports issues in a JSON format. json: # Output path can be either `stdout`, `stderr` or path to the file to write to. # Default: stdout path: ./path/to/output.json + # Reports issues in columns separated by tabulations. tab: # Output path can be either `stdout`, `stderr` or path to the file to write to. # Default: stdout @@ -4110,18 +4114,22 @@ output: # Use colors. # Default: true colors: false + # Reports issues in an HTML format. html: # Output path can be either `stdout`, `stderr` or path to the file to write to. # Default: stdout path: ./path/to/output.html + # Reports issues in a Checkstyle format. checkstyle: # Output path can be either `stdout`, `stderr` or path to the file to write to. # Default: stdout path: ./path/to/output.xml + # Reports issues in a Code Climate format. code-climate: # Output path can be either `stdout`, `stderr` or path to the file to write to. # Default: stdout path: ./path/to/output.json + # Reports issues in a JUnit XML format. junit-xml: # Output path can be either `stdout`, `stderr` or path to the file to write to. # Default: stdout @@ -4129,10 +4137,12 @@ output: # Support extra JUnit XML fields. # Default: false extended: true + # Reports issues in a Teamcity format. teamcity: # Output path can be either `stdout`, `stderr` or path to the file to write to. # Default: stdout path: ./path/to/output.txt + # Reports issues in a SARIF format. sarif: # Output path can be either `stdout`, `stderr` or path to the file to write to. # Default: stdout From 75e025fe6c41cc01c4598ff7e28243c1d9b32318 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Wed, 19 Feb 2025 13:46:07 +0100 Subject: [PATCH 10/13] review --- docs/src/docs/index.mdx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/src/docs/index.mdx b/docs/src/docs/index.mdx index 8037b04e36bf..d0ccbcea0618 100644 --- a/docs/src/docs/index.mdx +++ b/docs/src/docs/index.mdx @@ -2,7 +2,8 @@ title: Introduction --- - +import { FaTwitter, FaSlack } from "react-icons/fa"; +import { IconContainer } from "lib/icons"; [![License](https://img.shields.io/github/license/golangci/golangci-lint)](https://github.com/golangci/golangci-lint/blob/HEAD/LICENSE) [![Release](https://img.shields.io/github/release/golangci/golangci-lint.svg)](https://github.com/golangci/golangci-lint/releases/latest) From ec621d546a14373b682317026c6f38f68a842270 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Wed, 19 Feb 2025 13:48:37 +0100 Subject: [PATCH 11/13] docs: improve --- docs/src/docs/index.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/src/docs/index.mdx b/docs/src/docs/index.mdx index d0ccbcea0618..30ab2c3ff70e 100644 --- a/docs/src/docs/index.mdx +++ b/docs/src/docs/index.mdx @@ -2,7 +2,7 @@ title: Introduction --- -import { FaTwitter, FaSlack } from "react-icons/fa"; +import { FaSlack } from "react-icons/fa"; import { IconContainer } from "lib/icons"; [![License](https://img.shields.io/github/license/golangci/golangci-lint)](https://github.com/golangci/golangci-lint/blob/HEAD/LICENSE) @@ -30,7 +30,7 @@ Follow the news and releases: - 🖥 [Integrations](/welcome/integrations) with VS Code, Sublime Text, GoLand, GNU Emacs, Vim, GitHub Actions. - 🥇 [A lot of linters](/usage/linters) included, no need to install them. - 📈 Minimum number of [false positives](/usage/false-positives) because of tuned default settings. -- 🔥 Nice output with colors and source code lines: text, JSON, tab, HTML, Checkstyle, Code-Climate, JUnit-XML, TeamCity, SARIF. +- 🔥 Nice outputs: text with colors and source code lines, JSON, tab, HTML, Checkstyle, Code-Climate, JUnit-XML, TeamCity, SARIF. [Get started now!](/welcome/install) From 76ad3db9bf5ba98ccb14bda0e64b15ea8d77842c Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Wed, 19 Feb 2025 13:58:00 +0100 Subject: [PATCH 12/13] docs: improve --- .golangci.next.reference.yml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index 8ecd29fe197b..4608c73a5c70 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -4083,7 +4083,7 @@ issues: output: # The formats used to render issues. formats: - # Reports issues in a text format with colors, line number, and linter name. + # Prints issues in a text format with colors, line number, and linter name. # This format is the default format. text: # Output path can be either `stdout`, `stderr` or path to the file to write to. @@ -4098,12 +4098,12 @@ output: # Use colors. # Default: true colors: false - # Reports issues in a JSON format. + # Prints issues in a JSON representation. json: # Output path can be either `stdout`, `stderr` or path to the file to write to. # Default: stdout path: ./path/to/output.json - # Reports issues in columns separated by tabulations. + # Prints issues in columns representation separated by tabulations. tab: # Output path can be either `stdout`, `stderr` or path to the file to write to. # Default: stdout @@ -4114,22 +4114,23 @@ output: # Use colors. # Default: true colors: false - # Reports issues in an HTML format. + # Prints issues in an HTML page. + # It uses the Cloudflare CDN (cdnjs) and React. html: # Output path can be either `stdout`, `stderr` or path to the file to write to. # Default: stdout path: ./path/to/output.html - # Reports issues in a Checkstyle format. + # Prints issues in the Checkstyle format. checkstyle: # Output path can be either `stdout`, `stderr` or path to the file to write to. # Default: stdout path: ./path/to/output.xml - # Reports issues in a Code Climate format. + # Prints issues in the Code Climate format. code-climate: # Output path can be either `stdout`, `stderr` or path to the file to write to. # Default: stdout path: ./path/to/output.json - # Reports issues in a JUnit XML format. + # Prints issues in the JUnit XML format. junit-xml: # Output path can be either `stdout`, `stderr` or path to the file to write to. # Default: stdout @@ -4137,12 +4138,12 @@ output: # Support extra JUnit XML fields. # Default: false extended: true - # Reports issues in a Teamcity format. + # Prints issues in the Teamcity format. teamcity: # Output path can be either `stdout`, `stderr` or path to the file to write to. # Default: stdout path: ./path/to/output.txt - # Reports issues in a SARIF format. + # Prints issues in the SARIF format. sarif: # Output path can be either `stdout`, `stderr` or path to the file to write to. # Default: stdout From f6d3b110751cc57b70ea2c7c1b499800bd06c7b2 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Wed, 19 Feb 2025 15:05:22 +0100 Subject: [PATCH 13/13] review --- .golangci.next.reference.yml | 6 +++--- pkg/config/output_formats.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index 4608c73a5c70..e52cb21a8e07 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -4088,7 +4088,7 @@ output: text: # Output path can be either `stdout`, `stderr` or path to the file to write to. # Default: stdout - path: ./path/to/report.txt + path: ./path/to/output.txt # Print linter name in the end of issue text. # Default: true print-linter-name: false @@ -4107,7 +4107,7 @@ output: tab: # Output path can be either `stdout`, `stderr` or path to the file to write to. # Default: stdout - path: stdout + path: ./path/to/output.txt # Print linter name in the end of issue text. # Default: true print-linter-name: true @@ -4138,7 +4138,7 @@ output: # Support extra JUnit XML fields. # Default: false extended: true - # Prints issues in the Teamcity format. + # Prints issues in the TeamCity format. teamcity: # Output path can be either `stdout`, `stderr` or path to the file to write to. # Default: stdout diff --git a/pkg/config/output_formats.go b/pkg/config/output_formats.go index fd4fc30b135c..1c655c1b00d5 100644 --- a/pkg/config/output_formats.go +++ b/pkg/config/output_formats.go @@ -13,7 +13,7 @@ type Formats struct { } func (f *Formats) IsEmpty() bool { - styles := []SimpleFormat{ + formats := []SimpleFormat{ f.Text.SimpleFormat, f.JSON, f.Tab.SimpleFormat, @@ -25,8 +25,8 @@ func (f *Formats) IsEmpty() bool { f.Sarif, } - for _, style := range styles { - if style.Path != "" { + for _, format := range formats { + if format.Path != "" { return false } }