Skip to content

Commit 410334d

Browse files
committed
review
1 parent 56f24e4 commit 410334d

File tree

10 files changed

+42
-44
lines changed

10 files changed

+42
-44
lines changed

.golangci.next.reference.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4079,11 +4079,10 @@ issues:
40794079
fix: true
40804080

40814081

4082-
# output configuration options
4082+
# Output configuration options.
40834083
output:
40844084
# The formats used to render issues.
40854085
formats:
4086-
# (line-number)
40874086
text:
40884087
# Output path can be either `stdout`, `stderr` or path to the file to write to.
40894088
# Default: stdout

docs/src/docs/index.mdx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
title: Introduction
33
---
44

5-
import { FaSlack } from "react-icons/fa";
6-
import { IconContainer } from "lib/icons";
5+
76

87
[![License](https://img.shields.io/github/license/golangci/golangci-lint)](https://github.com/golangci/golangci-lint/blob/HEAD/LICENSE)
98
[![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:
3029
- 🖥 [Integrations](/welcome/integrations) with VS Code, Sublime Text, GoLand, GNU Emacs, Vim, GitHub Actions.
3130
- 🥇 [A lot of linters](/usage/linters) included, no need to install them.
3231
- 📈 Minimum number of [false positives](/usage/false-positives) because of tuned default settings.
33-
- 🔥 Nice output with colors, source code lines (Text, JSON, Tab, HTML, Checkstyle, Code-Climate, JUnit-XML, Teamcity, SARIF).
32+
- 🔥 Nice output with colors and source code lines: text, JSON, tab, HTML, Checkstyle, Code-Climate, JUnit-XML, TeamCity, SARIF.
3433

3534
[Get started now!](/welcome/install)
3635

pkg/commands/flagsets.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func setupOutputFormatsFlagSet(v *viper.Viper, fs *pflag.FlagSet) {
118118

119119
internal.AddFlagAndBind(v, fs, fs.String, "output.junit-xml.path", "output.formats.junit-xml.path", "",
120120
color.GreenString(outputPathDesc))
121-
internal.AddFlagAndBind(v, fs, fs.Bool, "output.junit-xml.extended", "output.formats.junit-xml.extended", true,
121+
internal.AddFlagAndBind(v, fs, fs.Bool, "output.junit-xml.extended", "output.formats.junit-xml.extended", false,
122122
color.GreenString("Support extra JUnit XML fields."))
123123

124124
internal.AddFlagAndBind(v, fs, fs.String, "output.teamcity.path", "output.formats.teamcity.path", "",

pkg/config/output_formats.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
package config
22

33
type Formats struct {
4-
Text Text `mapstructure:"text"`
5-
JSON SimpleStyle `mapstructure:"json"`
6-
Tab Tab `mapstructure:"tab"`
7-
HTML SimpleStyle `mapstructure:"html"`
8-
Checkstyle SimpleStyle `mapstructure:"checkstyle"`
9-
CodeClimate SimpleStyle `mapstructure:"code-climate"`
10-
JUnitXML JUnitXML `mapstructure:"junit-xml"`
11-
TeamCity SimpleStyle `mapstructure:"team-city"`
12-
Sarif SimpleStyle `mapstructure:"sarif"`
4+
Text Text `mapstructure:"text"`
5+
JSON SimpleFormat `mapstructure:"json"`
6+
Tab Tab `mapstructure:"tab"`
7+
HTML SimpleFormat `mapstructure:"html"`
8+
Checkstyle SimpleFormat `mapstructure:"checkstyle"`
9+
CodeClimate SimpleFormat `mapstructure:"code-climate"`
10+
JUnitXML JUnitXML `mapstructure:"junit-xml"`
11+
TeamCity SimpleFormat `mapstructure:"teamcity"`
12+
Sarif SimpleFormat `mapstructure:"sarif"`
1313
}
1414

1515
func (f *Formats) IsEmpty() bool {
16-
styles := []SimpleStyle{
17-
f.Text.SimpleStyle,
16+
styles := []SimpleFormat{
17+
f.Text.SimpleFormat,
1818
f.JSON,
19-
f.Tab.SimpleStyle,
19+
f.Tab.SimpleFormat,
2020
f.HTML,
2121
f.Checkstyle,
2222
f.CodeClimate,
23-
f.JUnitXML.SimpleStyle,
23+
f.JUnitXML.SimpleFormat,
2424
f.TeamCity,
2525
f.Sarif,
2626
}
@@ -34,24 +34,24 @@ func (f *Formats) IsEmpty() bool {
3434
return true
3535
}
3636

37-
type SimpleStyle struct {
37+
type SimpleFormat struct {
3838
Path string `mapstructure:"path"`
3939
}
4040

4141
type Text struct {
42-
SimpleStyle `mapstructure:",squash"`
42+
SimpleFormat `mapstructure:",squash"`
4343
PrintLinterName bool `mapstructure:"print-linter-name"`
4444
PrintIssuedLine bool `mapstructure:"print-issued-lines"`
4545
Colors bool `mapstructure:"colors"`
4646
}
4747

4848
type Tab struct {
49-
SimpleStyle `mapstructure:",squash"`
49+
SimpleFormat `mapstructure:",squash"`
5050
PrintLinterName bool `mapstructure:"print-linter-name"`
51-
UseColors bool `mapstructure:"use-colors"`
51+
Colors bool `mapstructure:"colors"`
5252
}
5353

5454
type JUnitXML struct {
55-
SimpleStyle `mapstructure:",squash"`
56-
Extended bool `mapstructure:"extended"`
55+
SimpleFormat `mapstructure:",squash"`
56+
Extended bool `mapstructure:"extended"`
5757
}

pkg/printers/printer.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ func NewPrinter(log logutils.Log, cfg *config.Formats, reportData *report.Data,
6565
//nolint:gocyclo,funlen // the complexity is related to the number of formats.
6666
func (c *Printer) Print(issues []result.Issue) error {
6767
if c.cfg.IsEmpty() {
68-
c.cfg.Text.SimpleStyle.Path = outputStdOut
68+
c.cfg.Text.SimpleFormat.Path = outputStdOut
6969
}
7070

7171
var printers []issuePrinter
7272

7373
if c.cfg.Text.Path != "" {
74-
w, closer, err := c.createWriter(&c.cfg.Text.SimpleStyle)
74+
w, closer, err := c.createWriter(&c.cfg.Text.SimpleFormat)
7575
if err != nil {
7676
return fmt.Errorf("can't create output for %s: %w", c.cfg.Text.Path, err)
7777
}
@@ -137,7 +137,7 @@ func (c *Printer) Print(issues []result.Issue) error {
137137
}
138138

139139
if c.cfg.JUnitXML.Path != "" {
140-
w, closer, err := c.createWriter(&c.cfg.JUnitXML.SimpleStyle)
140+
w, closer, err := c.createWriter(&c.cfg.JUnitXML.SimpleFormat)
141141
if err != nil {
142142
return fmt.Errorf("can't create output for %s: %w", c.cfg.JUnitXML.Path, err)
143143
}
@@ -179,7 +179,7 @@ func (c *Printer) Print(issues []result.Issue) error {
179179
return nil
180180
}
181181

182-
func (c *Printer) createWriter(cfg *config.SimpleStyle) (io.Writer, func(), error) {
182+
func (c *Printer) createWriter(cfg *config.SimpleFormat) (io.Writer, func(), error) {
183183
if cfg.Path == "" || cfg.Path == outputStdOut {
184184
return c.stdOut, func() {}, nil
185185
}

pkg/printers/printer_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func TestPrinter_Print_stdout(t *testing.T) {
4949
desc: "stdout (explicit)",
5050
cfg: &config.Formats{
5151
Text: config.Text{
52-
SimpleStyle: config.SimpleStyle{
52+
SimpleFormat: config.SimpleFormat{
5353
Path: "stdout",
5454
},
5555
},
@@ -94,7 +94,7 @@ func TestPrinter_Print_stderr(t *testing.T) {
9494

9595
cfg := &config.Formats{
9696
Text: config.Text{
97-
SimpleStyle: config.SimpleStyle{
97+
SimpleFormat: config.SimpleFormat{
9898
Path: "stderr",
9999
},
100100
},
@@ -132,7 +132,7 @@ func TestPrinter_Print_file(t *testing.T) {
132132

133133
cfg := &config.Formats{
134134
Text: config.Text{
135-
SimpleStyle: config.SimpleStyle{
135+
SimpleFormat: config.SimpleFormat{
136136
Path: outputPath,
137137
},
138138
},
@@ -174,14 +174,14 @@ func TestPrinter_Print_multiple(t *testing.T) {
174174
outputPath := filepath.Join(t.TempDir(), "teamcity.txt")
175175

176176
cfg := &config.Formats{
177-
TeamCity: config.SimpleStyle{
177+
TeamCity: config.SimpleFormat{
178178
Path: outputPath,
179179
},
180-
JSON: config.SimpleStyle{
180+
JSON: config.SimpleFormat{
181181
Path: "stdout",
182182
},
183183
Text: config.Text{
184-
SimpleStyle: config.SimpleStyle{
184+
SimpleFormat: config.SimpleFormat{
185185
Path: "stderr",
186186
},
187187
},

pkg/printers/tab.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
// Tab prints issues using tabulation as a field separator.
1616
type Tab struct {
1717
printLinterName bool
18-
useColors bool
18+
colors bool
1919

2020
log logutils.Log
2121
w io.Writer
@@ -24,7 +24,7 @@ type Tab struct {
2424
func NewTab(log logutils.Log, w io.Writer, cfg *config.Tab) *Tab {
2525
return &Tab{
2626
printLinterName: cfg.PrintLinterName,
27-
useColors: cfg.UseColors,
27+
colors: cfg.Colors,
2828
log: log.Child(logutils.DebugKeyTabPrinter),
2929
w: w,
3030
}
@@ -33,7 +33,7 @@ func NewTab(log logutils.Log, w io.Writer, cfg *config.Tab) *Tab {
3333
func (p *Tab) SprintfColored(ca color.Attribute, format string, args ...any) string {
3434
c := color.New(ca)
3535

36-
if !p.useColors {
36+
if !p.colors {
3737
c.DisableColor()
3838
}
3939

pkg/printers/tab_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ path/to/fileb.go:300:9 another issue
8989
buf := new(bytes.Buffer)
9090

9191
printer := NewTab(logutils.NewStderrLog(logutils.DebugKeyEmpty), buf, &config.Tab{
92-
SimpleStyle: config.SimpleStyle{},
92+
SimpleFormat: config.SimpleFormat{},
9393
PrintLinterName: test.printLinterName,
94-
UseColors: test.useColors,
94+
Colors: test.useColors,
9595
})
9696

9797
err := printer.Print(issues)

pkg/printers/text.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
type Text struct {
1717
printLinterName bool
1818
printIssuedLine bool
19-
useColors bool
19+
colors bool
2020

2121
log logutils.Log
2222
w io.Writer
@@ -26,7 +26,7 @@ func NewText(log logutils.Log, w io.Writer, cfg *config.Text) *Text {
2626
return &Text{
2727
printLinterName: cfg.PrintLinterName,
2828
printIssuedLine: cfg.PrintIssuedLine,
29-
useColors: cfg.Colors,
29+
colors: cfg.Colors,
3030
log: log.Child(logutils.DebugKeyTextPrinter),
3131
w: w,
3232
}
@@ -35,7 +35,7 @@ func NewText(log logutils.Log, w io.Writer, cfg *config.Text) *Text {
3535
func (p *Text) SprintfColored(ca color.Attribute, format string, args ...any) string {
3636
c := color.New(ca)
3737

38-
if !p.useColors {
38+
if !p.colors {
3939
c.DisableColor()
4040
}
4141

pkg/printers/text_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ path/to/fileb.go:300:9: another issue
117117
buf := new(bytes.Buffer)
118118

119119
printer := NewText(logutils.NewStderrLog(logutils.DebugKeyEmpty), buf, &config.Text{
120-
SimpleStyle: config.SimpleStyle{},
120+
SimpleFormat: config.SimpleFormat{},
121121
PrintLinterName: test.printLinterName,
122122
PrintIssuedLine: test.printIssuedLine,
123123
Colors: test.useColors,

0 commit comments

Comments
 (0)