Codecheck Comment Keywords

Good news for teams using Codecheck, build 868 lets Codecheck ignore violation via comments in the code. This will allow teams to specify areas in the code where exceptions are permitted and specify the rationale. For example:

  goto RAINBOW; //UndCC_Line() Use of goto statement approved by Gerry T. on Nov 7,2014

This will create a new rule in the Codecheck “Ignores List” to ignore all Codecheck violations on this line and add a note about the approval process. Those ignored violations can still be viewed in Understand, but are hidden by default.

Ignore rules can be created for: a specific line, a range of lines, a file, a specific entity, and a specific entity in a range of lines. They can also be made to ignore all violations or just violations of the specified type(s).

Keywords

//UndCC_Line()                            *Ignore all violations on this line

//UndCC_NextLine()                     *Ignore all violations on the next line

//UndCC_Begin()                          *Ignore all violations from the start of this line until _End

//UndCC_End()            

//UndCC_File()                             *Ignore all violation in this file                    

//UndCC_Entity(EntityName)         *For the next entity named EntityName, ignore all violations anywhere

//UndCC_EntityBegin(EntityName) *For the next entity named EntityName, ignore violations until _EntityEnd

//UndCC_EntityEnd(EntityName)

All of these keywords can optionally have one or more CheckIDs associated with them, for example UndCC_Line() ignores all violations on this line, and UndCC_Line(MISRA_2.1) will only ignore violations from MISRA rule 2.1.

Rules and clarifications

  • Each Codecheck now has a checkID subroutine that returns a unique checkID to identify it (AlphaNumeric and underscore characters) Those checkIDs are visible in the Understand GUI. 
  • All keywords optionally accept a comma-delimited list of checkIDs as parameters. If no checkIDs are specified then all violations will be ignored. 
  • Any comment before the keyword will be ignored, any comment after the keyword will be added as a note.
  • C-style comments (/*  */) allow multiple lines of notes. For C++-Style comments (//) the note will terminate at the end of the line.
  • Keywords are not case sensitive i.e UNDCC_LINE() and undcc_line() will both work.
  • Only one Keyword may be used per comment
  • Parentheses are required, even if no parameters are specified.
  • If Begin or EntityBegin do not have a corresponding End then it will ignore the remainder of the file.
  • In the case of multiple entities with the same name EntityEnd will use the Entity from the from the closest preceding EntityBegin statement with the same EntityName

Examples

Single line with Note

Check A49 will ignore violations on this line

goto RAINBOW; //UndCC_Line(A49) Mgmt Approved on Nov 7,2014

Single Entity with Multi-line Note

Any violations anywhere in the project from the entity numGprims will be ignored. A two line note will be added to the ignore rule.

/*UndCC_Entity(numGprims) numGprims is atomic so all

violations should be ignored*/

CImplicit::~CImplicit() {

   atomicDecrement(&stats.numGprims);

Staggered Endings

Ignore violations from check B34 between line 1 and 29. Violations from checks 1A9 and D38 will be ignored for the entire file since they have no corresponding _End.

Line 1:   //UndCC_Begin(B34,1A9,D3B)   

Line 29: //UndCC_End(B34)

Nested Example of EntityBegin (Same Entity)

Check D49 will ignore violations of ‘foo’ from lines 27-45. Check A48 from lines 27-98 and Check C3A from line 32-98

Line 27: //UndCC_EntityBegin(foo,D49,A48)

Line 32: //UndCC_EntityBegin(foo,C3A)

Line 45: //UndCC_EntityEnd(foo,D49)

Line 98: //UndCC_EntityEnd(foo,A48,C3A)

Nested Example of EntityBegin (Multiple Entities with the same name)

Here there are two entities named cDeltaRun, only violations to the first entity will be ignored, so any violations for cDeltaRun in getSwimSpeed will not be ignored because it is a different cDeltaRun.

//UndCC_EntityBegin(cDeltaRun)

int getDartInfo(int cDeltaRun){

 return cDeltaRun * 5;         

}

int getSwimSpeed(int cDeltaRun){

 return cDeltaRun / 2;          

}//UndCC_EntityEnd(cDeltaRun)

The correct way to do this would be to end the first range and create a second range for the next entity.

//UndCC_EntityBegin(cDeltaRun)

int getDartInfo(int cDeltaRun){

 return cDeltaRun * 5;         

} //UndCC_EntityEnd(cDeltaRun)

//UndCC_EntityBegin(cDeltaRun)

int getSwimSpeed(int cDeltaRun){

 return cDeltaRun / 2;          

} //UndCC_EntityEnd(cDeltaRun)

If the Begins and Ends are staggered, the rules will be nested:

//UndCC_EntityBegin(cDeltaRun) Ignore the first cDeltaRun

//UndCC_EntityBegin(cDeltaRun) Ignore the second cDeltaRun

//UndCC_EntityEnd(cDeltaRun)   Stop ignoring the second cDeltaRun

//UndCC_EntityEnd(cDeltaRun)   Stop ignoring the first cDeltaRun