C rules addon with the Developer Edition


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 ?

Hello @emilie,

Thanks for showing your interest about MISRA related rules and I’m sorry to say it’s not possible to add custom rules for C or C++ in SonarQube. Today, we support MISRA C++ 2008 (see C++ analysis engine covers more rules from MISRA C++ 2008 standard).

Do you confirm you need rules to check your compliance against MISRA C 2004?


Hello Alex,

Thanks for your response. I confirm that I am interested only by MISRA C 2004 (or 2012). I need a confirmation too. It is not possible to add some rules in the existing plugin? Without creating a new plugin, just to complete the existing one?

Best regards,