Hello,
I have a question about C rules addon with the Developer Edition. I want to adapt SonarQube to verify Automotive Misra’s Rules checking C language. Since all Misra’s rules are not originally implemented in your SonarQube plugin, I want to add some more rules, such as it is done with Java language.
For instance, the Misra’s rule 17.4 specifies that “Array indexing shall be the only allowed form of pointer arithmetic”, but none of the sonar’s rule checks this error. I give you an example of test code for this rule :
void my_fn(uint8_t * p1, uint8_t p2[])
{
uint8_t index = 0U;
uint8_t * p3;
uint8_t * p4;
*p1 = 0U;
p1 ++; /* not compliant - pointer increment */
p1 = p1 + 5; /* not compliant - pointer increment */
p1[5] = 0U; /* not compliant - p1 was not declared as an array */
p3 = &p1[5]; /* not compliant - p1 was not declared as an array */
p2[0] = 0U;
index ++;
index = index + 5U;
p2[index] = 0U; /* compliant */
p4 = &p2[5]; /* compliant*/
}
I want to raise an error when the code is not compliant. This is one rule among others that I want to implement. Do you think that it is possible to develop our proper rules for the language C with the Developer Edition ?