com.puppycrawl.tools.checkstyle.checks.coding

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Code Analyzer » checkstyle » com.puppycrawl.tools.checkstyle.checks.coding 
com.puppycrawl.tools.checkstyle.checks.coding

Contains the Coding checks that are bundled with the main distribution.

Java Source File NameTypeComment
AbstractIllegalCheck.javaClass Support for checks that look for usage of illegal types.
AbstractNestedDepthCheck.javaClass Abstract class which provides helpers functionality for nestedchecks.
AbstractSuperCheck.javaClass

Abstract class for checking that an overriding method with no parameters invokes the super method.

AllTests.javaClass
ArrayTrailingCommaCheck.javaClass

Checks if array initialization contains optional trailing comma.

ArrayTrailingCommaCheckTest.javaClass
AvoidInlineConditionalsCheck.javaClass Detects inline conditionals.
AvoidInlineConditionalsCheckTest.javaClass
CovariantEqualsCheck.javaClass

Checks that if a class defines a covariant method equals, then it defines method equals(java.lang.Object).

CovariantEqualsCheckTest.javaClass
DeclarationOrderCheck.javaClass

Checks that the parts of a class or interface declaration appear in the order suggested by the Code Conventions for the Java Programming Language.

  1. Class (static) variables.
DeclarationOrderCheckTest.javaClass
DefaultComesLastCheck.javaClass

Check that the default is after all the cases in a switch statement.

Rationale: Java allows default anywhere within the switch statement.

DefaultComesLastCheckTest.javaClass
DoubleCheckedLockingCheck.javaClass Detect the double-checked locking idiom, a technique that tries to avoid synchronization overhead but is incorrect because of subtle artifacts of the java memory model.
DoubleCheckedLockingCheckTest.javaClass
EmptyStatementCheck.javaClass

Detects empty statements (standalone ';').

EmptyStatementCheckTest.javaClass
EqualsHashCodeCheck.javaClass

Checks that classes that override equals() also override hashCode().

Rationale: The contract of equals() and hashCode() requires that equal objects have the same hashCode.

EqualsHashCodeCheckTest.javaClass
ExplicitInitializationCheck.javaClass

Checks if any class or object member explicitly initialized to default for its type value (null for object references, zero for numeric types and char and false for boolean.

Rationale: each instance variable gets initialized twice, to the same value.

ExplicitInitializationCheckTest.javaClass
FallThroughCheck.javaClass Checks for fall through in switch statements Finds locations where a case contains Java code - but lacks a break, return, throw or continue statement.

The check honors special comments to suppress warnings about the fall through.

FallThroughCheckTest.javaClass
FinalLocalVariableCheck.javaClass

Ensures that local variables that never get their values changed, must be declared final.

FinalLocalVariableCheckTest.javaClass
HiddenFieldCheck.javaClass

Checks that a local variable or a parameter does not shadow a field that is defined in the same class.

HiddenFieldCheckTest.javaClass
IllegalCatchCheck.javaClass Catching java.lang.Exception, java.lang.Error or java.lang.RuntimeException is almost never acceptable.
IllegalCatchCheckTest.javaClass
IllegalInstantiationCheck.javaClass

Checks for illegal instantiations where a factory method is preferred.

IllegalInstantiationCheckTest.javaClass
IllegalThrowsCheck.javaClass Throwing java.lang.Error or java.lang.RuntimeException is almost never acceptable.
IllegalThrowsCheckTest.javaClass
IllegalTokenCheck.javaClass

Checks for illegal tokens.

Rational: Certain language features are often lead to hard to maintain code or are non-obvious to novice developers.

IllegalTokenCheckTest.javaClass
IllegalTokenTextCheck.javaClass

Checks for illegal token text.

IllegalTokenTextCheckTest.javaClass
IllegalTypeCheck.javaClass

Checks that particular class are never used as types in variable declarations, return values or parameters.

IllegalTypeCheckTest.javaClass
InnerAssignmentCheck.javaClass

Checks for assignments in subexpressions, such as in String s = Integer.toString(i = 2);.

InnerAssignmentCheckTest.javaClass
InputIllegalCatchCheck.javaClass
InputIllegalThrowsCheck.javaClass
InputIllegalType.javaClass
InputJUnitTest.javaClass
InputParameterAssignment.javaClass
InputReturnCount.javaClass
JUnitTestCaseCheck.javaClass Ensures that the setUp(), tearDown()methods are named correctly, have no arguments, return void and are either public or protected.
JUnitTestCaseCheckTest.javaClass
MagicNumberCheck.javaClass

Checks for magic numbers.

MagicNumberCheckTest.javaClass
MissingCtorCheck.javaClass

Checks that classes (except abstract one) define a ctor and don't rely on the default one.

MissingCtorCheckTest.javaClass
MissingSwitchDefaultCheck.javaClass

Checks that switch statement has "default" clause.

Rationale: It's usually a good idea to introduce a default case in every switch statement.

MissingSwitchDefaultCheckTest.javaClass
ModifiedControlVariableCheck.javaClass Check for ensuring that for loop control variables are not modified inside the for block.
ModifiedControlVariableCheckTest.javaClass
MultipleStringLiteralsCheck.javaClass Checks for multiple occurrences of the same string literal within a single file.
MultipleStringLiteralsCheckTest.javaClass
MultipleVariableDeclarationsCheck.javaClass

Checks that each variable declaration is in its own statement and on its own line.

MultipleVariableDeclarationsCheckTest.javaClass
NestedIfDepthCheck.javaClass Restricts nested if-else blocks to a specified depth (default = 1).
NestedIfDepthCheckTest.javaClass
NestedTryDepthCheck.javaClass Restricts nested try-catch-finally blocks to a specified depth (default = 1).
NestedTryDepthCheckTest.javaClass
PackageDeclarationCheck.javaClass Ensures there is a package declaration. Rationale: Classes that live in the null package cannot be imported.
PackageDeclarationCheckTest.javaClass
ParameterAssignmentCheck.javaClass

Disallow assignment of parameters.

Rationale: Parameter assignment is often considered poor programming practice.

ParameterAssignmentCheckTest.javaClass
RedundantThrowsCheck.javaClass Checks for redundant exceptions declared in throws clause such as duplicates, unchecked exceptions or subclasses of another declared exception.
RedundantThrowsCheckTest.javaClass
RequireThisCheck.javaClass

Checks that code doesn't rely on the "this" default. That is references to instance variables and methods of the present object are explicitly of the form "this.varName" or "this.methodName(args)".

Examples of use:

 <module name="RequireThis"/>
 
An example of how to configure to check this qualifier for methods only:
 <module name="RequireThis">
 <property name="checkFields" value="false"/>
 <property name="checkMethods" value="true"/>
 </module>
 

Limitations: I'm not currently doing anything about static variables or catch-blocks.

RequireThisCheckTest.javaClass
ReturnCountCheck.javaClass

Restricts return statements to a specified count (default = 2).

ReturnCountCheckTest.javaClass
SimplifyBooleanExpressionCheck.javaClass

Checks for overly complicated boolean expressions.

SimplifyBooleanExpressionCheckTest.javaClass
SimplifyBooleanReturnCheck.javaClass

Checks for overly complicated boolean return statements.

SimplifyBooleanReturnCheckTest.javaClass
StringLiteralEqualityCheck.javaClass

Checks that string literals are not used with == or !=.

StringLiteralEqualityCheckTest.javaClass
SuperCloneCheck.javaClass

Checks that an overriding clone() method invokes super.clone().

SuperCloneCheckTest.javaClass
SuperFinalizeCheck.javaClass

Checks that an overriding finalize() method invokes super.finalize().

SuperFinalizeCheckTest.javaClass
UnnecessaryParenthesesCheck.javaClass

Checks if unnecessary parentheses are used in a statement or expression. The check will flag the following with warnings:

 return (x);          // parens around identifier
 return (x + 1);      // parens around return value
 int x = (y / 2 + 1); // parens around assignment rhs
 for (int i = (0); i < 10; i++) {  // parens around literal
 t -= (z + 1);        // parens around assignment rhs

The check is not "type aware", that is to say, it can't tell if parentheses are unnecessary based on the types in an expression.

UnnecessaryParenthesesCheckTest.javaClass Test fixture for the UnnecessaryParenthesesCheck.
author:
   Eric K.
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.