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

FormatString bug in AutoComplete found by Error Prone #2053

Closed
vorburger opened this issue Jun 26, 2023 · 3 comments · Fixed by #2175
Closed

FormatString bug in AutoComplete found by Error Prone #2053

vorburger opened this issue Jun 26, 2023 · 3 comments · Fixed by #2175
Labels
theme: auto-completion An issue or change related to auto-completion type: bug 🐛 type: enhancement ✨
Milestone

Comments

@vorburger
Copy link
Contributor

I'm running https://errorprone.info/ on this project, and it claims to have found a bug:

picocli/src/main/java/picocli/AutoComplete.java:788 : error: [FormatString] extra format arguments: used 2, provided 3
                buff.append(format("%s      positionals=$( compReplyArray \"${%s_pos_param_args[@]}\" )\n", indent, paramName, currWord));

picocli/src/main/java/picocli/AutoComplete.java:832 : error: [FormatString] extra format arguments: used 2, provided 3
                buff.append(format("%s      COMPREPLY=( $( compReplyArray \"${%s_option_args[@]}\" ) )\n", indent, bashify(option.paramLabel()), currWord));

See https://errorprone.info/bugpattern/FormatString ... @remkop from a quick glance, I think this is a real bug, not a false positive? As far as I understand it in both of those cases there are indeed only x2 %s but 3 arguments.

I would by happy to send a CL, but it's not immediately clear to me which of the 3 is wrong and should be removed.

@remkop
Copy link
Owner

remkop commented Jun 28, 2023

@vorburger Thank you for raising this!
Looks like these changes were made as part of PR #1759 .
I added a comment on that PR and I propose we wait for @jsotuyod to take a look and let us know.

@remkop remkop added type: bug 🐛 type: enhancement ✨ theme: auto-completion An issue or change related to auto-completion labels Jun 28, 2023
@remkop remkop added this to the 4.7.5 milestone Jun 28, 2023
@vorburger
Copy link
Contributor Author

Following @jsotuyod response the I had a look at this again, and it seems that on the current main branch this may already have been fixed? The line numbers, and code, has changed, see here and here... probably actually already all good as-is.

@vorburger
Copy link
Contributor Author

@remkop actually I was wrong above, this was never fixed!

BTW you can now even easily reproduce that Error Prone message above locally using #2054.

I've now raised #2175 to propose a fix for this.

@remkop remkop modified the milestones: 4.7.5, 4.7.6 Dec 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme: auto-completion An issue or change related to auto-completion type: bug 🐛 type: enhancement ✨
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants