-
Notifications
You must be signed in to change notification settings - Fork 101
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
Lint for redundant positional arguments. #1770
base: master
Are you sure you want to change the base?
Lint for redundant positional arguments. #1770
Conversation
this accidentally depends on #1767 and im too lazy to fix it merge that first. |
Unit tests plz |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd also like for there to be unit tests. You can make one by #pragma
-ing the lint to an error and purposefully triggering it.
@@ -129,6 +136,7 @@ sealed class ArgumentList { | |||
_isKeyed = true; | |||
|
|||
Expressions[argIndex] = (name, value); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary empty line
|
||
if ((!expr.ValType.IsAnything && !paramType.MatchesType(expr.ValType))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary empty line & parentheses
if ((!expr.ValType.IsAnything && !paramType.MatchesType(expr.ValType))) { | |
if (!expr.ValType.IsAnything && !paramType.MatchesType(expr.ValType)) { |
|
||
if (newIdx == argIndex) { | ||
DMCompiler.Emit(WarningCode.PointlessPositionalArgument, key.Location, | ||
$"The argument at index {argIndex + 1} is a positional argument with a redundant index (`{argIndex + 1} = value` at argument {argIndex + 1}). This does not function like a named argument and is likely a mistake."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We avoid using backticks in compiler messages due to it causing formatting issues when pasted elsewhere
$"The argument at index {argIndex + 1} is a positional argument with a redundant index (`{argIndex + 1} = value` at argument {argIndex + 1}). This does not function like a named argument and is likely a mistake."); | |
$"The argument at index {argIndex + 1} is a positional argument with a redundant index (\"{argIndex + 1} = value\" at argument {argIndex + 1}). This does not function like a named argument and is likely a mistake."); |
Fixes #1768, adds a new lint.