-
Notifications
You must be signed in to change notification settings - Fork 27
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
Add NullParameterCheck, closes #49 #85
Conversation
"type": "NullParameter", | ||
"props": { | ||
"severity": "ERROR", | ||
"nullDefaultValueStyle": "questionmark" |
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.
Is there a convention for the naming of the option values? Sometimes they're UPPERCASE, (ENUM
) sometimes lowercase (nl
).
I think this check should be called In Java world, parameter assignment is usually considered as a bad practice http://checkstyle.sourceforge.net/apidocs/com/puppycrawl/tools/checkstyle/checks/coding/ParameterAssignmentCheck.html The check can be customised and check for null assignments if parameter assignment is allowed. Thoughts? |
Trying to keep the checks as close as possible to original checkstyle wherever possible http://checkstyle.sourceforge.net/checks.html |
I think that would be a bit confusing, parameter default values aren't really the same thing as reassigning them. Java doesn't even have parameter default values. I wouldn't consider having default values for parameters bad style either. |
Considering that, it's not really a deviation from the original checkstyle, it's just an additional, Haxe specific check.. The |
Yes in Java it checks for parameter assignment in the function body but we can use the same and tweak it for haxe. For example, I don't like default assignment like this ParameterAssignmentCheck
test(i = 12, s = "bar") - invalid The check should never allow either as it's equivalent to disabling the check. We can change the name to |
Regarding the first two valid examples: test(?i = 12, ?s = "bar")
test(?i = 12, ?s) These are bad code style IMO - you know about implied nullability? Because of the The // this is redundant
test(?s = null) |
You have answers for everything :) Checkstyle is about code style and consistency so worrying about the runtime performance is up-to the user but it's important for the check to have all the options covered. So if some targets have runtime overhead using ParameterAssignmentCheck
Can we cover all the scenarios with the above options? BTW totally off topic, I can add you as a collaborator to this repo if you are interested. Let me know. |
Just to be clear, optionals are only problematic on types that are not already nullable (i.e. I think the check should be called Regarding the options:
Being added as a collaborator could be cool. I can't make any promises regarding my activity in the future though. |
You are now a collaborator 👍 Let's go with You can merge whenever you are happy with this check. |
Welcome to the team! |
Thanks. :) Are you sure about the name? Like I mentioned, this is not really about assignment, it's about default values. What happens to the redundancy check (specifying both |
Sorry my bad, I mean to say |
I think allowNullDefaults = false? should cover redundancy check (specifying both = null and ?) |
I have started documenting all the checks sometime back. If you guys have gitbboks account I can add as collaborators there as well. |
@adireddy I now do, signed up with GitHub so same account name. |
I signed up for an account when you moved docs to gitbook, but it didn't allow me to edit, so I didn't pursue it further. |
Awesome. Just added both of you. |
Gonna start with a fresh branch for this. |
No description provided.