Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

@faisal-hameed
Copy link

@faisal-hameed faisal-hameed commented Nov 19, 2015

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.

Copy link
Contributor

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") into algorithm == 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

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /