Fork me on GitHub

Sevntu-Checkstyle

By students from around the world.
Licence is GNU LESSER GENERAL PUBLIC LICENSE Version 2.1.

Description

Main idea of Checkstyle project is to automate and to ease code-review process; to assist developers in complying with the company's Code-standard, and allow them to fix and eliminate any minor problem upon just saving the file. We are strongly convinced that it is much more easier and convenient to catch minor traps in code during writing than after committing/pushing. This project contains a number of Checks that can help program engineers to write code in a uniform style, which makes it easier for the whole team of programmers to review the code, also significantly improves the low threshold of understanding for new developers.

This project is additional(non-standard) checks for Checkstyle that are compiled as extension to maven-checkstyle-plugin, Sonar Checkstyle Plugin, CheckStyle-IDEA, Checkstyle Eclipse plugin, see Distribution chapter for more details.

This project is incubator for Checkstyle checks that are not present in main stream of Checkstyle project. If you have a check and need place to be build-in, let us know.
If you want to study Java(with mentoring) and help us develop some Checks let us know, we are looking for new maintainers and level of Java experience does not matter.

We offer diversity of nonstandard Checks and each developer's group chooses what to use to satisfy their code-standard needs.

Contact

Roman Ivanov: ivanov-jr[*]mail[*]ru

Discussion group

Homepage: discussion group

Group email: sevntu-checkstyle[ a ]googlegroups.com

IRC

#sevntu.checkstyle on Freenode

Distribution

- extension to maven-checkstyle-plugin (how to use: in general, maven example, ant example).
- extension to Sonar Checkstyle Plugin (how to use: in general).
- extension to CheckStyle-IDEA (how to use: in general).
- extension to Checkstyle Eclipse plugin how to use: install from EclipseCS “update site” or use our update site http://sevntu-checkstyle.github.com/sevntu.checkstyle/update-site/ (do not use this link in Browser, it will return 404 code, it is expected, but it will work well through Eclipse menu "Help"->"Install New Software ...")

New and noteworthy

Release 1.12.0 (9/Oct/2014)

Update in Redundant Return Check -  Redundant Return Check was retested and fixed. Done by Alexey Nesterenko. More


Update in ForbidThrowAnonymousExceptionsCheck -  Reduced ForbidThrowAnonymousExceptionsCheck's limitation. Now this Check puts violation on throwing anonymous exception even in case if it is defined before throwing. Done by Alexey Nesterenko. More


Update in LineLengthCheck -  Updated LineLengthCheck to print the current line length in it's warnings. Done by Alexey Nesterenko. More


DiamondOperatorForVariableDefinitionCheck -  This Check highlights variable definition statements where diamond operator could be used. Done by Alexey Nesterenko. More


PublicReferenceToPrivateTypeCheck -  This Check warns on propagation of inner private types to outer classes:
- Externally accessible method if it returns private inner type.
- Externally accessible field if it's type is a private inner type.
These types could be private inner classes, interfaces or enumerations. Done by Alexey Nesterenko. More


TernaryPerExpressionCountCheck -  Replaced existing NestedTernaryCheck with more general TernaryPerExpressionCountCheck.
New Check provides options to ignore ternary sequences with explicitly set priority level (expressions in braces) and also to force Check to ignore ternary operators which are isolated inside a single line. Done by Alexey Nesterenko. More


Update in CustomDeclarationOrderCheck -  Updated Check to treat more king of methods as setters. E.g., now Check treats 'set' method as setter, in cases like:

public void setWorkMode(String workMode) {
this.workMode = WorkMode.valueOf(workMode);
}
public void setUserCache(UserCache userCache) {
super.setUserCache(userCache);
}
public void setY(Integer y) { // setter
this.y = Integer.parseInt(y + "");
}

Done by Alexey Nesterenko. More

Release 1.11.0 (7/May/2014)


Update for CustomDeclarationOrderCheck -  New macros for Fields with assigning to Anonymous classes, macros for Setter/Geter, macros for nested interfaces and nested enumarations macros for "main()" method. Done by Baratali Izmailov. More


EnumValueNameCheck -  Check forces enum values to match the specific pattern. Done by Pavel Baranchikov. More


CheckFinalizeImplementation -  This Check detects 3 most common cases of incorrect finalize() method implementation. Done by Max Vetrenko. More


ForbidThrowAnonymousExceptions -  Forbid throwing anonymous exception. limitation: This Check does not validate cases then Exception object is created before it is thrown. Done by Max Vetrenko. More


MapIterationInForEachLoopCheck -  This check can help you to write the whole for-each map iteration more correctly. Done by Max Vetrenko. More


update in deployment scipt -  Fixed -all mode in deploy.sh. Done by Ashutosh Agarwal. More

Release 1.10.0 (24/Nov/2013)


New project! sevntu-checkstyle-sonar-plugin -  Project was created as extension to Sonar Checkstyle Plugin for SonarQube™, How to use it is described here in detail and pictures, Done by Ruslan Diachenko. More.


New project! sevntu-checkstyle-idea-extension -  Project was created as extension for Checkstyle IDEA plugin for IntelliJ IDEA, How to use it is described here in details and pictures, Done by Vadim Panasiuk. More.


Update for CustomDeclarationOrderCheck -  Inner Classes in methods are ignored. Done by Baratali Izmailov. More


Updates in messages -  Done by Baratali Izmailov, Ilja Dubinin, Vadim Panasiuk. More


Update in VariableDeclarationUsageDistanceCheck -  Update to support block constructions/builders and methods with long list arguments,Done by Baratali Izmailov. More


Update in ConfusingConditionCheck -  Update to skip alarming on sequentional IF, Done by Vadim Panasiuk. More


Update in NoNullForCollectionReturnCheck -  Fix for NullPointerException,Done by Ilja Dubinin. More


Update in ForbidCertainImportsCheck -  additional field as Regexp for excluding imports from checking,Done by Daniil Yaroslavtsev. More


Release 1.9.0 (18/Sept/2013)


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.
Example:
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.
Example:
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.
Example:
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.
Example:
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();
as:
if (x == y) smth2(); else smth1();
Done by Vadim Panasiuk.  More.
Examples of usage and all options description is here.


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.
Example:
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).
Example:
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.
Example:
int scaleX;
Done by Baratali Izmailov.  More

Release 1.8.0 (16/Apr/2012)

NestedTernaryCheck - This check forbids nested ternary operators (with option to ignore final variable initializations except initializations inside C-tors).
Done by Daniil Yaroslavtsev.  (issue)

ForbidReturnInFinalBlockCheck -  This check reports if the finally block contains a return statement.
Done by Vadim Panasiuk.  (issue).

Update for ChildBlockLengthCheck to show current sizes of 'bad' blocks, not only allowed sizes for it.
Done by Daniil Yaroslavtsev.  More

Fixed bugs in AvoidHidingCauseExceptionCheck -  More information: issue.
Done by Ilja Dubinin. 

Fixed bugs in OverridableMethodInConstructorCheck -  More information: issue. Also added new option that allow compare methods by number of their parameters.
Done by Ilja Dubinin.  

Update for ReturnCountCheckExtended -  Now RegExp is used in ignored list of methods.
Done by Alexey Grigorov. 

Release 1.7.0 (15/Nov/2012)

AvoidConstantsInInterfacesCheck -  has been removed as it has been already implemented in standart Checkstyle. Done by Vadym Chekrii. 

Release 1.6.2 (12/Nov/2012)

AbbreviationAsWordInNameCheck - problem with constants in interfaces was fixed. Done by Roman Ivanov.  issue

Release 1.6.1 (29/Oct/2012)

Changes for descriptions for Eclipse plugin for checks that appear in 1.6.0. Done by Ilja Dubinin and Roman Ivanov.

Release 1.6.0 (21/Oct/2012)

LogicConditionNeedOptimizationCheck -  This check prevents the placement of local variables and fields after calling methods in '&&' and '||' conditions. Done by Ilja Dubinin. Patch.

ForbidCCommentsInMetods -  Check prevents usage of C-style (/* ... */) comments inside method body. If you have class declaration inside method body with JavaDoc you will get error too. Done by Ilja Dubinin. Patch.

InterfaceTypeParameterNameCheck -  Checks that interface type parameter(for template) names conform to a format specified by the format property. Default format is ^[A-Z]$. Done by Dmitry Gridyushko. Patch.

Release 1.5.3 (4/Sept/2012)

Internal release for site generation automation, refactoring of projects structure to be more independend from main project and ease code managment and ease new developers unserstanding of project, extension for maven plugin was introduced. Done By Ivan Sopov with help of Ilia Dubinin, Dmitry Gridyushko.

Release 1.5.0 (12/Jun/2012)

AvoidDefaultSerializableInInnerClasses - This check prevents the default implementation Serializable interface in inner classes (Serializable interface are default if methods readObject() or writeObject() are not override in class). Check has option, that allow implementation only one method, if it true, but if it false - class must implement both methods. For more information read "Effective Java (2nd edition)" chapter 11, item 74, page 294. Done by Ilia Dubinin.  issue

IllegalCatchCheck - Minor fix for default values. Done by Daniil Yaroslavtsev. 

Release 1.0.5 (14/Apr/2012)

ChildBlockLengthCheck - Length of child block that is more then 90% of parent block is hard to read in case child block is long(few display screens). Done by Daniil Yaroslavtsev.  issue

AvoidModifiersForTypesCheck - Disallow some set of modifiers (Only 4 types according to Java Spec:static,final, transient, volatile) for specified types, caused by static for ULCComponents. Done by Daniil Yaroslavtsev.  issue

CauseParameterInExceptionCheck - Exception Design Best Practices : Cause now needed as one the parameter in any custom Exception constructor. Done by Daniil Yaroslavtsev.  issue

ForbidsCertainImportsCheck - Forbids certain imports usage. Is similar to the useful check in Sonar project. Done by Daniil Yaroslavtsev.  issue

ForbidInstantiationCheck - Forbids instantiation of certain object types by their full classname. For example: "java.lang.NullPointerException" will forbid the NPE instantiation. Done by Daniil Yaroslavtsev.  issue

ReturnCountExtendedCheck - Checks that method/ctor "return" literal count is not greater than the given value ("maxReturnCount" property). has many useful ignore options. Done by Daniil Yaroslavtsev.  issue

AbbreviationAsWordInNameCheck - XMLReader should be names like XmlReader. Issue for ignoring methods with annotation @Override was fixed. Done by Daniil Yaroslavtsev.  issue

Release 1.0.4 (11/Oct/2011)

ForbidAnnotationCheck - Forbid specific annotation for field/method, e.g. forbid @Autowired annotation for private field. Done by Victor Hidoyatov.  issue

AvoidConstantsInInterfacesCheck - avoid declaration of constants in interfaces. Done by Vladimir Svikhunov.  issue.

AvoidHidingCauseExceptionCheck - hiding Cause exception in throwing new exception. Done by Daniil Yaroslavtsev.  issue.

AvoidNotShortCircuitOperatorsForBooleanCheck - Forbid to use "|", "|=", "&" for boolean/Boolean variables, and force to use "||", .... , explanation link. Example: "boolean b |= returnBoolean()". Done by Daniil Yaroslavtsev.  issue.

IllegalCatchCheck - Options to ignore 1) exact re-throw after logging 2) creation and throw of other Exception base on current exception. Done by Daniil Yaroslavtsev.  issue.

OverridableMethodInConstructorCheck - Do not use protected/public method in C-tor. Use only private and final. Check all call hierarchy from c-tor to avoid: c-tor -> private -> public/protected. Done by Daniil Yaroslavtsev. (issue.

ReturnBooleanFromTernary - It is a bad practice to return boolean values from ternary operations. Just use the value inside branch instead. Done by Ivan Sopov.

ReturnNullInsteadOfBoolean - Arguably it is the matter of style to use Boolean for ternary logic or enum. And since all the information is in the single file and even in the single method, I think that checkstyle is capable of doing this. Done by Ivan Sopov. (issue)

VariableDeclarationUsageDistanceCheck - check distance between declaration of variable and its first usage of it. Options: Allowed distance (in rows); Ignore variable names (regexp). Done by Ruslan Diachenko.  issue

AbbreviationAsWordInNameCheck - XMLReader should be names like XmlReader. Checks names for fields, methods , ....... . Few ignore options. Done by Roman Ivanov. (issue).

Release 1.0.2 (15/Mar/2011)

AvoidNotShortCircuitOperatorsForBooleanCheck - check to force user not to use ShortCircuit operators ("|", "&" for boolean calculations) . Done by Daniil Yaroslavtsev. patch

MultipleStringLiteralsExtendedCheck - extension of the standart check, newoption was added to highlight all duplicated. Done by Yury Balahonov. patch

MultipleVariableDeclarationsExtendedCheck - stndard check + option to ignore while/for. Done by Daniil Yaroslavtsev. patch

UnnecessaryParenthesesExtendedCheck - standart check + option to ignore some arguable cases. Dmitriy Antonenko. patch

Release 1.0.1 (21/Sept/2010)

CustomDeclarationOrderCheck - check to adjust class structure to make it more predictable. Done by Danil Lopatin. acticle in russian patch and example of config

InnerClassCheck - force user to place inner classes at the bottom ofthe class. Done by Ruslan Dyachenko. patch

AbstractClassNameExtendedCheck - extension to check if you named class AbstractXXXXXX then force user to keep it "abstract". Done by Danil Lopatin. patch

LineLengthExtendedCheck - extension of standard check with a lot of ignore option. Done by Ruslan Dyachenko. patch

Examples and ideas

Examples of how to use SevNTU-Checkstyle with Maven, Ant or Gradle you can find at checkstyle-samples repo.

GSOC 2013 ideas

Download

You can download this project in either zip or tar formats.

You can also clone the project with Git by running:

$ git clone git://github.com/sevntu-checkstyle/sevntu.checkstyle