[previous] 1503 [next] The function 'name' is defined but is not used within this project.
CMA declaration checks

The object declared here is not referenced at any point within the project. During maintenance it is possible that a function or an object used in the original design, may be replaced or become redundant. If possible, the declaration should be removed in order to reduce the potential for confusion.

Example:


// TU1.cpp
int globalObj = 0;

int main()
{
  ++globalObj; 
}

// TU2.cpp
void bar()
{
}

In order to reduce the number of global variables, it is decided to change this global variable into a local static.

Example:


// TU1.cpp
int globalObj = 0;

int & getGlobalObj()
{
  static int obj = 0;
  return obj;
}

int main()
{
  ++getGlobalObj();
}

// TU2.cpp
void bar ()
{
}

However, incorrectly, the declaration of globalObj has not been removed. At a later stage, a bug fix is required and the developer incorrectly changes TU2 so it now uses globalObj.

Example:


// TU1.cpp
int globalObj = 0;

int & getGlobalObj()
{
  static int obj = 0;
  return obj;
}

int main()
{
  ++getGlobalObj();
}

// TU2.cpp
extern int globalObj;

void bar ()
{
  ++globalObj;          // ERROR: This variable was no longer used in the project
}

See also:

QA·C Source Code Analyser 8.1.2
© 2013 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index Contents