Skip to content

Commit 757bc74

Browse files
committed
chore: remove sort-results option
1 parent 378dfbd commit 757bc74

File tree

7 files changed

+12
-57
lines changed

7 files changed

+12
-57
lines changed

.golangci.next.reference.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4102,10 +4102,6 @@ output:
41024102
# Default: ""
41034103
path-prefix: ""
41044104

4105-
# Sort results by the order defined in `sort-order`.
4106-
# Default: false
4107-
sort-results: true
4108-
41094105
# Order to use when sorting results.
41104106
# Require `sort-results` to `true`.
41114107
# Possible values: `file`, `linter`, and `severity`.

jsonschema/golangci.next.jsonschema.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3890,11 +3890,6 @@
38903890
"items": {
38913891
"enum": ["linter", "severity", "file"]
38923892
}
3893-
},
3894-
"sort-results": {
3895-
"description": "Sort results by: filepath, line and column.",
3896-
"type": "boolean",
3897-
"default": true
38983893
}
38993894
}
39003895
},

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.Bool, "sort-results", "output.sort-results", false,
74-
color.GreenString("Sort linter results"))
7573
internal.AddFlagAndBind(v, fs, fs.StringSlice, "sort-order", "output.sort-order", nil,
7674
color.GreenString("Sort order of linter results"))
7775
internal.AddFlagAndBind(v, fs, fs.String, "path-prefix", "output.path-prefix", "",

pkg/config/output.go

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

33
import (
4-
"errors"
54
"fmt"
65
"slices"
76
"strings"
87
)
98

109
type Output struct {
11-
Formats Formats `mapstructure:"formats"`
12-
SortResults bool `mapstructure:"sort-results"`
13-
SortOrder []string `mapstructure:"sort-order"`
14-
PathPrefix string `mapstructure:"path-prefix"`
15-
ShowStats bool `mapstructure:"show-stats"`
10+
Formats Formats `mapstructure:"formats"`
11+
SortOrder []string `mapstructure:"sort-order"`
12+
PathPrefix string `mapstructure:"path-prefix"`
13+
ShowStats bool `mapstructure:"show-stats"`
1614
}
1715

1816
func (o *Output) Validate() error {
19-
if !o.SortResults && len(o.SortOrder) > 0 {
20-
return errors.New("sort-results should be 'true' to use sort-order")
21-
}
22-
2317
validOrders := []string{"linter", "file", "severity"}
2418

2519
all := strings.Join(o.SortOrder, " ")

pkg/config/output_test.go

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,25 @@ func TestOutput_Validate(t *testing.T) {
1414
{
1515
desc: "file",
1616
settings: &Output{
17-
SortResults: true,
18-
SortOrder: []string{"file"},
17+
SortOrder: []string{"file"},
1918
},
2019
},
2120
{
2221
desc: "linter",
2322
settings: &Output{
24-
SortResults: true,
25-
SortOrder: []string{"linter"},
23+
SortOrder: []string{"linter"},
2624
},
2725
},
2826
{
2927
desc: "severity",
3028
settings: &Output{
31-
SortResults: true,
32-
SortOrder: []string{"severity"},
29+
SortOrder: []string{"severity"},
3330
},
3431
},
3532
{
3633
desc: "multiple",
3734
settings: &Output{
38-
SortResults: true,
39-
SortOrder: []string{"file", "linter", "severity"},
35+
SortOrder: []string{"file", "linter", "severity"},
4036
},
4137
},
4238
}
@@ -57,26 +53,17 @@ func TestOutput_Validate_error(t *testing.T) {
5753
settings *Output
5854
expected string
5955
}{
60-
{
61-
desc: "sort-results false and sort-order",
62-
settings: &Output{
63-
SortOrder: []string{"file"},
64-
},
65-
expected: "sort-results should be 'true' to use sort-order",
66-
},
6756
{
6857
desc: "invalid sort-order",
6958
settings: &Output{
70-
SortResults: true,
71-
SortOrder: []string{"a"},
59+
SortOrder: []string{"a"},
7260
},
7361
expected: `unsupported sort-order name "a"`,
7462
},
7563
{
7664
desc: "duplicate",
7765
settings: &Output{
78-
SortResults: true,
79-
SortOrder: []string{"file", "linter", "severity", "linter"},
66+
SortOrder: []string{"file", "linter", "severity", "linter"},
8067
},
8168
expected: `the sort-order name "linter" is repeated several times`,
8269
},

pkg/result/processors/sort_results.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,6 @@ func (SortResults) Name() string { return "sort_results" }
5555

5656
// Process is performing sorting of the result issues.
5757
func (p SortResults) Process(issues []result.Issue) ([]result.Issue, error) {
58-
if !p.cfg.SortResults {
59-
return issues, nil
60-
}
61-
6258
if len(p.cfg.SortOrder) == 0 {
6359
p.cfg.SortOrder = []string{orderNameFile}
6460
}

pkg/result/processors/sort_results_test.go

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -209,22 +209,11 @@ func Test_numericCompare(t *testing.T) {
209209
}
210210
}
211211

212-
func TestSortResults_Process_noSorting(t *testing.T) {
212+
func TestSortResults_Process(t *testing.T) {
213213
tests := make([]result.Issue, len(issues))
214214
copy(tests, issues)
215215

216-
sr := NewSortResults(&config.Output{})
217-
218-
results, err := sr.Process(tests)
219-
require.NoError(t, err)
220-
assert.Equal(t, tests, results)
221-
}
222-
223-
func TestSortResults_Process_Sorting(t *testing.T) {
224-
tests := make([]result.Issue, len(issues))
225-
copy(tests, issues)
226-
227-
cfg := &config.Output{SortResults: true}
216+
cfg := &config.Output{}
228217

229218
sr := NewSortResults(cfg)
230219

0 commit comments

Comments
 (0)