@@ -945,24 +945,40 @@ std::string getClassification(const std::string &guideline, ReportType reportTyp
945
945
return getClassification (checkers::certCInfo, guideline);
946
946
case ReportType::certCpp:
947
947
return getClassification (checkers::certCppInfo, guideline);
948
- case ReportType::misraC:
948
+ case ReportType::misraC2012:
949
+ case ReportType::misraC2023:
950
+ case ReportType::misraC2025:
949
951
{
950
- auto components = splitString (guideline, ' .' );
952
+ const bool isDirective = guideline.rfind (" Dir " , 0 ) == 0 ;
953
+
954
+ const std::size_t offset = isDirective ? 4 : 0 ;
955
+ auto components = splitString (guideline.substr (offset), ' .' );
951
956
if (components.size () != 2 )
952
957
return " " ;
953
958
954
959
const int a = std::stoi (components[0 ]);
955
960
const int b = std::stoi (components[1 ]);
956
961
957
- const std::vector<checkers::MisraInfo> &info = checkers::misraC2012Rules;
958
- const auto it = std::find_if (info.cbegin (), info.cend (), [&](const checkers::MisraInfo &i) {
962
+ const std::vector<checkers::MisraInfo> *info = nullptr ;
963
+ switch (reportType) {
964
+ case ReportType::misraC2012:
965
+ info = isDirective ? &checkers::misraC2012Directives : &checkers::misraC2012Rules;
966
+ break ;
967
+ case ReportType::misraC2023:
968
+ info = isDirective ? &checkers::misraC2023Directives : &checkers::misraC2023Rules;
969
+ break ;
970
+ case ReportType::misraC2025:
971
+ info = isDirective ? &checkers::misraC2025Directives : &checkers::misraC2025Rules;
972
+ break ;
973
+ default :
974
+ cppcheck::unreachable ();
975
+ }
976
+
977
+ const auto it = std::find_if (info->cbegin (), info->cend (), [&](const checkers::MisraInfo &i) {
959
978
return i.a == a && i.b == b;
960
979
});
961
980
962
- if (it == info.cend ())
963
- return " " ;
964
-
965
- return it->str ;
981
+ return it == info->cend () ? " " : it->str ;
966
982
}
967
983
case ReportType::misraCpp2008:
968
984
case ReportType::misraCpp2023:
@@ -1022,7 +1038,9 @@ std::string getGuideline(const std::string &errId, ReportType reportType,
1022
1038
guideline.begin (), static_cast <int (*)(int )>(std::toupper));
1023
1039
}
1024
1040
break ;
1025
- case ReportType::misraC:
1041
+ case ReportType::misraC2012:
1042
+ case ReportType::misraC2023:
1043
+ case ReportType::misraC2025:
1026
1044
if (errId.rfind (" misra-c20" , 0 ) == 0 || errId.rfind (" premium-misra-c-20" , 0 ) == 0 )
1027
1045
guideline = errId.substr (errId.rfind (' -' ) + 1 );
1028
1046
break ;
@@ -1038,8 +1056,11 @@ std::string getGuideline(const std::string &errId, ReportType reportType,
1038
1056
break ;
1039
1057
}
1040
1058
1041
- if (!guideline.empty ())
1059
+ if (!guideline.empty ()) {
1060
+ if (errId.find (" -dir-" ) != std::string::npos)
1061
+ guideline = " Dir " + guideline;
1042
1062
return guideline;
1063
+ }
1043
1064
1044
1065
auto it = guidelineMapping.find (errId);
1045
1066
@@ -1074,7 +1095,9 @@ std::map<std::string, std::string> createGuidelineMapping(ReportType reportType)
1074
1095
idMapping1 = &checkers::idMappingCertC;
1075
1096
ext1 = " -C" ;
1076
1097
break ;
1077
- case ReportType::misraC:
1098
+ case ReportType::misraC2012:
1099
+ case ReportType::misraC2023:
1100
+ case ReportType::misraC2025:
1078
1101
idMapping1 = &checkers::idMappingMisraC;
1079
1102
break ;
1080
1103
case ReportType::misraCpp2008:
0 commit comments