Skip to content

Commit fc6a1fe

Browse files
committed
chore: new sort-order default
1 parent 757bc74 commit fc6a1fe

File tree

5 files changed

+14
-35
lines changed

5 files changed

+14
-35
lines changed

.golangci.next.reference.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4114,7 +4114,7 @@ output:
41144114
# 5. low
41154115
# Either they are sorted alphabetically.
41164116
#
4117-
# Default: ["file"]
4117+
# Default: ["linter", "file"]
41184118
sort-order:
41194119
- linter
41204120
- severity

pkg/commands/flagsets.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ func setupRunFlagSet(v *viper.Viper, fs *pflag.FlagSet) {
7070
}
7171

7272
func setupOutputFlagSet(v *viper.Viper, fs *pflag.FlagSet) {
73-
internal.AddFlagAndBind(v, fs, fs.StringSlice, "sort-order", "output.sort-order", nil,
74-
color.GreenString("Sort order of linter results"))
7573
internal.AddFlagAndBind(v, fs, fs.String, "path-prefix", "output.path-prefix", "",
7674
color.GreenString("Path prefix to add to output"))
7775
internal.AddFlagAndBind(v, fs, fs.Bool, "show-stats", "output.show-stats", false, color.GreenString("Show statistics per linter"))

pkg/result/processors/sort_results.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func (SortResults) Name() string { return "sort_results" }
5656
// Process is performing sorting of the result issues.
5757
func (p SortResults) Process(issues []result.Issue) ([]result.Issue, error) {
5858
if len(p.cfg.SortOrder) == 0 {
59-
p.cfg.SortOrder = []string{orderNameFile}
59+
p.cfg.SortOrder = []string{orderNameLinter, orderNameFile}
6060
}
6161

6262
var cmps []issueComparator

pkg/result/processors/sort_results_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ func TestSortResults_Process(t *testing.T) {
219219

220220
results, err := sr.Process(tests)
221221
require.NoError(t, err)
222-
assert.Equal(t, []result.Issue{issues[3], issues[2], issues[1], issues[0]}, results)
222+
assert.Equal(t, []result.Issue{issues[1], issues[0], issues[3], issues[2]}, results)
223223
}
224224

225225
func compToString(c int) string {

test/run_test.go

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -367,38 +367,19 @@ func TestUnsafeOk(t *testing.T) {
367367
}
368368

369369
func TestSortedResults(t *testing.T) {
370-
testCases := []struct {
371-
opt string
372-
want string
373-
}{
374-
{
375-
opt: "--sort-results=false",
376-
want: "testdata/sort_results/main.go:15:13: Error return value is not checked (errcheck)" + "\n" +
377-
"testdata/sort_results/main.go:12:5: var `db` is unused (unused)",
378-
},
379-
{
380-
opt: "--sort-results=true",
381-
want: "testdata/sort_results/main.go:12:5: var `db` is unused (unused)" + "\n" +
382-
"testdata/sort_results/main.go:15:13: Error return value is not checked (errcheck)",
383-
},
384-
}
385-
386370
binPath := testshared.InstallGolangciLint(t)
387371

388-
for _, test := range testCases {
389-
t.Run(test.opt, func(t *testing.T) {
390-
t.Parallel()
391-
392-
testshared.NewRunnerBuilder(t).
393-
WithNoConfig().
394-
WithArgs("--output.text.print-issued-lines=false", test.opt).
395-
WithTargetPath(testdataDir, "sort_results").
396-
WithBinPath(binPath).
397-
Runner().
398-
Run().
399-
ExpectExitCode(exitcodes.IssuesFound).ExpectOutputEq(test.want + "\n")
400-
})
401-
}
372+
testshared.NewRunnerBuilder(t).
373+
WithNoConfig().
374+
WithArgs("--output.text.print-issued-lines=false").
375+
WithTargetPath(testdataDir, "sort_results").
376+
WithBinPath(binPath).
377+
Runner().
378+
Run().
379+
ExpectExitCode(exitcodes.IssuesFound).ExpectOutputEq(
380+
"testdata/sort_results/main.go:15:13: Error return value is not checked (errcheck)" + "\n" +
381+
"testdata/sort_results/main.go:12:5: var `db` is unused (unused)" + "\n",
382+
)
402383
}
403384

404385
func TestIdentifierUsedOnlyInTests(t *testing.T) {

0 commit comments

Comments
 (0)