Move constants to right side in comparisons. #1555

Fixes ` ConstantOnLHSOfComparison` inspection violations.

Description:
>Reports on comparison operations with constant values on their left-hand side. Some coding conventions specify that constants should be on the right-hand side of comparisons.
This commit is contained in:
Michal Kordas 2015-08-11 22:48:18 +02:00 committed by Roman Ivanov
parent 0da6b95ae7
commit ba9639e5de
1 changed files with 4 additions and 4 deletions

View File

@ -351,7 +351,7 @@ public final class AnnotationUseStyleCheck extends Check {
* @param annotation the annotation token
*/
private void checkTrailingComma(final DetailAST annotation) {
if (TrailingArrayComma.IGNORE == comma) {
if (comma == TrailingArrayComma.IGNORE) {
return;
}
@ -405,18 +405,18 @@ public final class AnnotationUseStyleCheck extends Check {
* @param ast the annotation token
*/
private void checkCheckClosingParens(final DetailAST ast) {
if (ClosingParens.IGNORE == parens) {
if (parens == ClosingParens.IGNORE) {
return;
}
final DetailAST paren = ast.getLastChild();
final boolean parenExists = paren.getType() == TokenTypes.RPAREN;
if (ClosingParens.ALWAYS == parens
if (parens == ClosingParens.ALWAYS
&& !parenExists) {
log(ast.getLineNo(), MSG_KEY_ANNOTATION_PARENS_MISSING);
}
else if (ClosingParens.NEVER == parens
else if (parens == ClosingParens.NEVER
&& !ast.branchContains(TokenTypes.EXPR)
&& !ast.branchContains(TokenTypes.ANNOTATION_MEMBER_VALUE_PAIR)
&& !ast.branchContains(TokenTypes.ANNOTATION_ARRAY_INIT)