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

Ignore assigning the loop variable to another variable by default #13

Closed
karamaru-alpha opened this issue Apr 9, 2024 · 0 comments · Fixed by #14
Closed

Ignore assigning the loop variable to another variable by default #13

karamaru-alpha opened this issue Apr 9, 2024 · 0 comments · Fixed by #14
Assignees
Labels
enhancement New feature or request

Comments

@karamaru-alpha
Copy link
Owner

karamaru-alpha commented Apr 9, 2024

The default setting detects cases where you want to you aim to preserve the state prior to modification within a for loop as below.

for _, v := range slice {
   before := v

   // Some processing for the variable v.

   log.Printf("before:%+v, after:%+v", before, v)
}

We have the option "ignore-alias" to avoid to detect assignment to a different variable, but I think the presence of false positives in the default settings is not good.

So I'd like to make the default setting not to detect places assign to a different variable.
In addition, I'll create the option to detect assignment to a different variable for cases like _i := i.

Related: #8

@karamaru-alpha karamaru-alpha added the enhancement New feature or request label Apr 9, 2024
@karamaru-alpha karamaru-alpha self-assigned this Apr 9, 2024
@karamaru-alpha karamaru-alpha changed the title Ignore assignment to a different variable by default Ignore assigning the loop variable to another variable by default Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
1 participant