JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.

If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.

If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.

CodeSonar® 9.2p0 CONFIDENTIAL CodeSecure Inc
C and C++


LANG.ID.STYLE : Naming Style Violation

Summary

An identifier does not conform to the style requirements that have been expressed through IDENTIFIER_NAMING_* rules applied to the project.

You can specify your own rules, or use one or more of the built-in presets that specify IDENTIFIER_NAMING_* rules for a particular standard.

Preset Contains IDENTIFIER_NAMING_* rules for...
barr_naming The naming rules in the Barr Group Embedded C Coding Standard.
misrac++2023
misrac++2023_inc
misrac++
misrac++_inc
MisraC++2023:5.10.1.
jsf++
jsf++_inc
JSF++:47, JSF++:50, JSF++:51, JSF++:52.

There are no rules applied by default (that is, there are no factory settings for the IDENTIFIER_NAMING_* parameters, and no IDENTIFIER_NAMING_* rules in any of the default presets shipped with CodeSonar). This means that if you enable this warning class without specifying your own rules or including a suitable preset, you will not get any warnings.

Properties

Class Name Naming Style Violation
Significance style
Mnemonic LANG.ID.STYLE
Categories
MisraC++2023 MisraC++2023:5.10.1 User-defined identifiers shall have an appropriate form
JSF++ JSF++:47 Identifiers will not begin with the underscore character '_'.
  JSF++:50 The first word of the name of a class, structure, namespace, enumeration, or type created with typedef will begin with an uppercase letter. All others letters will be lowercase.
  JSF++:51 All letters contained in function and variable names will be composed entirely of lowercase letters.
  JSF++:52 Identifiers for constant and enumerator values shall be lowercase.
Availability Available for C and C++.
Enabling Checks for this warning class are disabled by default, and require the unnormalized C ASTs for the project. To enable them, add the following WARNING_FILTER rule and RETAIN_UNNORMALIZED_C_AST specification to the project configuration file.
RETAIN_UNNORMALIZED_C_AST = Yes
WARNING_FILTER += allow class="Naming Style Violation"
Note that retaining the unnormalized ASTs will increase the disk space used to store the project representation, and may make the analysis take longer.

Example

Suppose there is an organization-wide style rule that all class names must be in camel case. For example, a class can be named MyClass but not myClass or myclass.

To check that all class names conform to this rule, add the following IDENTIFIER_NAMING_CLASS_CASE entry to a suitable configuration file. For an organization-wide rule, you might decide to add the rule to the general template configuration file so that it is always available to all projects, or to create a custom preset or default preset containing all the organization style rules.

IDENTIFIER_NAMING_CLASS_CASE = CamelCase

When the Naming Style Violation warning class is enabled and this IDENTIFIER_NAMING_CLASS_CASE rule is specified, CodeSonar will issue the following warnings.

class A {                         // ok: camel case according to definition ^[A-Z][a-zA-Z0-9]*
   // ...
  };

  class Capitalized {              // ok: camel case according to definition ^[A-Z][a-zA-Z0-9]*
   // ...
  };

  class Capitalizedmultiword {     // ok: a human reader might object to the interior words not being 
                                   // individually capitalized, but the warning class check is syntactic only
   // ...
  };

  class CamelCase {                // ok: classic camel case
   // ...
  };

  class UPPERCASE {                // ok: camel case according to definition ^[A-Z][a-zA-Z0-9]*
   // ...
  };

  class lowercase {       // 'Naming Style Violation' warning issued here 
   // ...
  };

  class camelBack {       // 'Naming Style Violation' warning issued here 
   // ...
  };

  class Camel_Snake {     // 'Naming Style Violation' warning issued here 
   // ...
  };

  class camel_Snakeback { // 'Naming Style Violation' warning issued here 
   // ...
  };

  class mIxEd_cAse {      // 'Naming Style Violation' warning issued here 
   // ...
  };

  int foo;

Relevant Configuration File Parameters

The following configuration file parameters affect checks for this warning class.

 

To report problems with this documentation, please visit https://support.codesecure.com/.