ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS

Abraxas/ECS C++ Home  Table of Contents   

CodeCheck Rule-Files for ECS C++ - ecs-test.ccp


// test

ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++


//[ 3. Naming Conventions ]

11. Use UPPERCASE and underscores for preprocessor macro names.

ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++


ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++


//15. Pluralize the names of collections.

ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++


16. Use lowerCamelCase for function names.

ECS C++ Function Definition: Foofun

ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++


22. Name all function parameters.

ECS C++ Function Definition: myclass

ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++


23. Use "other" for parameter names in copy constructors and assignment operators.

ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++


ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++


// 28. Avoid excessively long names.

ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++


30. Use lowerCamelCase for abbreviations.

ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++


40. Use one-line comments to explain implementation details.

// comment about the function

ECS C++ Function Definition: f

// comment about the next aggregate statement

ECS C++ Function Definition: ff

ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++


42. Provide a summary description of every declared element.

//GOOD foo doesn't do much

ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++


43. Document the interface exposed by every function.

// foo does this ..

ECS C++ Function Definition: foo
ECS C++ Function Definition: badfoo

ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++


52. Label closing braces in highly nested control structure.

// BAD

ECS C++ Function Definition: foo1

// GOOD

ECS C++ Function Definition: foo2

ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++


64. Design for reentrancy.

// multi-thread code cannot use global's each method must have unique instance

ECS C++ Function Definition: Thread

ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++


69. Place preprocessor include guards in header files.

ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++


72. Add a semicolon after every statement expression macro.

ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++


74. Do not use "#define" to define constants declare static const variables instead.

ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++


75. Use portable types for portable code.

// bad over-riding #include

will generate the above for you automatically this make's portable code!

It's best to #include and then let your compiler create the types for you.

ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++


76. Use typedefs to simplify complicated type expressions.

ECS C++ Function Definition: bad
ECS C++ Function Definition: good

ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++


77. Create a zero-valued enumerator to indicate an uninitialized, invalid, unspecified, or default state.

// zero value, added zero intialization as comment

// bad NO Default, or None, ...

// false positive exclusion

ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++


78. Do not define enumerations using macros or integer constants.

// BAD don't use macro constants, use enum

// BAD also ..

ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++


79. Declare enumerations within a namespace or class.

// bad, global space

// good nmsp

// good class space

ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++


80. Declare global functions, variables, or constants as static members of a class.

// bad, should be static in class

// good

ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++


81. Declare for-loop iteration variables inside of for statements.

// a loop iterator variable must be local to for-loop

ECS C++ Function Definition: main

ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++


82. Use an enumeration instead of a Boolean to improve readability.

ECS C++ Function Definition: fooop

//BAD 82 Usage

//GOOD 82

ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++


84. Accept objects by reference and primitive or pointer types by value.

//GOOD 84

//BAD 84, primitive types must be passed by value

ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++


// 87. Do not use void* in a public interface.

ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++


88. Use inline functions instead of macros.

ECS C++ Function Definition: SQRT
ECS C++ Function Definition: main

ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++


9. Include white space.

ECS C++ Function Definition: main

ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++


// 96. Avoid the use of friend declarations.

// bad 96, don't use friend

ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++


97. Declare an explicit default constructor for added clarity.

// bad 97, no con

// good 97, has con

ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++


102. Declare a private operator new() to prohibit dynamic allocation.

// bad 102

//good 102

ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++


104. Declare single-parameter constructors as explicit to avoid unexpected type conversions.

// good 104

// bad 104, no explicit

ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++


// 118. Use C++ casting operators instead of C-style casts.

// BAD 118, explicit old-style cast

// good 118

ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++


126. Use C++ streams instead of stdio functions for type safety.

ECS C++ Function Definition: main

// don't use stdio.h

// good

ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++


145. Avoid break and continue in iteration statements.

ECS C++ Function Definition: main

// Avoid break and continue in iteration statements.

ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++


146. Avoid multiple return statements in functions.

ECS C++ Function Definition: main

ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++


147. Do not use goto.

ECS C++ Function Definition: main

//Do not use goto.

ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++


170. Use the class name as the filename.

// GOOD 170 class name like file name

// BAD 170 file name not like class name

ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++


172. Use #include sparingly in header files.

// 172.h #includes "gen.h" [ prj header ], its ok for 172.h to #include <> system headers

ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++


173. Implement class methods outside of their class declaration block.

// bad 173, a definition should NOT be made within a class

// Very nasty practice as this is a 'deferred function' and not actually processed until end-of-class

// good 173, just a decl

ECS C++ Function Definition: c173

ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++


// 174. Do not name files containing tests or examples the same as template header file names.

ECS C++ Function Definition: main

ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++


// 175. Do not put global-scope using or using namespace declarations in a header file.

// GOOD 175, using ok in c++ file

ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++


Abraxas/ECS C++ Home  Table of Contents   

ABRAXAS SOFTWARE - CodeCheck ECS C++ Test-Suite ECS C++-C: