|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
IAuditRule provides common interface for easy extension of
audit plug-ins functionality.
An audit plug-in is a Sapient plug-in that performs a set of source code verifications called audits. To allow for adding new features, audit plug-ins are implemented as easily extensible audit containers, rather than being monolithic libraries.
When an audit plug-in is initialized, it searches the registry for the registered
code analyzers (see IAnalyzerDescriptor).
The plug-in builds the list of audits that have been chosen to run by the user.
In audit plug-ins, audits are represented by a code analyzer. Code analyzers are not
audits themselves; they only contain information necessary to load and instantiate
the described audit. This is the fully qualified of the class that implements the audit,
and the jar library from which it can be loaded. The only specific
requirement for audits is that they must implement the IAuditRule interface.
Once the plug-in has loaded the audits, it builds the internal representation of the
examined source files (called the model). The model is shown to the audits using
the Visitor design pattern. The audits act as visitors; they have a chance
to examine the model elements by overriding the corresponding methods of
the IAuditRule interface.
The main benefit of this mechanism is easy installation of new audits.
New audits can be added by putting their XML manfiset files and jar
libraries into the plug-in directory.
Currently there are three Sapient audit plug-ins: jlint, audit,
and refactor. All of these can be extended using the mechanism described
above.
To achieve higher performance, audits are divided into several groups. Audits from each group examine the particular kind of model elements. The following groups of model elements are defined:
AuditRule constructor. Note that an audit may be member
of multiple groups. It indicates that by OR'ing the corresponding flags.
Audit rule implementations are expected to extend the AuditRule
class that contains stubs for the check methods. In effect,
implementation may override only those methods that are required to perform
necessary actions.
| Field Summary | |
static int |
ALL_GRP
Represents an audit rule that is a member of all the groups. |
static int |
DECLARATION_GRP
Represents an audit rule which examines declarations. |
static int |
EXPRESSION_GRP
Represents an audit rule which examines expressions. |
static int |
STATEMENT_GRP
Represents an audit rule which examines statements. |
static int |
TUPLE_GRP
Represents an audit rule which examines tuples. |
| Method Summary | |
void |
checkArrayCreationExpression(com.togethersoft.sca.plugin.audit.AstArrayCreationExpression expr)
Examines an array creation expression. |
void |
checkArrayInitializer(com.togethersoft.sca.plugin.audit.AstArrayInitializer expr)
Examines an array initializer expression. |
void |
checkArrayReference(com.togethersoft.sca.plugin.audit.AstArrayReference expr)
Examines an array reference expression. |
void |
checkAssertStatement(com.togethersoft.sca.plugin.audit.AstAssertStatement stmt)
Examines an assertion statement. |
void |
checkAssignmentExpression(com.togethersoft.sca.plugin.audit.AstAssignmentExpression expr)
Examines an assignment expression. |
void |
checkBasicBlock(com.togethersoft.sca.plugin.audit.IBasicBlock block)
Examines the results of control flow analysis. |
void |
checkBinaryExpression(com.togethersoft.sca.plugin.audit.AstBinaryExpression expr)
Examines a binary expression. |
void |
checkBreakStatement(com.togethersoft.sca.plugin.audit.AstBreakStatement stmt)
Examines a break statement. |
void |
checkCastExpression(com.togethersoft.sca.plugin.audit.AstCastExpression expr)
Examines a type cast expression. |
void |
checkCompilationUnit(com.togethersoft.sca.plugin.audit.AstCompilationUnit decl)
Examines a compilation unit (source file). |
void |
checkCompoundStatement(com.togethersoft.sca.plugin.audit.AstCompoundStatement stmt)
Examines a compound statement. |
void |
checkConditionalExpression(com.togethersoft.sca.plugin.audit.AstConditionalExpression expr)
Examines a conditional expression. |
void |
checkConstructorInvocation(com.togethersoft.sca.plugin.audit.AstConstructorInvocation expr)
Examines an explicit constructor invocation. |
void |
checkContinueStatement(com.togethersoft.sca.plugin.audit.AstContinueStatement stmt)
Examines a continue statement. |
void |
checkDeclarationStatement(com.togethersoft.sca.plugin.audit.AstDeclarationStatement stmt)
Examines a declaration statement. |
void |
checkDoStatement(com.togethersoft.sca.plugin.audit.AstDoStatement stmt)
Examines a do loop statement. |
void |
checkEmptyStatement(com.togethersoft.sca.plugin.audit.AstEmptyStatement stmt)
Examines an empty statement. |
void |
checkExpressionStatement(com.togethersoft.sca.plugin.audit.AstExpressionStatement stmt)
Examines an expression statement. |
void |
checkField(com.togethersoft.sca.plugin.audit.AstField decl)
Examines a field. |
void |
checkField(com.togethersoft.sca.dataflow.IField field,
com.togethersoft.sca.plugin.audit.AstField ast)
Examines a field. |
void |
checkFieldReference(com.togethersoft.sca.plugin.audit.AstFieldReference expr)
Examines a field reference expression. |
void |
checkForStatement(com.togethersoft.sca.plugin.audit.AstForStatement stmt)
Examines a for loop statement. |
void |
checkIfStatement(com.togethersoft.sca.plugin.audit.AstIfStatement stmt)
Examines an if statement. |
void |
checkInitializer(com.togethersoft.sca.plugin.audit.AstInitializer decl)
Examines a class initializer. |
void |
checkLifetime(com.togethersoft.sca.plugin.audit.ITupleSet[][] webs)
Examined lifetime of a local variable. |
void |
checkLiteral(com.togethersoft.sca.plugin.audit.AstLiteral expr)
Examines a literal. |
void |
checkLoop(com.togethersoft.sca.plugin.audit.IJavaLoop loop)
Examines a loop. |
void |
checkMethod(com.togethersoft.sca.plugin.audit.AstMethod method)
Examines a method. |
void |
checkMethod(com.togethersoft.sca.dataflow.IMethod method,
com.togethersoft.sca.plugin.audit.AstMethod ast)
Examines a method. |
void |
checkMethodCallExpression(com.togethersoft.sca.plugin.audit.AstMethodCallExpression expr)
Examines a method call expression. |
void |
checkModel(com.togethersoft.sca.plugin.audit.AstModel model)
Examines a model (whole project). |
void |
checkObjectCreationExpression(com.togethersoft.sca.plugin.audit.AstObjectCreationExpression expr)
Examines an object creation expression. |
void |
checkParenthesizedExpression(com.togethersoft.sca.plugin.audit.AstParenthesizedExpression expr)
Examines a parenthesized expression. |
void |
checkReturnStatement(com.togethersoft.sca.plugin.audit.AstReturnStatement stmt)
Examines a return statement. |
void |
checkSimpleReference(com.togethersoft.sca.plugin.audit.AstSimpleReference expr)
Examines a simple name expression. |
void |
checkSuperExpression(com.togethersoft.sca.plugin.audit.AstSuperExpression expr)
Examines super expression. |
void |
checkSwitchStatement(com.togethersoft.sca.plugin.audit.AstSwitchStatement stmt)
Examines a switch statement. |
void |
checkSynchronizedStatement(com.togethersoft.sca.plugin.audit.AstSynchronizedStatement stmt)
Examines a synchronized statement. |
void |
checkThisExpression(com.togethersoft.sca.plugin.audit.AstThisExpression expr)
Examines a this expression. |
void |
checkThrowStatement(com.togethersoft.sca.plugin.audit.AstThrowStatement stmt)
Examines a throw statement. |
void |
checkTryStatement(com.togethersoft.sca.plugin.audit.AstTryStatement stmt)
Examines a try statement. |
void |
checkTuple(com.togethersoft.sca.plugin.audit.ITuple tuple,
com.togethersoft.sca.plugin.audit.IVal[] operands,
com.togethersoft.sca.dataflow.values.IValueDomain[] values,
com.togethersoft.sca.dataflow.values.IValueDomain result)
Examines the results of data flow analysis. |
void |
checkType(com.togethersoft.sca.plugin.audit.AstType decl)
Examines a class or an interface. |
void |
checkTypeExpression(com.togethersoft.sca.plugin.audit.AstTypeExpression expr)
Examines a type expression. |
void |
checkUnaryExpression(com.togethersoft.sca.plugin.audit.AstUnaryExpression expr)
Examines a unary expression. |
void |
checkVariable(com.togethersoft.sca.plugin.audit.AstVariable decl)
Examines a variable or method parameter. |
void |
checkWhileStatement(com.togethersoft.sca.plugin.audit.AstWhileStatement stmt)
Examines a while loop statement. |
void |
enterPackage(com.togethersoft.sca.plugin.audit.AstPackage pkg)
enterPackage is the first method called during package examination. |
com.togethersoft.sca.core.IAnalyzerDescriptor |
getAnalyzer()
Returns the analyzer that produced this message. |
java.lang.String |
getExplainMessage(com.togethersoft.sca.plugin.audit.AstObject ast,
java.lang.String messageId,
java.lang.Object[] values)
Returns the formatted explain text of this message in HTML format |
java.util.ResourceBundle |
getResourceBundle()
Method getResourceBundle return ResourceBundle by default return value is null. |
java.lang.String |
getSeverity()
Returns the severity of messages generated by this rule. |
com.togethersoft.sca.core.plugin.audit.AutoFix |
getSuppressionFix(com.togethersoft.sca.core.plugin.audit.IAuditMessage msg)
Returns a fix that will suppress the given message during subsequent audit executions. |
void |
leaveCompoundStatement(com.togethersoft.sca.plugin.audit.AstCompoundStatement stmt)
Called when all the statements contained in the block have been examined. |
void |
leaveMethod(com.togethersoft.sca.plugin.audit.AstMethod method)
leaveMethod is called when the body of the method has been
examined. |
void |
leavePackage(com.togethersoft.sca.plugin.audit.AstPackage pkg)
leavePackage is the last method called during package examination. |
boolean |
requiresDataFlowAnalysis()
If this audit requires data flow analysis |
| Field Detail |
public static final int ALL_GRP
public static final int DECLARATION_GRP
public static final int EXPRESSION_GRP
public static final int STATEMENT_GRP
public static final int TUPLE_GRP
| Method Detail |
public void checkArrayCreationExpression(com.togethersoft.sca.plugin.audit.AstArrayCreationExpression expr)
Group: expressions.
public void checkArrayInitializer(com.togethersoft.sca.plugin.audit.AstArrayInitializer expr)
Group: expressions.
public void checkArrayReference(com.togethersoft.sca.plugin.audit.AstArrayReference expr)
Group: expressions.
public void checkAssertStatement(com.togethersoft.sca.plugin.audit.AstAssertStatement stmt)
Group: statements.
public void checkAssignmentExpression(com.togethersoft.sca.plugin.audit.AstAssignmentExpression expr)
Group: expressions.
public void checkBasicBlock(com.togethersoft.sca.plugin.audit.IBasicBlock block)
Group: statements.
public void checkBinaryExpression(com.togethersoft.sca.plugin.audit.AstBinaryExpression expr)
Group: expressions.
public void checkBreakStatement(com.togethersoft.sca.plugin.audit.AstBreakStatement stmt)
Group: statements.
public void checkCastExpression(com.togethersoft.sca.plugin.audit.AstCastExpression expr)
Group: expressions.
public void checkCompilationUnit(com.togethersoft.sca.plugin.audit.AstCompilationUnit decl)
Group: declarations.
public void checkCompoundStatement(com.togethersoft.sca.plugin.audit.AstCompoundStatement stmt)
Group: statements.
public void checkConditionalExpression(com.togethersoft.sca.plugin.audit.AstConditionalExpression expr)
Group: expressions.
public void checkConstructorInvocation(com.togethersoft.sca.plugin.audit.AstConstructorInvocation expr)
Group: expressions.
public void checkContinueStatement(com.togethersoft.sca.plugin.audit.AstContinueStatement stmt)
Group: statements.
public void checkDeclarationStatement(com.togethersoft.sca.plugin.audit.AstDeclarationStatement stmt)
Group: statements.
public void checkDoStatement(com.togethersoft.sca.plugin.audit.AstDoStatement stmt)
Group: statements.
public void checkEmptyStatement(com.togethersoft.sca.plugin.audit.AstEmptyStatement stmt)
Group: statements.
public void checkExpressionStatement(com.togethersoft.sca.plugin.audit.AstExpressionStatement stmt)
Group: statements.
public void checkField(com.togethersoft.sca.plugin.audit.AstField decl)
Group: declarations.
public void checkField(com.togethersoft.sca.dataflow.IField field,
com.togethersoft.sca.plugin.audit.AstField ast)
public void checkFieldReference(com.togethersoft.sca.plugin.audit.AstFieldReference expr)
Group: expressions.
public void checkForStatement(com.togethersoft.sca.plugin.audit.AstForStatement stmt)
Group: statements.
public void checkIfStatement(com.togethersoft.sca.plugin.audit.AstIfStatement stmt)
Group: statements.
public void checkInitializer(com.togethersoft.sca.plugin.audit.AstInitializer decl)
Group: declarations.
public void checkLifetime(com.togethersoft.sca.plugin.audit.ITupleSet[][] webs)
public void checkLiteral(com.togethersoft.sca.plugin.audit.AstLiteral expr)
Group: expressions.
public void checkLoop(com.togethersoft.sca.plugin.audit.IJavaLoop loop)
Group: statements.
public void checkMethod(com.togethersoft.sca.plugin.audit.AstMethod method)
Group: declarations.
public void checkMethod(com.togethersoft.sca.dataflow.IMethod method,
com.togethersoft.sca.plugin.audit.AstMethod ast)
public void checkMethodCallExpression(com.togethersoft.sca.plugin.audit.AstMethodCallExpression expr)
Group: expressions.
public void checkModel(com.togethersoft.sca.plugin.audit.AstModel model)
Group: declarations.
public void checkObjectCreationExpression(com.togethersoft.sca.plugin.audit.AstObjectCreationExpression expr)
Group: expressions.
public void checkParenthesizedExpression(com.togethersoft.sca.plugin.audit.AstParenthesizedExpression expr)
Group: expressions.
public void checkReturnStatement(com.togethersoft.sca.plugin.audit.AstReturnStatement stmt)
Group: statements.
public void checkSimpleReference(com.togethersoft.sca.plugin.audit.AstSimpleReference expr)
Group: expressions.
public void checkSuperExpression(com.togethersoft.sca.plugin.audit.AstSuperExpression expr)
Group: expressions.
public void checkSwitchStatement(com.togethersoft.sca.plugin.audit.AstSwitchStatement stmt)
Group: statements.
public void checkSynchronizedStatement(com.togethersoft.sca.plugin.audit.AstSynchronizedStatement stmt)
Group: statements.
public void checkThisExpression(com.togethersoft.sca.plugin.audit.AstThisExpression expr)
Group: expressions.
public void checkThrowStatement(com.togethersoft.sca.plugin.audit.AstThrowStatement stmt)
Group: statements.
public void checkTryStatement(com.togethersoft.sca.plugin.audit.AstTryStatement stmt)
Group: statements.
public void checkTuple(com.togethersoft.sca.plugin.audit.ITuple tuple,
com.togethersoft.sca.plugin.audit.IVal[] operands,
com.togethersoft.sca.dataflow.values.IValueDomain[] values,
com.togethersoft.sca.dataflow.values.IValueDomain result)
Group: tuples.
public void checkType(com.togethersoft.sca.plugin.audit.AstType decl)
Group: declarations.
public void checkTypeExpression(com.togethersoft.sca.plugin.audit.AstTypeExpression expr)
Group: expressions.
public void checkUnaryExpression(com.togethersoft.sca.plugin.audit.AstUnaryExpression expr)
Group: expressions.
public void checkVariable(com.togethersoft.sca.plugin.audit.AstVariable decl)
Group: declarations.
public void checkWhileStatement(com.togethersoft.sca.plugin.audit.AstWhileStatement stmt)
Group: statements.
public void enterPackage(com.togethersoft.sca.plugin.audit.AstPackage pkg)
enterPackage is the first method called during package examination.
Group: declarations.
public com.togethersoft.sca.core.IAnalyzerDescriptor getAnalyzer()
public java.lang.String getExplainMessage(com.togethersoft.sca.plugin.audit.AstObject ast,
java.lang.String messageId,
java.lang.Object[] values)
public java.util.ResourceBundle getResourceBundle()
public java.lang.String getSeverity()
public com.togethersoft.sca.core.plugin.audit.AutoFix getSuppressionFix(com.togethersoft.sca.core.plugin.audit.IAuditMessage msg)
null if suppression fix cannot
be created.
When run, the suppression fix will insert a special comment before
the associated code fragment, for example:
void f(int a) {
int z = 0;
// $SUP-AP$ $SUP-EVNU$ $SUP-ONE$
a += z;
}
public void leaveCompoundStatement(com.togethersoft.sca.plugin.audit.AstCompoundStatement stmt)
public void leaveMethod(com.togethersoft.sca.plugin.audit.AstMethod method)
leaveMethod is called when the body of the method has been
examined.
Group: declarations.
public void leavePackage(com.togethersoft.sca.plugin.audit.AstPackage pkg)
leavePackage is the last method called during package examination.
Group: declarations.
public boolean requiresDataFlowAnalysis()
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||