#675 invalid "Conditional logic can be removed"

release_1.0
closed
Oliver Burn
5
2013-10-26
2012-04-11
olegvl
No

Checkstyle is reporting problem:
Check.java:10:16: Conditional logic can be removed

for the sample class as follows

public final class Check {
private Check() {
}
public static boolean checkClass(final Class<?> cls) {
if (java.sql.Timestamp.class.isAssignableFrom(cls)) {
return true;
} else if (String.class.isAssignableFrom(cls)) {
return true;
} else {
return false;
}
}
}

Discussion

  • olegvl
    olegvl
    2012-04-11

    samle class

     
    Attachments
  • Roman Ivanov
    Roman Ivanov
    2013-10-26

    • status: open --> closed
    • Group: --> release_1.0
     
  • Roman Ivanov
    Roman Ivanov
    2013-10-26

    Check is right, it demand from you following code:

    public static boolean checkClass(final Class<?> cls) {
    if (java.sql.Timestamp.class.isAssignableFrom(cls)) {
    return true;
    } else {
    return String.class.isAssignableFrom(cls);
    }
    }
    }

    If you still think it is not appropriate ... please welcome to mail-list to discuss or https://github.com/checkstyle/checkstyle/issues