Skip to content

feat: add support for SuggestedFixes #5232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 57 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
6a296b0
chore: migrate dogsled
ldez Dec 11, 2024
b73ec12
chore: migrate gochecknoinits
ldez Dec 11, 2024
08d2476
chore: migrate gci
ldez Dec 13, 2024
d351aa8
chore: migrate gocritic
ldez Dec 13, 2024
36b2549
chore: migrate godot
ldez Dec 13, 2024
12d2c13
chore: migrate goheader
ldez Dec 13, 2024
30451ed
chore: migrate mirror
ldez Dec 13, 2024
6a40069
chore: migrate protogetter
ldez Dec 13, 2024
ebcff94
chore: migrate tagalign
ldez Dec 13, 2024
89dc119
chore: migrate whitespace
ldez Dec 13, 2024
0acc998
feat: add GetFilePositionFor
ldez Dec 13, 2024
19a66e6
chore: rewrite diff hunkChangesParser
ldez Dec 13, 2024
e7c65cb
chore: refactor nolintlint
ldez Dec 12, 2024
bf20023
chore: copy x/tools/internal/diff
ldez Dec 16, 2024
e5eefef
feat: new fixer
ldez Dec 16, 2024
632b805
chore: migrate nolintlint
ldez Dec 16, 2024
87f42b5
chore: migrate gofmt
ldez Dec 16, 2024
acfdecc
chore: migrate gofumpt
ldez Dec 16, 2024
473ab4e
chore: migrate goimports
ldez Dec 16, 2024
a85e53b
chore: migrate misspell
ldez Dec 16, 2024
75e4944
feat: support autofix for revive
ldez Dec 16, 2024
7b016e6
chore: tag all linters with autofix
ldez Dec 16, 2024
8444ec1
tests: autofix canonicalheader
ldez Dec 16, 2024
410281c
tests: autofix dupword
ldez Dec 16, 2024
e5c03da
tests: autofix fatcontext
ldez Dec 16, 2024
993ac5e
tests: autofix err113
ldez Dec 16, 2024
ddced09
tests: autofix errorlint
ldez Dec 16, 2024
4813ac7
tests: autofix iface
ldez Dec 16, 2024
ca2e133
tests: autofix importas
ldez Dec 16, 2024
54472f6
tests: autofix intrange
ldez Dec 16, 2024
46c6a38
tests: autofix nakedret
ldez Dec 16, 2024
ba516f4
tests: autofix nlreturn
ldez Dec 16, 2024
159bf02
tests: autofix perfsprint
ldez Dec 16, 2024
a642640
tests: autofix testifylint
ldez Dec 16, 2024
26c61a8
tests: autofix wsl
ldez Dec 16, 2024
65fd897
tests: autofix govet
ldez Dec 16, 2024
fe005f2
tests: autofix gosimple
ldez Dec 16, 2024
0cea44b
tests: autofix stylecheck
ldez Dec 16, 2024
6f36d37
tests: autofix staticcheck
ldez Dec 16, 2024
0dbb927
tests: autofix whitespace
ldez Dec 16, 2024
c4ba66d
tests: multiple fixes
ldez Dec 16, 2024
3c47cda
chore: migrate LLL
ldez Dec 16, 2024
66c31e6
chore: simplify godot
ldez Dec 16, 2024
b8d5d41
chore: migrate forbidigo
ldez Dec 16, 2024
30af54f
chore: migrate godox
ldez Dec 16, 2024
7d46339
chore: migrate makezero
ldez Dec 16, 2024
600e10e
chore: migrate nestif
ldez Dec 16, 2024
c7e3c0f
chore: migrate prealloc
ldez Dec 16, 2024
e1fbf35
chore: migrate unparam
ldez Dec 16, 2024
fe88914
tests: add cgo tests
ldez Dec 16, 2024
225f0f9
tests: ignore cgo tests for some linters
ldez Dec 16, 2024
94073d2
fix: dupl on Windows
ldez Dec 16, 2024
3763e1a
review
ldez Dec 16, 2024
f4b2e7a
tests: add missing whitespace tests
ldez Dec 16, 2024
898a5da
chore: add comments about TextEdits positions adjustements
ldez Dec 17, 2024
63b9001
feat: improve error handling
ldez Dec 17, 2024
936e333
fix: skip suggested changes for cgo
ldez Dec 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
review
  • Loading branch information
ldez committed Dec 16, 2024
commit 3763e1aea640914701a76e2deb7a36fd8549c745
9 changes: 7 additions & 2 deletions pkg/golinters/internal/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,13 @@ func parseDiffLines(h *diffpkg.Hunk) []diffLine {
return diffLines
}

func ExtractDiagnosticFromPatch(pass *analysis.Pass, file *ast.File, patch string,
lintCtx *linter.Context, formatter fmtTextFormatter) error {
func ExtractDiagnosticFromPatch(
pass *analysis.Pass,
file *ast.File,
patch string,
lintCtx *linter.Context,
formatter fmtTextFormatter,
) error {
diffs, err := diffpkg.ParseMultiFileDiff([]byte(patch))
if err != nil {
return fmt.Errorf("can't parse patch: %w", err)
Expand Down
4 changes: 2 additions & 2 deletions pkg/golinters/nolintlint/internal/nolintlint.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func (l Linter) Run(pass *analysis.Pass) ([]goanalysis.Issue, error) {
if lintersText != "" && !strings.HasPrefix(lintersText, "all") {
lls := strings.Split(lintersText, ",")
linters = make([]string, 0, len(lls))
rangeStart := (pos.Column - 1) + len("//") + len(leadingSpace) + len("nolint:")
rangeStart := (pos.Column - 1) + len(commentMark) + len(leadingSpace) + len("nolint:")
for i, ll := range lls {
rangeEnd := rangeStart + len(ll)
if i < len(lls)-1 {
Expand Down Expand Up @@ -202,7 +202,7 @@ func (l Linter) Run(pass *analysis.Pass) ([]goanalysis.Issue, error) {
}
}

if (l.needs&NeedsExplanation) != 0 && (explanation == "" || strings.TrimSpace(explanation) == "//") {
if (l.needs&NeedsExplanation) != 0 && (explanation == "" || strings.TrimSpace(explanation) == commentMark) {
needsExplanation := len(linters) == 0 // if no linters are mentioned, we must have explanation
// otherwise, check if we are excluding all the mentioned linters
for _, ll := range linters {
Expand Down
2 changes: 1 addition & 1 deletion pkg/golinters/nolintlint/nolintlint.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func New(settings *config.NoLintLintSettings) *goanalysis.Linter {

lnt, err := nolintlint.NewLinter(needs, settings.AllowNoExplanation)
if err != nil {
internal.LinterLogger.Fatalf("asasalint: create analyzer: %v", err)
internal.LinterLogger.Fatalf("%s: create analyzer: %v", nolintlint.LinterName, err)
}

analyzer := &analysis.Analyzer{
Expand Down
Loading