|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--rj.tools.jcsc.JavaCodingStandardChecker
This JavaCC grammar and program are to check Java source against specific rules
Field Summary | |
Token |
jj_nt
|
boolean |
lookingAhead
|
static java.util.ArrayList |
sAuthors
|
static int |
sCCNCount
counter to keep track of CCS (cyclomatic complexity number) |
static rj.tools.jcsc.JavaCodingStandardChecker.CurrentState |
sCurrentState
State of the current class declaration. |
static java.lang.String |
sJVMVersion
jvm spec version |
static java.lang.StringBuffer |
sLastComment
last read comment block |
static java.lang.String |
sLastJavaDoc
last read java doc |
static java.util.ArrayList |
sMethodMetrics
|
static int |
sMethodsCount
counter to keep track of methods |
static int |
sNCSSCount
counter to keep track of NCSS (non commenting source statements) |
static boolean |
sNewLine
true if \n was lexed; has to be set to false on own accord |
static boolean |
sReturn
true if return statement was the last one |
static int |
sSpaceCount
counter to keep track of spaces after statement keyword |
static int |
sUnitTestClassCount
counter to keep track of unit test classes |
static int |
sUnitTestsCount
counter to keep track of unit tests |
static java.util.ArrayList |
sViolations
|
Token |
token
|
JavaCodingStandardCheckerTokenManager |
token_source
|
Constructor Summary | |
JavaCodingStandardChecker(java.io.InputStream stream)
|
|
JavaCodingStandardChecker(JavaCodingStandardCheckerTokenManager tm)
|
|
JavaCodingStandardChecker(java.io.Reader stream)
|
Method Summary | |
void |
AdditiveExpression()
|
void |
AllocationExpression()
|
void |
AndExpression()
|
static void |
appendComment(java.lang.String comment)
|
void |
ArgumentList()
|
void |
Arguments()
|
void |
ArrayDimsAndInits()
|
void |
ArrayInitializer()
|
void |
AssertStatement()
|
void |
AssignmentOperator()
|
void |
Block()
|
void |
BlockStatement()
|
void |
BooleanLiteral()
|
void |
BreakStatement()
|
void |
CastExpression()
|
void |
CastLookahead()
|
void |
CatchBlock()
|
void |
ClassBody()
|
void |
ClassBodyDeclaration()
|
java.lang.String |
ClassDeclaration()
|
void |
CompilationUnit()
THE JAVA LANGUAGE GRAMMAR STARTS HERE * |
void |
ConditionalAndExpression()
|
void |
ConditionalExpression()
|
void |
ConditionalOrExpression()
|
void |
ConstructorDeclaration()
|
void |
ContinueStatement()
|
void |
disable_tracing()
|
void |
DoStatement()
|
void |
EmptyStatement()
|
void |
enable_tracing()
|
void |
EqualityExpression()
|
void |
ExclusiveOrExpression()
|
void |
ExplicitConstructorInvocation()
|
void |
Expression()
|
void |
FieldDeclaration()
|
void |
FinallyBlock()
|
void |
ForInit()
|
Return.FormalParameterReturn |
FormalParameter()
|
int |
FormalParameters()
|
void |
ForStatement()
|
void |
ForUpdate()
|
ParseException |
generateParseException()
|
java.util.List |
getAuthors()
getAuthors - get list of all @authors as
a comma separated string |
int |
getMethodsCount()
getMethodsCount - call this method after a successful
parse to obtain the number of methods |
int |
getNCSS()
getNCSS - get the count of NCSS
non commenting source statements |
Token |
getNextToken()
|
Token |
getToken(int index)
|
int |
getUnitTestClassCount()
getUnitTestClassCount - call this method after a successful
parse to obtain the number of Unit test classes |
int |
getUnitTestsCount()
getUnitTestsCount - call this method after a successful
parse to obtain the number of Unit tests |
java.util.List |
getViolations()
getViolations - call this method after a successful
parse to obtain a List of violations. |
int |
getViolationsCount()
getViolationsCount - call this method after a successful
parse to obtain the number of violations |
static void |
handleComplexLoopExpression(java.lang.StringBuffer pExpression,
int pLine,
int pColumn)
handleComplexLoopExpression checks break condition is based
on an operation rather then on a constant |
static void |
handleConditionalExpression(int pLine,
int pColumn)
handleConditionalExpression checks if cond expression are
allowd or not |
static void |
handleConstructorDeclarationJavaDoc(java.lang.String pDoc,
java.lang.StringBuffer pAccess,
int pParaCount,
java.util.ArrayList pExcpts,
int pLine,
int pColumn)
handleConstructorDeclarationJavaDoc handles the javadoc for
constructor declarations. |
static void |
handleFieldDeclarationJavaDoc(java.lang.String pDoc,
java.lang.StringBuffer pAccess,
int pLine,
int pColumn)
handleFieldDeclarationJavaDoc handles the javadoc for
field declarations. |
static void |
handleJavaDocTagOrder(JavaDocParser pJdp,
int pLine,
int pColumn)
handleJavaDocTagOrder handles if the javadoc tag order correct |
static void |
handleMethodDeclarationJavaDoc(java.lang.String pDoc,
java.lang.StringBuffer pAccess,
java.lang.StringBuffer pReturn,
int pParaCount,
java.util.ArrayList pExcpts,
int pLine,
int pColumn)
handleMethodDeclarationJavaDoc handles the javadoc for
method declarations. |
static void |
handleParaRegExp(java.lang.StringBuffer pAccess,
java.lang.StringBuffer pName,
int pLine,
int pColumn)
Checks if parameter does have the correct prefix |
static void |
handleSpaceAfterMethodName(java.lang.String pName,
int pLine,
int pColumn)
handleSpaceAfterMethodName checks if the space count is not '0'. |
static void |
handleSpaceAfterStatementKeyword(java.lang.String pKind,
int pLine,
int pColumn)
handleSpaceAfterStatementKeyword checks if the space count is not '0'. |
static void |
handleSpaceAroundBinaryExpression(java.lang.String pPlace,
java.lang.String pKind,
int pLine,
int pColumn)
handleSpaceAroundBinaryExpression checks space Around Binary Expression |
static void |
handleStringLiteral(java.lang.String pLiteral,
int pLine,
int pColumn)
handleStringLiteral checks if String literal is allowed |
static void |
handleTypeDeclarationJavaDoc(java.lang.String pDoc,
java.lang.StringBuffer pAccess,
java.lang.String pType,
int pLine,
int pColumn)
handleTypeDeclarationJavaDoc handles the javadoc for
class declarations. |
static void |
handleTypeHeaderExpression(java.lang.StringBuffer pHeader,
int pLine,
int pColumn)
handleTypeHeaderExpression handles if the type (class/i-face) do start
with the correct header |
void |
IfStatement()
|
void |
ImportDeclaration()
|
void |
InclusiveOrExpression()
|
static void |
incrementSpace()
incrementSpace is called by the tokenizer when a space is read |
void |
Initializer()
|
void |
InstanceOfExpression()
|
java.lang.String |
InterfaceDeclaration()
|
void |
InterfaceMemberDeclaration()
|
static boolean |
isRegexpMatch(java.lang.Object regexp,
java.lang.Object value)
isRegexpMatch return whether the regexp matches the value. |
void |
LabeledStatement()
|
void |
Literal()
|
void |
LocalVariableDeclaration()
|
void |
LoopExpression()
|
static void |
main(java.lang.String[] args)
Main - The starting point |
void |
MethodDeclaration()
|
void |
MethodDeclarationLookahead()
|
Return.MethodDeclaratorReturn |
MethodDeclarator()
|
void |
MultiplicativeExpression()
|
java.lang.StringBuffer |
Name()
|
java.util.ArrayList |
NameList()
|
void |
NestedClassDeclaration()
|
void |
NestedInterfaceDeclaration()
|
void |
NullLiteral()
|
static void |
overviewClassResults()
During parsing global issues are checked whose result is here generated |
void |
PackageDeclaration()
|
void |
parse()
parse - do the parsing!!! |
void |
PostfixExpression()
|
void |
PreDecrementExpression()
|
void |
PreIncrementExpression()
|
void |
PrimaryExpression()
|
java.lang.StringBuffer |
PrimaryPrefix()
|
java.lang.StringBuffer |
PrimarySuffix()
|
java.lang.StringBuffer |
PrimitiveType()
|
void |
ReInit(java.io.InputStream stream)
|
void |
ReInit(JavaCodingStandardCheckerTokenManager tm)
|
void |
ReInit(java.io.Reader stream)
|
void |
RelationalExpression()
|
static void |
resetNewLine()
resetNewLine resets the new line flag to false |
static void |
resetSpaceCount()
resetSpaceCount resets the current space count to '0' |
java.lang.StringBuffer |
ResultType()
|
void |
ReturnStatement()
|
void |
setFileName(java.lang.String fileName)
setFileName - set the absolute path of the file
to be parsed |
static void |
setLastJavaDoc(java.lang.String doc)
setLastJavaDoc set the last JavaDoc of the current class |
static void |
setNewLine()
setNewLine resets the new line flag to true |
void |
setResultsFormatter(ResultsFormatter resultsFormatter)
setResultsFormatter - set the resulsthander to handle
the violations. |
void |
setRules(java.util.Map cache)
Set the checking rules according to a property file |
void |
ShiftExpression()
|
void |
SpecialStatementBlock(java.lang.String pKind)
|
void |
Statement()
|
void |
StatementExpression()
|
void |
StatementExpressionList()
|
boolean |
SwitchLabel()
|
void |
SwitchStatement()
|
void |
SynchronizedStatement()
|
void |
ThrowStatement()
|
void |
TryStatement()
|
java.lang.StringBuffer |
Type()
|
java.lang.String |
TypeDeclaration()
|
void |
UnaryExpression()
|
void |
UnaryExpressionNotPlusMinus()
|
java.lang.String |
UnmodifiedClassDeclaration(java.lang.StringBuffer pAccess)
|
java.lang.String |
UnmodifiedInterfaceDeclaration(java.lang.StringBuffer pAccess)
|
java.lang.StringBuffer |
VariableDeclarator()
|
java.lang.StringBuffer |
VariableDeclaratorId()
|
void |
VariableInitializer()
|
void |
WhileStatement()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static java.util.ArrayList sAuthors
public static java.util.ArrayList sViolations
public static java.util.ArrayList sMethodMetrics
public static java.lang.String sJVMVersion
public static java.lang.String sLastJavaDoc
public static java.lang.StringBuffer sLastComment
public static int sSpaceCount
public static int sUnitTestClassCount
public static int sUnitTestsCount
public static int sMethodsCount
public static int sNCSSCount
public static int sCCNCount
public static boolean sReturn
public static boolean sNewLine
public static rj.tools.jcsc.JavaCodingStandardChecker.CurrentState sCurrentState
public JavaCodingStandardCheckerTokenManager token_source
public Token token
public Token jj_nt
public boolean lookingAhead
Constructor Detail |
public JavaCodingStandardChecker(java.io.InputStream stream)
public JavaCodingStandardChecker(java.io.Reader stream)
public JavaCodingStandardChecker(JavaCodingStandardCheckerTokenManager tm)
Method Detail |
public static void main(java.lang.String[] args)
args
- a String[]
value - the argumentspublic void parse()
parse
- do the parsing!!!public java.util.List getViolations()
getViolations
- call this method after a successful
parse to obtain a List of violations. The violations are sorted
accorind to the configuration.int
valuepublic int getViolationsCount()
getViolationsCount
- call this method after a successful
parse to obtain the number of violationsint
valuepublic int getUnitTestClassCount()
getUnitTestClassCount
- call this method after a successful
parse to obtain the number of Unit test classesint
valuepublic int getUnitTestsCount()
getUnitTestsCount
- call this method after a successful
parse to obtain the number of Unit testsint
valuepublic int getMethodsCount()
getMethodsCount
- call this method after a successful
parse to obtain the number of methodsint
valuepublic java.util.List getAuthors()
getAuthors
- get list of all @authors as
a comma separated stringList
valuepublic int getNCSS()
getNCSS
- get the count of NCSS
non commenting source statementsStirng
valuepublic void setResultsFormatter(ResultsFormatter resultsFormatter)
setResultsFormatter
- set the resulsthander to handle
the violations. The results handler uses the output stream.resultsFormatter
- a ResultsFormatter
valuepublic void setFileName(java.lang.String fileName)
setFileName
- set the absolute path of the file
to be parsedfileName
- a String
valuepublic void setRules(java.util.Map cache)
public static boolean isRegexpMatch(java.lang.Object regexp, java.lang.Object value)
isRegexpMatch
return whether the regexp matches the value.
toString() is called on either of the parameters to get the string representationregexp
- a Object
valuevalue
- a Object
valueboolean
valuepublic static void handleTypeHeaderExpression(java.lang.StringBuffer pHeader, int pLine, int pColumn)
handleTypeHeaderExpression
handles if the type (class/i-face) do start
with the correct headerpHeader
- a StringBuffer
valuepLine
- an int
valuepColumn
- an int
valuepublic static void handleParaRegExp(java.lang.StringBuffer pAccess, java.lang.StringBuffer pName, int pLine, int pColumn)
pName
- a value of type 'StringBuffer'pLine
- a value of type 'int'public static void overviewClassResults()
public static void incrementSpace()
incrementSpace
is called by the tokenizer when a space is readpublic static void resetSpaceCount()
resetSpaceCount
resets the current space count to '0'public static void resetNewLine()
resetNewLine
resets the new line flag to falsepublic static void setNewLine()
setNewLine
resets the new line flag to truepublic static void setLastJavaDoc(java.lang.String doc)
setLastJavaDoc
set the last JavaDoc of the current classpublic static void appendComment(java.lang.String comment)
public static void handleSpaceAfterStatementKeyword(java.lang.String pKind, int pLine, int pColumn)
handleSpaceAfterStatementKeyword
checks if the space count is not '0'.pLine
- an int
value is current line numberpKind
- a String
value is the type of the statementpublic static void handleSpaceAfterMethodName(java.lang.String pName, int pLine, int pColumn)
handleSpaceAfterMethodName
checks if the space count is not '0'.pLine
- an int
value is current line numberpKind
- a String
value is the type of the statementpublic static void handleSpaceAroundBinaryExpression(java.lang.String pPlace, java.lang.String pKind, int pLine, int pColumn)
handleSpaceAroundBinaryExpression
checks space Around Binary ExpressionpLine
- an int
value is the current line numberpPlace
- a String
value indicates BEFORE_BINARY or AFTER_BINARYpKind
- a String
value is the type of the binary expressionpublic static void handleStringLiteral(java.lang.String pLiteral, int pLine, int pColumn)
handleStringLiteral
checks if String literal is allowedpLine
- an int
value is the current line numberpLiteral
- a String
value is the string literlpublic static void handleComplexLoopExpression(java.lang.StringBuffer pExpression, int pLine, int pColumn)
handleComplexLoopExpression
checks break condition is based
on an operation rather then on a constantpExpression
- a StringBuffer
value is the complex loop exprpLine
- a int
line numberpColumn
- an int
column numberpublic static void handleConditionalExpression(int pLine, int pColumn)
handleConditionalExpression
checks if cond expression are
allowd or notpLine
- a int
line numberpColumn
- an int
column numberpublic static void handleTypeDeclarationJavaDoc(java.lang.String pDoc, java.lang.StringBuffer pAccess, java.lang.String pType, int pLine, int pColumn)
handleTypeDeclarationJavaDoc
handles the javadoc for
class declarations.pDoc
- a String
valuepAccess
- a StringBuffer
valuepType
- a String
valuepublic static void handleConstructorDeclarationJavaDoc(java.lang.String pDoc, java.lang.StringBuffer pAccess, int pParaCount, java.util.ArrayList pExcpts, int pLine, int pColumn)
handleConstructorDeclarationJavaDoc
handles the javadoc for
constructor declarations.doc
- a String
valuepublic static void handleMethodDeclarationJavaDoc(java.lang.String pDoc, java.lang.StringBuffer pAccess, java.lang.StringBuffer pReturn, int pParaCount, java.util.ArrayList pExcpts, int pLine, int pColumn)
handleMethodDeclarationJavaDoc
handles the javadoc for
method declarations.doc
- a String
valuepublic static void handleFieldDeclarationJavaDoc(java.lang.String pDoc, java.lang.StringBuffer pAccess, int pLine, int pColumn)
handleFieldDeclarationJavaDoc
handles the javadoc for
field declarations.doc
- a String
valuepublic static void handleJavaDocTagOrder(JavaDocParser pJdp, int pLine, int pColumn)
handleJavaDocTagOrder
handles if the javadoc tag order correctpJdp
- a JavaDocParser
valuepLine
- an int
valuepColumn
- an int
valuepublic final void CompilationUnit() throws ParseException
public final void PackageDeclaration() throws ParseException
public final void ImportDeclaration() throws ParseException
public final java.lang.String TypeDeclaration() throws ParseException
public final java.lang.String ClassDeclaration() throws ParseException
public final java.lang.String UnmodifiedClassDeclaration(java.lang.StringBuffer pAccess) throws ParseException
public final void ClassBody() throws ParseException
public final void NestedClassDeclaration() throws ParseException
public final void ClassBodyDeclaration() throws ParseException
public final void MethodDeclarationLookahead() throws ParseException
public final java.lang.String InterfaceDeclaration() throws ParseException
public final void NestedInterfaceDeclaration() throws ParseException
public final java.lang.String UnmodifiedInterfaceDeclaration(java.lang.StringBuffer pAccess) throws ParseException
public final void InterfaceMemberDeclaration() throws ParseException
public final void FieldDeclaration() throws ParseException
public final java.lang.StringBuffer VariableDeclarator() throws ParseException
public final java.lang.StringBuffer VariableDeclaratorId() throws ParseException
public final void VariableInitializer() throws ParseException
public final void ArrayInitializer() throws ParseException
public final void MethodDeclaration() throws ParseException
public final Return.MethodDeclaratorReturn MethodDeclarator() throws ParseException
public final int FormalParameters() throws ParseException
public final Return.FormalParameterReturn FormalParameter() throws ParseException
public final void ConstructorDeclaration() throws ParseException
public final void ExplicitConstructorInvocation() throws ParseException
public final void Initializer() throws ParseException
public final java.lang.StringBuffer Type() throws ParseException
public final java.lang.StringBuffer PrimitiveType() throws ParseException
public final java.lang.StringBuffer ResultType() throws ParseException
public final java.lang.StringBuffer Name() throws ParseException
public final java.util.ArrayList NameList() throws ParseException
public final void Expression() throws ParseException
public final void AssignmentOperator() throws ParseException
public final void ConditionalExpression() throws ParseException
public final void ConditionalOrExpression() throws ParseException
public final void ConditionalAndExpression() throws ParseException
public final void InclusiveOrExpression() throws ParseException
public final void ExclusiveOrExpression() throws ParseException
public final void AndExpression() throws ParseException
public final void EqualityExpression() throws ParseException
public final void InstanceOfExpression() throws ParseException
public final void RelationalExpression() throws ParseException
public final void ShiftExpression() throws ParseException
public final void AdditiveExpression() throws ParseException
public final void MultiplicativeExpression() throws ParseException
public final void UnaryExpression() throws ParseException
public final void PreIncrementExpression() throws ParseException
public final void PreDecrementExpression() throws ParseException
public final void UnaryExpressionNotPlusMinus() throws ParseException
public final void CastLookahead() throws ParseException
public final void PostfixExpression() throws ParseException
public final void CastExpression() throws ParseException
public final void PrimaryExpression() throws ParseException
public final java.lang.StringBuffer PrimaryPrefix() throws ParseException
public final java.lang.StringBuffer PrimarySuffix() throws ParseException
public final void Literal() throws ParseException
public final void BooleanLiteral() throws ParseException
public final void NullLiteral() throws ParseException
public final void Arguments() throws ParseException
public final void ArgumentList() throws ParseException
public final void AllocationExpression() throws ParseException
public final void ArrayDimsAndInits() throws ParseException
public final void Statement() throws ParseException
public final void LabeledStatement() throws ParseException
public final void Block() throws ParseException
public final void BlockStatement() throws ParseException
public final void LocalVariableDeclaration() throws ParseException
public final void EmptyStatement() throws ParseException
public final void StatementExpression() throws ParseException
public final void SwitchStatement() throws ParseException
public final boolean SwitchLabel() throws ParseException
public final void SpecialStatementBlock(java.lang.String pKind) throws ParseException
public final void IfStatement() throws ParseException
public final void WhileStatement() throws ParseException
public final void DoStatement() throws ParseException
public final void ForStatement() throws ParseException
public final void ForInit() throws ParseException
public final void LoopExpression() throws ParseException
public final void StatementExpressionList() throws ParseException
public final void ForUpdate() throws ParseException
public final void BreakStatement() throws ParseException
public final void ContinueStatement() throws ParseException
public final void ReturnStatement() throws ParseException
public final void ThrowStatement() throws ParseException
public final void SynchronizedStatement() throws ParseException
public final void TryStatement() throws ParseException
public final void CatchBlock() throws ParseException
public final void FinallyBlock() throws ParseException
public final void AssertStatement() throws ParseException
public void ReInit(java.io.InputStream stream)
public void ReInit(java.io.Reader stream)
public void ReInit(JavaCodingStandardCheckerTokenManager tm)
public final Token getNextToken()
public final Token getToken(int index)
public final ParseException generateParseException()
public final void enable_tracing()
public final void disable_tracing()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |