-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Code quality fix - Strings literals should be placed on the left side when checking for equality #1041
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
Closed
faisal-hameed
wants to merge
1
commit into
AsyncHttpClient:master
from
DevFactory:release/strings-literals-should-be-on-left-side
Closed
Code quality fix - Strings literals should be placed on the left side when checking for equality #1041
faisal-hameed
wants to merge
1
commit into
AsyncHttpClient:master
from
DevFactory:release/strings-literals-should-be-on-left-side
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I know this comes from good will, but...
Just applying generic rules without further thought has nothing to do with improving code quality.
Here, specifically:
- Yoda style is everything but readable
- some of the code you suggest to change is already protected against NPE when the parameter is expected to be optional. ex: turning
algorithm == null || algorithm.equals("MD5")intoalgorithm == null || "MD5".equals(algorithm) - trying to blindly change code so that it doesn't crash with an NPE when an expected parameter is missing, but then behave in an unexpected manner is so very dangerous. I'd rather have an NPE, and then decide if it was a bug and that this parameter could rightfully be optional, instead of never being aware that this parameter is sometimes missing, being possibly a user error.
Those qualimetry tools can only raise some warnings that have then to be evaluated in the context of the application and the code. They are by no way silver bullets, and some of their rules are plain BS.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request is focused on resolving occurrences of Sonar rule squid:S1132 - "Strings literals should be placed on the left side".
You can find more information about the issue here: https://dev.eclipse.org/sonar/rules/show/squid:S1132
Please let me know if you have any questions.
Faisal.