Package Index  Table of Contents

C/C++ ECS Test Suite Project - *.cpp



Module - 10.html


// test

Module - 102.html


/*
102.   Declare a private operator new() to prohibit dynamic allocation.
*/
// bad 102
//good 102    

Module - 104.html


/*
104.   Declare single-parameter constructors as explicit to avoid unexpected type conversions.
*/
  // good 104
// bad 104, no explicit    

Module - 11.html


/*
//[   3.         Naming Conventions         ]
11.    Use UPPERCASE and underscores for preprocessor macro names.
*/
#define foo	143849839483 // 11. Use UPPERCASE and underscores for preprocessor macro names.
#define FOO_foo	2       // bad
#define ABX_FOO	3       // ok

Module - 118.html


// 118.  Use C++ casting operators instead of C-style casts.
// BAD 118, explicit old-style cast
// good 118

Module - 12.html


#define FOO_foo	2 // 
#define ABX_foo	3 // 12.    Add a unique prefix to macro names.

Module - 126.html


/*
126.  Use C++ streams instead of stdio functions for type safety.
*/
#include   // don't use
Function Definition: main
// don't use stdio.h
// good

Module - 145.html


/*
145.  Avoid break and continue in iteration statements.
*/
Function Definition: main
     break;      // no
     continue;   // no
      // Avoid break and continue in iteration statements.

Module - 146.html


/*
146.  Avoid multiple return statements in functions.
*/
Function Definition: main
  if ( 1 ) return;  // too many return path's

Module - 147.html


/*
147.  Do not use goto.
*/
Function Definition: main
//Do not use goto.

Module - 15.html


//15.    Pluralize the names of collections.
Shapes 	shape;		// single, singular
Shapes 	shapes[10];	// multiple, plual
Shape	array[10];	// BAD multipe, no plural 

Module - 16.html


/*
16.    Use lowerCamelCase for function names.
*/
Function Definition: Foofun
int Foofun() { 		// 16. Use lowerCamelCase for function names.

Module - 172.html


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

Module - 173.html


/*
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
Function Definition: foo

Module - 174.html


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

Module - 175.html


// 175.  Do not put global-scope using or using namespace declarations in a header file.
// GOOD 175, using ok in c++ file

Module - 22.html


/*
22.    Name all function parameters.
*/
    myclass (void);     //ok
    myclass(int);       //bad
    void method2();     // inconsistent
Function Definition: myclass

Module - 23.html


/*
23.    Use "other" for parameter names in copy constructors and assignment operators.
*/
    A( const A& other );    // ok
    A& operator= (const A& other ); // ok
    A( const A& foo );    // bad
    A& operator= (const A& fum ); // bad

Module - 27.html


int h57;	// 27. Avoid the use of digits within names.

Module - 28.html


// 28.  Avoid excessively long names.

Module - 30.html


/*
.
30.    Use lowerCamelCase for abbreviations.
*/
typedef int FOO; // 30.    Use "lowerCamelCase"

Module - 40.html


/*
40.    Use one-line comments to explain implementation details.
*/
// comment about the function
Function Definition: f
// comment about the next aggregate statement
Function Definition: ff

Module - 42.html


/*
42.   Provide a summary description of every declared element.
*/
//GOOD foo doesn't do much

Module - 43.html


/*
43.   Document the interface exposed by every function.
*/
// foo does this ..
Function Definition: foo
Function Definition: badfoo

Module - 52.html


/*
52.    Label closing braces in highly nested control structure.
*/
// BAD
Function Definition: foo1
// GOOD
Function Definition: foo2
			}	// good
		}		// good
	}			// good

Module - 64.html


/*
64.    Design for reentrancy.
*/
// multi-thread code cannot use global's each method must have unique instance
Function Definition: Thread
  FOO_GLO ++;		// 64. Design for reentrancy.

Module - 69.html


/*
69.    Place preprocessor include guards in header files.
*/

Module - 72.html


/*
72.    Add a semicolon after every statement expression macro.
*/
NOP		// bad 72.    Add a semicolon after every statement expression macro.
NOP;	// good

Module - 74.html


/*
74.    Do not use "#define" to define constants declare static const variables instead.
*/
 int foomem = foo ; // big magic number -Do not use "#define" to define constants

Module - 75.html


/*
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.
*/

Module - 76.html


/*
76.    Use typedefs to simplify complicated type expressions.
*/
        const vector &  log;    // bad 
Function Definition: bad
    const vector &  log;    // bad 
      logtype &  log;            // good
Function Definition: good
    logtype &  log;            // good

Module - 77.html


/*
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

Module - 78.html


/*
78.    Do not define enumerations using macros or integer constants.
*/
// BAD don't use macro constants, use enum
// BAD also ..

Module - 79.html


/*
79.   Declare enumerations within a namespace or class.
*/
// bad, global space
// good nmsp
// good class space

Module - 80.html


/*
80.   Declare global functions, variables, or constants as static members of a class.
*/
// bad, should be static in class
  // good

Module - 81.html


/*
81.   Declare for-loop iteration variables inside of for statements.
*/
// a loop iterator variable must be local to for-loop
Function Definition: main
  for ( i=0; i<1; i++ ) {   // BAD 81
  for ( int i=0; i<10; i++ ) {  // GOOD 81

Module - 82.html


/*
82.    Use an enumeration instead of a Boolean to improve readability.
*/
  void noop(bool);  //BAD 82 DECL
Function Definition: fooop
 //BAD 82 Usage
 foo.noop(true);    // this has questionable meaning
 //GOOD 82
 foo.noop(foo::aloud); // this is clear?

Module - 84.html


/*
84.   Accept objects by reference and primitive or pointer types by value.
*/
//GOOD 84
//BAD 84, primitive types must be passed by value

Module - 87.html


// 87.    Do not use void* in a public interface.
  void * foo();  // BAD 87
  void * foam();  // GOOD 87

Module - 88.html


/*
88.    Use inline functions instead of macros.
*/
Function Definition: SQRT
Function Definition: main
  hypo = _SQRT ( 2 );  // BAD 88, don't use macros
  hypo = SQRT ( 2 );    // GOOD 88, inline 

Module - 9.html


/*
9.       Include white space.
*/
Function Definition: main
 while(1) {  } ;	// need space after while
 do{ } while(1);	// need space after do and while

Module - 96.html


// 96.    Avoid the use of friend declarations.
// bad 96, don't use friend

Module - 97.html


/*
97.   Declare an explicit default constructor for added clarity.
*/
// bad 97, no con
// good 97, has con

Module - c170.html


/*
170.  Use the class name as the filename.
*/
// GOOD 170 class name like file name
// BAD 170 file name not like class name

Module - gen.html


#include 	// bad
#define foo	143849839483 // 11. Use UPPERCASE and underscores for preprocessor macro names.
#define FOO_foo	2 // 
#define ABX_foo	3 // 12.    Add a unique prefix to macro names.
NOP		// bad 72.    Add a semicolon after every statement expression macro.
NOP;	// good
class foo1; // fwd decl
Function Definition: Foo
Foo() {}	// DUMMY Fun def
int h57;	// 27. Avoid the use of digits within names.
typedef int FOO; // 30.    Use "lowerCamelCase"
 int foomem = foo ; // big magic number -Do not use "#define" to define constants
Function Definition: Foofun
int Foofun() { 		// 16. Use lowerCamelCase for function names.
  FOO_GLO ++;		// 64. Design for reentrancy.

Module - t174.html


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

Package Index  Table of Contents

CodeCheck Copyright (c) 1988-2005 by Abraxas Software Inc. (R). All rights reserved.