NC -- Naming Conventions
Go Up to C++ Audits
Description
NC checks whether the code conforms to the naming guidelines. NC controls:
- Using capitalization of internal elements of compound identifiers when elements are joined without spaces.
- Using prefixes in identifiers.
NC checks capitalization in the following types of identifiers:
Identifier Type | Description |
---|---|
NCCheckClassNames |
Class names. The default is |
NCCheckEnumeratorNames |
Enumerator names. The default is |
NCCheckFieldNamesConst |
Names of unmodifiable fields. The default is |
NCCheckFieldNamesOthear |
Names of modifiable fields. The default is |
NCCheckFieldNamesPublic |
Names of public fields. The default is |
NCCheckFieldNamesStatic |
Names of static fields. The default is |
NCCheckFunctionNames |
Function names. The default is |
NCCheckLocalVariablesFormalParameterNames |
Names of local variables and formal parameters (arguments). The default is |
NCCheckMacroNames |
Names of macros. The default is |
NCCheckMethodNames |
Names of methods. The default is |
NCCheckNamespaceNames |
Names of namespaces. The default is |
NC understands the following types of capitalization:
CapitalizationType | Description |
---|---|
|
Each internal element's initial letter capitalized within a compound identifier and the first letter of the identifier is in lowercase, for example, iPod. |
|
An identifier should contain all letters in lowercase. |
|
Each internal element's initial letter capitalized within a compound identifier and the first letter of the identifier is in uppercase, for example, BackColor. |
|
Identifier should contain all capital letters. |
NC checks prefixes in the following types of identifiers:
Identifier Type | Description |
---|---|
NCPrefixClassFieldNames |
In names of fields in classes |
NCPrefixClassNames |
In names of classes |
NCPrefixEnumeratorNames |
In names of enumerators |
NCPrefixInstanceFieldName |
In names of fields in objects |
Incorrect
class myClass {
static const int max_size = 10;
void MyMethod() {
int Var;
}
};
Correct
class MyClass {
static const int MAX_SIZE = 10;
void myMethod() {
int var;
}
};
Refactoring
Use the Refactor > Rename refactoring menu command to rename names.