Hi,

I have had a look at the code you had attached Bert. Your solution for parsing out the MISRA rule number is nicer than what I used.

After digging into how Pc-lint handles MISRA I have come to the following conclusion:

-          Using the ID:s to see what rules needs to be remapped into unique Sonar rules will not do.

o   There are a lot more ID:s used than 960,961 and 1960 for MISRA. The ID:s 960,961 and 1960 is being used for the rules that Pc-Lint needed to explicitly add to have a full MISRA rules set. The rules that they had implemented before taking on MISRA have other ID:s. Example ID 504. All the rules seems to have MISRA appended to the message when running in MISRA mode.

Therefor searching the message for “MISRA” ought to be the best way to find the MISRA rules.

-          Naming convention for Sonar MISRA rules “original ID + MISRA rule” will be problematic.

o   For the same reason as above I think that it will be quite tricky to sort out all original ID:s for all MISRA rules when creating the Sonar rules.

o   My suggestion would be to use what Bert already did “M+MISRA rule”

My only concern is the new MISRA 2012. Have anyone of you seen how the new rule format look like?

MISRA 2004: Rule 12.1
MISRA 2008: Rule 0-0-1
MISRA 2012: Rule ????

Regards
Johan
From: Bert [mailto:notifications@github.com]
Sent: den 21 maj 2013 22:59
To: SonarCommunity/sonar-cxx
Cc: Esbjörner Johan
Subject: Re: [sonar-cxx] Remap Pc-lint MISRA 2004 rules into unique Sonar rules. (#30)


In sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/pclint/CxxPCLintSensor.java:

>            && !StringUtils.isEmpty(id) && !StringUtils.isEmpty(msg);

>        }

> +

> +            /**

> +            Removes the dot in the rule number and adds a big offset

> +            to make sure the key ID is not already used by other PC-lint rules.

> +            **/

> +            private String mapMisraRulesToUniqueSonarRules(String msg){

Hi Johan,

Please find the proposal for MISRA 2008 support attached (PC-Lint warning ID 1960). I used a prefix “M” for the rule id but Costa’s hint to use the original warning ID “960|961|1960” is better.

I guess the former attachment was dropped on GitHub and I will send it to your e-Mail account.

Best Regards
Bert

—
Reply to this email directly or view it on GitHub<https://github.com/SonarCommunity/sonar-cxx/pull/30/files#r4326617>.
The information contained in this e-mail message is privileged and
confidential and is for the exclusive use of the addressee. The person
who receives this message and who is not the addressee, one of his
employees or an agent entitled to hand it over to the addressee, is
informed that he may not use, disclose or reproduce the contents
thereof, and is kindly asked to notify the sender and delete the e-mail
immediately.