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

Allow warning-ignore in the same line as the respective warning #47863

Merged
merged 1 commit into from
May 18, 2021

Conversation

mphe
Copy link
Contributor

@mphe mphe commented Apr 13, 2021

This patch allows putting warning-ignore comments in the same line as the respective warning itself.

# warning-ignore: return_value_discarded
connect("tree_entered", self, "_tree_entered")

# This works now, too
connect("tree_entered", self, "_tree_entered")  # warning-ignore: return_value_discarded

I can't think of any particular reason the latter shouldn't be allowed.
It should be up to the programmer to decide where to put their comments.
Personally, and I'm sure I'm not the only one, I find the latter more readable as it doesn't visually interrupt the actual code.

I took a look at the source and saw that this fix only requires a >= to be changed to >, so this is a very simple fix for slightly more flexibility.
As for the master branch, I couldn't find any code related to honoring warning-ignore at all, so this fix is only for 3.x versions.

@mphe mphe requested a review from a team as a code owner April 13, 2021 16:30
@Calinou Calinou added this to the 3.4 milestone Apr 13, 2021
@akien-mga
Copy link
Member

Is this also relevant for the master branch?

@akien-mga akien-mga merged commit 6355877 into godotengine:3.x May 18, 2021
@akien-mga
Copy link
Member

akien-mga commented May 18, 2021

Thanks! And congrats for your first merged Godot contribution 🎉

@mphe
Copy link
Contributor Author

mphe commented May 18, 2021

Is this also relevant for the master branch?

As mentioned in the top post, I haven't found any warning-ignore related code in the master branch. I don't know if it was renamed or still needs to be implemented (or maybe I'm just blind), but it probably can't be trivially merged into master.

@akien-mga
Copy link
Member

Indeed, thanks for checking. It seems that this code was lost in the rewrite, there's some stray stuff left but no logic to bind it together:

$ rg ignored_warnings
modules/gdscript/gdscript_parser.cpp
241:    if (ignored_warnings.has(warn_name)) {

modules/gdscript/gdscript_parser.h
1202:   Set<String> ignored_warnings;

$ rg warning-ignore
editor/plugins/script_text_editor.cpp
298:            code_editor->get_text_editor()->insert_at("# warning-ignore:" + meta["code"].operator String(), meta["line"].operator int64_t() - 1);

@akien-mga
Copy link
Member

Cherry-picked for 3.3.2.

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

Successfully merging this pull request may close these issues.

4 participants