-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
After removing some codes in the legacy file, new-from-rev is not correctly working #4622
Comments
Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors. |
Hello, without a reproducible context, it's not possible to diagnose the issue.
|
@ldez So, you mean, there are size limitation to detect the diff? Yes, I'm trying to find a way, but from the multiple test with minimal code, it was fine.. If it's related to the size of diff, then it will be much harder to detect actually. |
@ldez I realized that, https://stackoverflow.com/questions/40949745/git-diff-incorrectly-interprets-my-changes In case of default option git diff, because of the greedy algorithm limitation, when I check the git diff from the commit a long time ago, the diff is mixed with multiple functions. But, in case of histogram option, it shows proper git diff. When I add func gitDiff(extraArgs ...string) *exec.Cmd {
cmd := exec.Command("git", "diff", "--histogram", "--color=never", "--no-ext-diff")
if isSupportedByGit(2, 41, 0) {
cmd.Args = append(cmd.Args, "--default-prefix")
}
cmd.Args = append(cmd.Args, "--relative")
cmd.Args = append(cmd.Args, extraArgs...)
return cmd
} Check histogram option from git: https://git-scm.com/docs/diff-options/2.6.7 I think it can resolve problem on #4907 too. |
If it's ok, then I'll raise a PR to revgrep repo. |
I think the "verbose" option
this issue doesn't exist, can you provide the right issue number? |
@ldez Can u explain more on this? what do u mean about "verbose" option? From the golangci-lint side? How can we used this from the config file then?
#4097 this one, sorry I put wrong number. |
You are suggesting |
@ldez oh, ok. so you just want to use |
yes |
Do you still plan to create a PR? |
Seems related to #4349 |
Welcome
Description of the problem
I'm using
new-from-rev
to avoid lint from legacy code, and it worked well previously.But, when I delete some of the codes in the middle of the legacy file, and it causes the old code to be included in the lint.
I did similar behavior before, and it was fine for that situation, but for this case, all the codes in the legacy file under the deleted code are included into lint.
It's a bit hard to reproduce with minimal example because I tried, but all cases was fine. So, I think it seems extremely corner case. But, when I check the git diff, it is not a problem of git diff, it detects only changed part.
Are there any known issue for this?
I'll try to find a way with some of the public project which has a lot of long code, but for now, in order to check is known issue or, are there any solution. So, I raised issue first.
Version of golangci-lint
I tested with 1.55.2 too.
Configuration
Go environment
Verbose output of running
A minimal reproducible example or link to a public repository
Actually, it's hard to reproducable, I tried to reproduce with some codes, but I failed. In normal case, deletion of the code in the old code will not affect to the
new-from-rev
.But, only happening with large complex code case.
I'll further try to find a way to reproduce this with public large project.
Validation
The text was updated successfully, but these errors were encountered: