-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 missing type info in formal parameter #57147
Comments
Lo and behold this harkens back to lint request #1 (https://github.com/dart-lang/linter/issues/1). Could have saved me a headache! [email protected] Review URL: https://codereview.chromium.org//1367723003 .
An easy way to tackle this would be to check that argument names start with lowercase. And a similar check for method names would help spot another sneaky case: class MyClassNameBeforeRefactoring {
// oops, forgot to rename the constructor...
MyClassNameAfterRefactoring() {
// something important that will never happen
}
} |
@ochafik for your case a rule for functions and methods like http://dart-lang.github.io/linter/lints/non_constant_identifier_names.html would be nice to catch this. |
Looks like this will become irrelevant when the old typedef syntax becomes obsolete? |
Yeah I think we've likely dodged this by recommending the new typedef format. |
Discovered in the wild a number of cases like this:
typedef A(B);
typedef B(dynamic);
Both of them are essentially equivalent to
dynamic->dynamic
which is most likely not what the user has in mind. Instead, they likely mean:typedef A(B _);
typedef B(dynamic _);
As Paul Berry points out it's a nasty user trap in the language, especially for people coming from a C/C++ background where using a single identifier as a formal parameter denotes the type of the formal parameter. A proposed lint:
The text was updated successfully, but these errors were encountered: