Skip to content

Commit

Permalink
Sonar violation: Tabulation characters should not be used
Browse files Browse the repository at this point in the history
Pull #326
  • Loading branch information
damianszczepanik committed Mar 1, 2015
1 parent f5497d6 commit 1202787
Show file tree
Hide file tree
Showing 21 changed files with 150 additions and 150 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@

public class ForbidAnnotationCheck extends Check
{
/**
* A key is used to retrieve check message from 'messages.properties' file
*/

/**
* A key is used to retrieve check message from 'messages.properties' file
*/
public static final String MSG_KEY = "annotation.incorrect.target";

/**
* annotationNames is set of annotation's names.
*/
Expand Down Expand Up @@ -110,14 +110,14 @@ && isForbiddenAnnotationTarget(targetType))
}

private static String getAnnotationName(DetailAST annotation){
DetailAST directname = annotation.findFirstToken(TokenTypes.IDENT);

if(directname != null){
return directname.getText();
}else{
//This means that annotation is specified with the full package name
return annotation.findFirstToken(TokenTypes.DOT).getLastChild().getText();
}
DetailAST directname = annotation.findFirstToken(TokenTypes.IDENT);

if(directname != null){
return directname.getText();
}else{
//This means that annotation is specified with the full package name
return annotation.findFirstToken(TokenTypes.DOT).getLastChild().getText();
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
*/
public class AvoidConstantAsFirstOperandInConditionCheck extends Check {

public final static String MSG_KEY = "avoid.constant.as.first.operand.in.condition";
public final static String MSG_KEY = "avoid.constant.as.first.operand.in.condition";

/**
* targetConstantTypes is array of default target constant types.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
*/
public class AvoidDefaultSerializableInInnerClasses extends Check
{
public static final String MSG_KEY = "avoid.default.serializable.in.inner.classes";

public static final String MSG_KEY = "avoid.default.serializable.in.inner.classes";

/**
*<b>
*Option, that allow partial implementation of serializable interface.
Expand Down Expand Up @@ -191,8 +191,8 @@ public static ChildrenIterator methodsIterator(DetailAST parent)
*</b>
*@return boolean value
*/
public boolean hasNext()

public boolean hasNext()
{
return next != null;
}
Expand All @@ -203,8 +203,8 @@ public boolean hasNext()
*</b>
*@return next DetailAST.
*/
public DetailAST next()

public DetailAST next()
{
final DetailAST result = next;
while (next != null) {
Expand All @@ -221,8 +221,8 @@ public DetailAST next()
*Not implemented method.
*</b>
*/
public void remove()

public void remove()
{
throw new IllegalStateException("Not implemented");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
*/
public class AvoidHidingCauseExceptionCheck extends Check
{
public static final String MSG_KEY = "avoid.hiding.cause.exception";
public static final String MSG_KEY = "avoid.hiding.cause.exception";

@Override
public int[] getDefaultTokens()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -620,15 +620,15 @@ else if (currentRule.hasRule(MAIN_METHOD_MACRO)) {
}
}
else {
// if more than one rule matches current AST node, then keep first one
// if more than one rule matches current AST node, then keep first one
result = (result == -1) ? index : result;
if (ast.getType() == TokenTypes.METHOD_DEF
|| ast.getType() == TokenTypes.VARIABLE_DEF)
|| ast.getType() == TokenTypes.VARIABLE_DEF)
{
// continue to find more specific rule
continue;
// continue to find more specific rule
continue;
} else {
break;
break;
}
}
}
Expand Down Expand Up @@ -722,7 +722,7 @@ private boolean isGetterCorrect(DetailAST methodDef, String methodPrefix)
final DetailAST exprAst = returnStatementAst.getFirstChild();
final String returnedFieldName = getNameOfGetterField(exprAst);
if (returnedFieldName != null
&& !localVariableHidesField(statementsAst, returnedFieldName)
&& !localVariableHidesField(statementsAst, returnedFieldName)
&& verifyFieldAndMethodName(returnedFieldName, methodNameWithoutPrefix))
{
result = true;
Expand All @@ -733,20 +733,20 @@ && verifyFieldAndMethodName(returnedFieldName, methodNameWithoutPrefix))
return result;
}

private static boolean localVariableHidesField(DetailAST slist,
String fieldName) {
boolean result = false;
DetailAST currNode = slist.getFirstChild();
while (currNode != null) {
if (currNode.getType() == TokenTypes.VARIABLE_DEF
&& fieldName.equals(getIdentifier(currNode))) {
result = true;
break;
}
currNode = currNode.getNextSibling();
}
return result;
}
private static boolean localVariableHidesField(DetailAST slist,
String fieldName) {
boolean result = false;
DetailAST currNode = slist.getFirstChild();
while (currNode != null) {
if (currNode.getType() == TokenTypes.VARIABLE_DEF
&& fieldName.equals(getIdentifier(currNode))) {
result = true;
break;
}
currNode = currNode.getNextSibling();
}
return result;
}

/**
* Returns true when setter is correct. Correct setter is method that has one parameter,
Expand All @@ -772,7 +772,7 @@ private boolean isSetterCorrect(DetailAST methodDefAst, String methodPrefix)
final DetailAST statementsAst = methodDefAst.findFirstToken(TokenTypes.SLIST);

result = statementsAst != null
&& !localVariableHidesField(statementsAst, setterFieldName)
&& !localVariableHidesField(statementsAst, setterFieldName)
&& isFieldUpdate(statementsAst, setterFieldName);
}
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@ public void visitToken(DetailAST variableDefNode) {

if (assignNode != null) {

DetailAST newNode = assignNode.getFirstChild().getFirstChild();
DetailAST newNode = assignNode.getFirstChild().getFirstChild();

if (newNode.getType() == TokenTypes.LITERAL_NEW
&& newNode.getLastChild().getType() != TokenTypes.OBJBLOCK) {
DetailAST typeArgs = newNode.findFirstToken(TokenTypes.TYPE_ARGUMENTS);
if (typeArgs != null && isSameTypeArgsInVariableDef(variableDefNode, typeArgs)) {
log(typeArgs, MSG_KEY);
}
}
if (newNode.getType() == TokenTypes.LITERAL_NEW
&& newNode.getLastChild().getType() != TokenTypes.OBJBLOCK) {

DetailAST typeArgs = newNode.findFirstToken(TokenTypes.TYPE_ARGUMENTS);
if (typeArgs != null && isSameTypeArgsInVariableDef(variableDefNode, typeArgs)) {
log(typeArgs, MSG_KEY);
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
*/
public class FinalizeImplementationCheck extends Check
{

/**
* The key is pointing to the warning message text in "messages.properties"
* file.
Expand Down Expand Up @@ -97,12 +97,12 @@ public int[] getDefaultTokens()
public void visitToken(DetailAST methodDefToken)
{
if (isFinalizeMethodSignature(methodDefToken)) {
String warningMessage = validateFinalizeMethod(methodDefToken);
if (warningMessage != null) {
log(methodDefToken.getLineNo(), warningMessage);
}

String warningMessage = validateFinalizeMethod(methodDefToken);
if (warningMessage != null) {
log(methodDefToken.getLineNo(), warningMessage);
}
}
}

Expand All @@ -115,7 +115,7 @@ public void visitToken(DetailAST methodDefToken)
*/
private static String validateFinalizeMethod(DetailAST finalizeMethodToken)
{
String warningMessage = null;
String warningMessage = null;
if (hasModifier(TokenTypes.LITERAL_PROTECTED, finalizeMethodToken)) {
DetailAST methodOpeningBrace = finalizeMethodToken.getLastChild();
DetailAST literalTry = methodOpeningBrace.findFirstToken(TokenTypes.LITERAL_TRY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
*/
public class ForbidCCommentsInMethods extends Check
{
/*
* Warning message key
*/
public final static String MSG_KEY = "forbid.c.comments.in.the.method.body";
/**
* Warning message key
*/
public final static String MSG_KEY = "forbid.c.comments.in.the.method.body";

/**
* Set contains C style comments from current file
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public void visitToken(DetailAST ast)
break;
case TokenTypes.IMPORT:
if (packageMatches && forbiddenImportsRegexp != null
&& forbiddenImportsExcludesRegexp != null)
&& forbiddenImportsExcludesRegexp != null)
{
final String importQualifiedText = getText(ast);
if (isImportForbidden(importQualifiedText)) {
Expand All @@ -181,9 +181,9 @@ public void visitToken(DetailAST ast)
break;
case TokenTypes.LITERAL_NEW:
if (forbiddenImportsRegexp != null
&& forbiddenImportsExcludesRegexp != null
&& ast.findFirstToken(TokenTypes.DOT) != null
&& packageMatches)
&& forbiddenImportsExcludesRegexp != null
&& ast.findFirstToken(TokenTypes.DOT) != null
&& packageMatches)
{
final String importQualifiedText = getText(ast);
if (isImportForbidden(importQualifiedText)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* <p>
* <code><pre>
* catch (Exception e) {
* throw new RuntimeException() { //WARNING
* throw new RuntimeException() { //WARNING
* //some code
* };
* }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
*/
public final class IllegalCatchExtendedCheck extends AbstractIllegalCheck
{
/**
* Warning message key.
*/
public static final String MSG_KEY = "illegal.catch";
/**
* Warning message key.
*/
public static final String MSG_KEY = "illegal.catch";

/** disable warnings for "catch" blocks containing
* throwing an exception. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
*/
public class LogicConditionNeedOptimizationCheck extends Check
{
public static final String MSG_KEY = "logic.condition.need.optimization";
public static final String MSG_KEY = "logic.condition.need.optimization";

@Override
public int[] getDefaultTokens()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@
*/
public class NoNullForCollectionReturnCheck extends Check
{
/**
* Warning message key.
*/
public static final String MSG_KEY = "no.null.for.collections";
/**
* Warning message key.
*/
public static final String MSG_KEY = "no.null.for.collections";

/**
* <p>
* Default list of collection implementing classes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,12 @@ private void logWarnings(final DetailAST detailAST, final String key)
if (hasModifier(methodDef, TokenTypes.LITERAL_PRIVATE)
|| hasModifier(methodDef, TokenTypes.FINAL))
{
log(om.metCallAST, MSG_KEY_LEADS, getMethodName(om.metCallAST),
log(om.metCallAST, MSG_KEY_LEADS, getMethodName(om.metCallAST),
key, om.overridableMetName);
} else {
log(om.metCallAST, MSG_KEY, getMethodName(om.metCallAST),
log(om.metCallAST, MSG_KEY, getMethodName(om.metCallAST),
key, om.overridableMetName);
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@
* @author Ivan Sopov
*/
public class ReturnBooleanFromTernary extends Check {

/**
* Warning message key.
*/
public final static String MSG_KEY = "return.boolean.ternary";

@Override
public int[] getDefaultTokens() {
return new int[] { TokenTypes.QUESTION };
}

@Override
public void visitToken(DetailAST ast) {
DetailAST secondBranch = ast.getLastChild();
DetailAST firstBranch = secondBranch.getPreviousSibling().getPreviousSibling();
if ("true".equals(secondBranch.getText()) || "false".equals(secondBranch.getText())
|| "true".equals(firstBranch.getText()) || "false".equals(firstBranch.getText())) {
log(ast, "return.boolean.ternary");
}
}
/**
* Warning message key.
*/
public final static String MSG_KEY = "return.boolean.ternary";

@Override
public int[] getDefaultTokens() {
return new int[] { TokenTypes.QUESTION };
}

@Override
public void visitToken(DetailAST ast) {
DetailAST secondBranch = ast.getLastChild();
DetailAST firstBranch = secondBranch.getPreviousSibling().getPreviousSibling();
if ("true".equals(secondBranch.getText()) || "false".equals(secondBranch.getText())
|| "true".equals(firstBranch.getText()) || "false".equals(firstBranch.getText())) {
log(ast, "return.boolean.ternary");
}
}
}
Loading

0 comments on commit 1202787

Please sign in to comment.