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

Include gdscript warning name in the warning message. #40155

Merged
merged 1 commit into from
Jul 6, 2020

Conversation

rcorre
Copy link
Contributor

@rcorre rcorre commented Jul 6, 2020

I can open a proposal if desired, but this is just a pretty small
quality-of-life thing.

Occasionally you want to ignore a warning with a warning-ignore
comment, and you have to go into the settings to look up what the
actual name of the warning is. This patch appends the warning name to
the end of the warning so you know what string to use to ignore it,
similar to other linters like pylint.

For example

"The signal 'blah' is declared but never emitted.";

is now

"The signal 'blah' is declared but never emitted. (UNUSED_SIGNAL)";

}
ERR_FAIL_V_MSG(String(), "Invalid GDScript warning code: " + get_name_from_code(code) + ".");
return msg + " (" + get_name() + ")";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation issue.

I'd suggest using square brackets ([UNUSED_ARGUMENT]) instead of parentheses, as it's what is used for compiler warnings (at least GCC and Clang's).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine either way, but FWIW pylint uses parens, and gdscript seems most similar to python:

[rcorre@midova tmp]$ pylint example.py
************* Module example
example.py:1:0: C0305: Trailing newlines (trailing-newlines)

Anyone familiar with python will immediately understand that "the thing in parens" is what they can put in the ignore comment.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, I'm also fine either way :) I guess it depends what compiler warnings folk are most used too (C/C++ vs Python).

@akien-mga
Copy link
Member

Please squash the commits.

Occasionally you want to ignore a warning with a `warning-ignore`
comment, and you have to go into the settings to look up what the
actual name of the warning is. This patch appends the warning name to
the end of the warning so you know what string to use to ignore it,
similar to other linters like pylint.

For example

```
"The signal 'blah' is declared but never emitted.";
```

is now

```
"The signal 'blah' is declared but never emitted. (UNUSED_SIGNAL)";
```
@Calinou Calinou added this to the 4.0 milestone Jul 6, 2020
@Calinou Calinou added cherrypick:3.x Considered for cherry-picking into a future 3.x release enhancement topic:editor topic:gdscript usability labels Jul 6, 2020
@YeldhamDev
Copy link
Member

I don't really see the point of this, since you can just click "Ignore" in the warning itself.

@rcorre
Copy link
Contributor Author

rcorre commented Jul 6, 2020

@YeldhamDev you can only click "ignore" if you're using the builtin editor. This is useful for folks using an external editor (which can now show warnings thanks to LSP support 🎉 )

@YeldhamDev
Copy link
Member

Oh, didn't think about that! The change is fine then.

@akien-mga akien-mga merged commit a535b91 into godotengine:master Jul 6, 2020
@akien-mga
Copy link
Member

Thanks!

@akien-mga
Copy link
Member

Cherry-picked for 3.2.3.

@akien-mga akien-mga removed the cherrypick:3.x Considered for cherry-picking into a future 3.x release label Jul 6, 2020
@akien-mga
Copy link
Member

Now that I'm testing, I'm not sure this was a good change, as it adds redundant information which was already included in the warning:
Screenshot_20200710_124041
Screenshot_20200710_124241

I guess your motivation for adding this is that you want it visible in the debugger even without expanding the warning details, i.e. when it's like this:
Screenshot_20200710_124309

But as it stands it adds redundant info for the other two cases.

@rcorre
Copy link
Contributor Author

rcorre commented Jul 10, 2020

My motivation was making this visible in an external editor that uses the LSP for linting. I'm using neovim with ALE and I only see the first line. I can check tonight if that's a matter of the LSP or my configuration.

@rcorre rcorre deleted the warning-names branch July 10, 2020 14:13
@rcorre
Copy link
Contributor Author

rcorre commented Jul 14, 2020

The LSP calls get_message to build the warning message it sends, so no external editor will see the warning name without this patch.

@rcorre
Copy link
Contributor Author

rcorre commented Jul 14, 2020

So I suppose the "proper" fix would be to replicate https://github.com/rcorre/godot/blob/0fe60f84241663a053cde622567c669f2b6093c9/modules/gdscript/gdscript.cpp#L624 in the LSP.

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