Skip to content
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

fix: combination of --fix and --path-prefix #3700

Merged
merged 3 commits into from
Mar 20, 2023

Conversation

pohly
Copy link
Contributor

@pohly pohly commented Mar 16, 2023

This combination used to fail because the fixer was executed after the path prefixer.
Then the file paths that it processed didn't match the current working directory, leading to:

ERRO Failed to fix issues in file test/fix_sample/main.go: failed to get file bytes for test/fix_sample/main.go: can't read file test/fix_sample/main.go: open test/fix_sample/main.go: no such file or directory

Making the fixer a normal processor and moving it before the path prefixed avoids this problem.

Related to #2293 and #3626

@pohly
Copy link
Contributor Author

pohly commented Mar 16, 2023

This is an alternative to #3626.

test/fix_sample/main.go Outdated Show resolved Hide resolved
@ldez ldez changed the title fix combination of --fix and --path-prefix fix: combination of --fix and --path-prefix Mar 17, 2023
@pohly
Copy link
Contributor Author

pohly commented Mar 18, 2023

Rebased after PR #3571 was merged.

@ldez ldez added the bug Something isn't working label Mar 20, 2023
pohly and others added 3 commits March 20, 2023 21:22
This combination used to fail because the fixer was executed after the path
prefixer. Then the file paths that it processed didn't match the current
working directory, leading to:

     ERRO Failed to fix issues in file test/fix_sample/main.go: failed to get file bytes for test/fix_sample/main.go: can't read file test/fix_sample/main.go: open test/fix_sample/main.go: no such file or directory

Making the fixer a normal processor and moving it before the path prefixer
avoids this problem.
The combination with --path gets tested for the first test case.
This is arbitrary. It could also be tested for all of them,
but then each test would have to run twice (with and without).
Copy link
Member

@ldez ldez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ldez ldez merged commit d92b38c into golangci:master Mar 20, 2023
SeigeC pushed a commit to SeigeC/golangci-lint that referenced this pull request Apr 4, 2023
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
@ldez ldez added this to the v1.52 milestone Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: auto-fix bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants