Thursday, September 19, 2013

SevNTU Checkstyle version 1.9.0

SevNTU Checkstyle Release 1.9.0 (18/September/2013):

About project and previous releases:
To Discuss:!forum/sevntu-checkstyle

New in 1.9.0:

AvoidConstantAsFirstOperandInConditionCheck -  Avoid Constant As First Operand In Condition. If comparing values, C(C++) developers prefer to put the constant first in the equality check, to prevent situations of assignment rather than equality checking. But in Java, in IF condition it is impossible to use assignment, so that habit become unnecessary and do damage readability of code.
if (null == varialble)"
should be
if (varialble == null)"

Done by Sergey Burtsev.  More

EitherLogOrThrowException -  Either log the exception, or throw it, but never do both. Logging and throwing results in multiple log messages for a single problem in the code, and makes problems for the support engineer who is trying to dig through the logs. This is one of the most annoying error-handling antipatterns.
       catch (NoSuchMethodException e) {
          LOG.error("Blah", e);
          throw e;

Done by Baratali Izmailov.  More

ForbidWildcardAsReturnTypeCheck -  Do not use wildcard types as return types. Rather than providing additional flexibility for your users, it would force them to use wildcard types in client code. Properly used, wildcard types are nearly invisible to users of a class. They cause methods to accept the parameters they should accept and reject those they should reject. If the user of a class has to think about wildcard types, there is probably something wrong with the class’s API.
public <T> List<? extends T> getValues()

Done by Baratali Izmailov.  More

NoNullForCollectionReturnCheck -  Check detect when method, that must return array or collection, return null value instead of empty collection or empty array.
public List<String> metValues() { return null; }

Done by Ilja Dubinin.  More

ConfusingConditionCheck -  This check prevents negation within an "if" expression if "else" is present.
For example, rephrase:
if (x != y) smth1(); else smth2(); 
if (x == y) smth2(); else smth1(); 

Done by Vadim Panasiuk.  More

NoMainMethodInAbstractClassCheck -  Forbids main methods in abstract classes. Rationale: existance of 'main' method can mislead a developer to consider this class as a ready-to-use implementation.
         abstract class AbstractUiJob {
             public static void main(String args[]){ ... } 

Done by Baratali Izmailov.  More

SimpleAccessorNameNotationCheck -  Check only direct fields and setter and getter. Options: 1) member prefix "m_" 2) check only simple getter/setter XXXType getXXXName(); void setXXXName(XXXType).
private String value; 
void setValue(String val) { this.value = val;}

Reimplemented and fixed by Ilja Dubinin.  More

AbbreviationAsWordInNameCheck -  problem detection of 2 char abbreviation with length limit 1 was fixed.
int scaleX;

Done by Baratali Izmailov.  More

No comments:

Post a Comment