Skip to content

Commit a15d862

Browse files
Excavator: Bump go dependency github.com/golangci/golangci-lint/v2
1 parent be91778 commit a15d862

File tree

146 files changed

+10973
-226
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+10973
-226
lines changed

generated_src/golangcilint/internal/github.com/golangci/golangci-lint/v2/internal/cache/cache.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ func (c *Cache) computePkgHash(pkg *packages.Package) (hashResults, error) {
166166

167167
fmt.Fprintf(key, "pkgpath %s\n", pkg.PkgPath)
168168

169-
for _, f := range pkg.CompiledGoFiles {
169+
for _, f := range slices.Concat(pkg.CompiledGoFiles, pkg.IgnoredFiles) {
170170
h, fErr := c.fileHash(f)
171171
if fErr != nil {
172172
return nil, fmt.Errorf("failed to calculate file %s hash: %w", f, fErr)

generated_src/golangcilint/internal/github.com/golangci/golangci-lint/v2/internal/x/tools/analysisinternal/analysis.go

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,30 @@ package analysisinternal
88

99
import (
1010
"fmt"
11-
"os"
11+
"slices"
1212

1313
"golang.org/x/tools/go/analysis"
1414
)
1515

16-
// MakeReadFile returns a simple implementation of the Pass.ReadFile function.
17-
func MakeReadFile(pass *analysis.Pass) func(filename string) ([]byte, error) {
16+
// A ReadFileFunc is a function that returns the
17+
// contents of a file, such as [os.ReadFile].
18+
type ReadFileFunc = func(filename string) ([]byte, error)
19+
20+
// CheckedReadFile returns a wrapper around a Pass.ReadFile
21+
// function that performs the appropriate checks.
22+
func CheckedReadFile(pass *analysis.Pass, readFile ReadFileFunc) ReadFileFunc {
1823
return func(filename string) ([]byte, error) {
1924
if err := CheckReadable(pass, filename); err != nil {
2025
return nil, err
2126
}
22-
return os.ReadFile(filename)
27+
return readFile(filename)
2328
}
2429
}
2530

2631
// CheckReadable enforces the access policy defined by the ReadFile field of [analysis.Pass].
2732
func CheckReadable(pass *analysis.Pass, filename string) error {
28-
if slicesContains(pass.OtherFiles, filename) ||
29-
slicesContains(pass.IgnoredFiles, filename) {
33+
if slices.Contains(pass.OtherFiles, filename) ||
34+
slices.Contains(pass.IgnoredFiles, filename) {
3035
return nil
3136
}
3237
for _, f := range pass.Files {
@@ -36,13 +41,3 @@ func CheckReadable(pass *analysis.Pass, filename string) error {
3641
}
3742
return fmt.Errorf("Pass.ReadFile: %s is not among OtherFiles, IgnoredFiles, or names of Files", filename)
3843
}
39-
40-
// TODO(adonovan): use go1.21 slices.Contains.
41-
func slicesContains[S ~[]E, E comparable](slice S, x E) bool {
42-
for _, elem := range slice {
43-
if elem == x {
44-
return true
45-
}
46-
}
47-
return false
48-
}

generated_src/golangcilint/internal/github.com/golangci/golangci-lint/v2/internal/x/tools/diff/diff.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package diff
77

88
import (
99
"fmt"
10+
"slices"
1011
"sort"
1112
"strings"
1213
)
@@ -64,7 +65,7 @@ func ApplyBytes(src []byte, edits []Edit) ([]byte, error) {
6465
// It may return a different slice.
6566
func validate(src string, edits []Edit) ([]Edit, int, error) {
6667
if !sort.IsSorted(editsSort(edits)) {
67-
edits = append([]Edit(nil), edits...)
68+
edits = slices.Clone(edits)
6869
SortEdits(edits)
6970
}
7071

generated_src/golangcilint/internal/github.com/golangci/golangci-lint/v2/internal/x/tools/diff/lcs/common.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func (l lcs) fix() lcs {
5151
// from the set of diagonals in l, find a maximal non-conflicting set
5252
// this problem may be NP-complete, but we use a greedy heuristic,
5353
// which is quadratic, but with a better data structure, could be D log D.
54-
// indepedent is not enough: {0,3,1} and {3,0,2} can't both occur in an lcs
54+
// independent is not enough: {0,3,1} and {3,0,2} can't both occur in an lcs
5555
// which has to have monotone x and y
5656
if len(l) == 0 {
5757
return nil

generated_src/golangcilint/internal/github.com/golangci/golangci-lint/v2/internal/x/tools/diff/lcs/doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ computed labels. That is the worst case. Had the code noticed (x,y)=(u,v)=(3,3)
139139
from the edgegraph. The implementation looks for a number of special cases to try to avoid computing an extra forward path.
140140
141141
If the two-sided algorithm has stop early (because D has become too large) it will have found a forward LCS and a
142-
backwards LCS. Ideally these go with disjoint prefixes and suffixes of A and B, but disjointness may fail and the two
142+
backwards LCS. Ideally these go with disjoint prefixes and suffixes of A and B, but disjointedness may fail and the two
143143
computed LCS may conflict. (An easy example is where A is a suffix of B, and shares a short prefix. The backwards LCS
144144
is all of A, and the forward LCS is a prefix of A.) The algorithm combines the two
145145
to form a best-effort LCS. In the worst case the forward partial LCS may have to

generated_src/golangcilint/internal/github.com/golangci/golangci-lint/v2/internal/x/tools/diff/lcs/old.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func forward(e *editGraph) lcs {
105105
return ans
106106
}
107107
// from D to D+1
108-
for D := 0; D < e.limit; D++ {
108+
for D := range e.limit {
109109
e.setForward(D+1, -(D + 1), e.getForward(D, -D))
110110
if ok, ans := e.fdone(D+1, -(D + 1)); ok {
111111
return ans
@@ -199,13 +199,14 @@ func (e *editGraph) bdone(D, k int) (bool, lcs) {
199199
}
200200

201201
// run the backward algorithm, until success or up to the limit on D.
202+
// (used only by tests)
202203
func backward(e *editGraph) lcs {
203204
e.setBackward(0, 0, e.ux)
204205
if ok, ans := e.bdone(0, 0); ok {
205206
return ans
206207
}
207208
// from D to D+1
208-
for D := 0; D < e.limit; D++ {
209+
for D := range e.limit {
209210
e.setBackward(D+1, -(D + 1), e.getBackward(D, -D)-1)
210211
if ok, ans := e.bdone(D+1, -(D + 1)); ok {
211212
return ans
@@ -299,7 +300,7 @@ func twosided(e *editGraph) lcs {
299300
e.setBackward(0, 0, e.ux)
300301

301302
// from D to D+1
302-
for D := 0; D < e.limit; D++ {
303+
for D := range e.limit {
303304
// just finished a backwards pass, so check
304305
if got, ok := e.twoDone(D, D); ok {
305306
return e.twolcs(D, D, got)
@@ -376,10 +377,7 @@ func (e *editGraph) twoDone(df, db int) (int, bool) {
376377
if (df+db+e.delta)%2 != 0 {
377378
return 0, false // diagonals cannot overlap
378379
}
379-
kmin := -db + e.delta
380-
if -df > kmin {
381-
kmin = -df
382-
}
380+
kmin := max(-df, -db+e.delta)
383381
kmax := db + e.delta
384382
if df < kmax {
385383
kmax = df

generated_src/golangcilint/internal/github.com/golangci/golangci-lint/v2/internal/x/tools/diff/ndiff.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func diffRunes(before, after []rune) []Edit {
7272
func runes(bytes []byte) []rune {
7373
n := utf8.RuneCount(bytes)
7474
runes := make([]rune, n)
75-
for i := 0; i < n; i++ {
75+
for i := range n {
7676
r, sz := utf8.DecodeRune(bytes)
7777
bytes = bytes[sz:]
7878
runes[i] = r

generated_src/golangcilint/internal/github.com/golangci/golangci-lint/v2/internal/x/tools/diff/unified.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,12 @@ func toUnified(fromName, toName string, content string, edits []Edit, contextLin
129129

130130
switch {
131131
case h != nil && start == last:
132-
//direct extension
132+
// direct extension
133133
case h != nil && start <= last+gap:
134-
//within range of previous lines, add the joiners
134+
// within range of previous lines, add the joiners
135135
addEqualLines(h, lines, last, start)
136136
default:
137-
//need to start a new hunk
137+
// need to start a new hunk
138138
if h != nil {
139139
// add the edge to the previous hunk
140140
addEqualLines(h, lines, last, last+contextLines)

generated_src/golangcilint/internal/github.com/golangci/golangci-lint/v2/pkg/commands/flagsets.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,5 +138,5 @@ func setupIssuesFlagSet(v *viper.Viper, fs *pflag.FlagSet) {
138138
internal.AddFlagAndBind(v, fs, fs.Bool, "whole-files", "issues.whole-files", false,
139139
color.GreenString("Show issues in any part of update files (requires new-from-rev or new-from-patch)"))
140140
internal.AddFlagAndBind(v, fs, fs.Bool, "fix", "issues.fix", false,
141-
color.GreenString("Fix found issues (if it's supported by the linter)"))
141+
color.GreenString("Apply the fixes detected by the linters and formatters (if it's supported by the linter)"))
142142
}

generated_src/golangcilint/internal/github.com/golangci/golangci-lint/v2/pkg/commands/fmt.go

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,11 @@ func (c *fmtCommand) preRunE(_ *cobra.Command, _ []string) error {
113113
}
114114

115115
func (c *fmtCommand) execute(_ *cobra.Command, args []string) error {
116-
paths, err := cleanArgs(args)
117-
if err != nil {
118-
return fmt.Errorf("failed to clean arguments: %w", err)
119-
}
116+
paths := cleanArgs(args)
120117

121118
c.log.Infof("Formatting Go files...")
122119

123-
err = c.runner.Run(paths)
120+
err := c.runner.Run(paths)
124121
if err != nil {
125122
return fmt.Errorf("failed to process files: %w", err)
126123
}
@@ -134,25 +131,15 @@ func (c *fmtCommand) persistentPostRun(_ *cobra.Command, _ []string) {
134131
}
135132
}
136133

137-
func cleanArgs(args []string) ([]string, error) {
134+
func cleanArgs(args []string) []string {
138135
if len(args) == 0 {
139-
abs, err := filepath.Abs(".")
140-
if err != nil {
141-
return nil, err
142-
}
143-
144-
return []string{abs}, nil
136+
return []string{"."}
145137
}
146138

147139
var expanded []string
148140
for _, arg := range args {
149-
abs, err := filepath.Abs(strings.ReplaceAll(arg, "...", ""))
150-
if err != nil {
151-
return nil, err
152-
}
153-
154-
expanded = append(expanded, abs)
141+
expanded = append(expanded, filepath.Clean(strings.ReplaceAll(arg, "...", "")))
155142
}
156143

157-
return expanded, nil
144+
return expanded
158145
}

0 commit comments

Comments
 (0)