Table 2 Source structure in the rules library
include/ | • | HPCodeGuideConstructs.h |
|
| Contains the APIs required for (re)writing the rules to enforce coding guidelines. |
| • | HPCodeGuideDiagnosticTags.h |
|
| Contains the various diagnostic tags that you can use to emit the diagnostics |
|
| from the rules library. |
lib/
src/
•libcodeguide.a
This is provided to fill in the implementation stubs for recompilation of the rules' library, and must be linked in while compiling the rules' library.
•librules.s[lo]
This is the default rules' library that is available with cadvise.
•HPCodeGuideRules.C
The file where all rules are implemented. You can modify this file to incorporate more rules and/or modify the existing ones.
•HPCodeGuideRulesDriver.C
The driver from where the rules are invoked on the various program constructs.
•Makefile
The default makefile for rebuilding the rules' library from the above sources.
The sample rules towards naming convention that are available with the current release are as follows:
1.Functions that returns a bool must start with is.
2.Names of abstract classes should begin with Interface.
3.Class names should start with a capital letter.
4.Names of global variables should start with a capital letter.
5.Names of local variables should start with a small letter.
An example of writing a rule to enforce the naming convention of private data members being suffixed with an '_' is as follows:
Example 5 Writing a rule to enforce naming convention
void Field::checkNamingConventions() {
//Private data members of class should end with "_" if(name() && isPrivate()) {
char ch = *name() + strlen(name()); if(ch != '_')
warning("Private data member \"%s\" not suffixed with \"_\"", 2000053, name());
}
}
NOTE: Cadvise reports do not currently have support for Coding Guideline diagnostics. Use the
18 Using Cadvise