Many classes are prone to NPEs #1300
manticore-projects
started this conversation in
Ideas
Replies: 1 comment
-
This works for constructor initialization only classes. For the other ones make this in setters is not enough, since there are many combinations of parameters including some set to null. This one should go into the validators as well, I think. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When implementing the Statement Classifications I looked into a few classes, which can easily throw NPEs because they do not enforce proper initiation:
Testing
TimezoneExpression
Example
TimezoneExpression
We do not enforce setting
leftExpression
and we also do not check if it is set intoString()
or in theDeparser
. Of course I do understand that this is unlikely to happen because the Parser will callsetLeftExpression()
during parsing. Nevertheless I do not think that this approach is clean.Instead I would like to suggest a refactoring into something like
What do you think about please?
We have many of similar classes, please see the attached Test Case. I would like to recommend and volunteer refactoring those -- but of course only, when there is no counter argument and the effort was welcome.
Cheers.
ErrorTest0.zip
Beta Was this translation helpful? Give feedback.
All reactions