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 linting sprintf that uses "%[1]s" #16

Merged
merged 1 commit into from
Dec 13, 2023

Conversation

Frassle
Copy link
Contributor

@Frassle Frassle commented Dec 12, 2023

Noticed when running "--fix" against a codebase that made use of "%[1]s" and "%s" format directives.

Without the fixes the negative test incorrectly tries to concatenate:

        -       fmt.Sprintf("%s %[1]s", "hello")
        +       "hello" + " %[1]s"

and the positive test doesn't:

        -       "Hello says " + s // want "fmt.Sprintf can be replaced with string addition"
        +       fmt.Sprintf("Hello says %[1]s", s) // want "fmt.Sprintf can be replaced with string addition"

@catenacyber
Copy link
Owner

Thanks @Frassle for the report and the fix

Any other feedback ?

@catenacyber catenacyber merged commit a02dde5 into catenacyber:main Dec 13, 2023
1 check passed
@Frassle
Copy link
Contributor Author

Frassle commented Dec 13, 2023

Any other feedback ?

Nope, otherwise seems to have worked as advertised 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants