-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Refactoring: fix SonarQube issues in populateMap() #990
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
Refactoring: fix SonarQube issues in populateMap() #990
Conversation
for JSONObject#populateMap
|
| } | ||
|
|
||
| private static String getKeyNameFromMethod(Method method) { | ||
| if (!isValidMethod(method)) { |
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.
Method validation now requires two function calls: getKeyNameFromMethod() and isValidMethod(). Also, the validation check is performed twice, in isValidMethod(), and in populateMap() with the key check. The call to isValidMethod() could be moved back up to the original location in populateMap(). This will help restore a bit of performance without losing all of the cognitive load improvements.
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 am not 100% sure, how you want to build it.
moving the extracted method isValidMethod() back into the for loop of populateMap() would either indent everything back into an if-statement, which I removed. And reintroducing it would increase the cognitive load again. Or it would introduce an early exit continue; into the for loop, which would be bad for performance as it introduces an unpredictable jump. I tried to avoid both.
|
@Simulant87 Thanks for working on this issue. One minor comment, otherwise looks good. |
|
What problem does this code solve? Note: There is an outstanding comment. If the submitter can't make the update, the code will be merged anyway, and I will add a follow-up PR to fix it. Does the code still compile with Java6? Risks Changes to the API? Will this require a new release? Should the documentation be updated? Does it break the unit tests? Was any code refactored in this commit? Review status Starting 3-day comment window |
|
I think I could have a look at it maybe tomorrow. But you could as well merge it already and I could create another PR. |



#984