Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #13029 (Update checkers report: Misra C directives) #6712

Merged
merged 1 commit into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions lib/checkers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,31 @@ namespace checkers {
const char Man[] = "Mandatory";
const char Doc[] = "Document";

const std::vector<MisraInfo> misraC2012Directives =
{
{1,1,Req,0},
{2,1,Req,0},
{3,1,Req,0},
{4,1,Req,0},
{4,2,Adv,0},
{4,3,Req,0},
{4,4,Adv,0},
{4,5,Adv,0},
{4,6,Adv,3},
{4,7,Req,0},
{4,8,Adv,0},
{4,9,Adv,3},
{4,10,Req,0},
{4,11,Req,3},
{4,12,Req,0},
{4,13,Adv,0},
{4,14,Req,2},
{4,15,Req,3},
{5,1,Req,4},
{5,2,Req,4},
{5,3,Req,4},
};

const std::vector<MisraInfo> misraC2012Rules =
{
{1,1,Req,0},
Expand Down
1 change: 1 addition & 0 deletions lib/checkers.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ namespace checkers {
extern CPPCHECKLIB const char Man[]; // = "Mandatory";
extern CPPCHECKLIB const char Doc[]; // = "Document";

extern CPPCHECKLIB const std::vector<MisraInfo> misraC2012Directives;
extern CPPCHECKLIB const std::vector<MisraInfo> misraC2012Rules;
extern CPPCHECKLIB const std::vector<MisraCppInfo> misraCpp2008Rules;
extern CPPCHECKLIB const std::vector<MisraCppInfo> misraCpp2023Rules;
Expand Down
13 changes: 12 additions & 1 deletion lib/checkersreport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,17 @@ std::string CheckersReport::getReport(const std::string& criticalErrors) const
fout << std::endl << std::endl;
fout << "Misra C " << misra << std::endl;
fout << "------------" << std::endl;
for (const checkers::MisraInfo& info: checkers::misraC2012Directives) {
const std::string directive = "Dir " + std::to_string(info.a) + "." + std::to_string(info.b);
const bool active = isMisraRuleActive(mActiveCheckers, directive);
fout << (active ? "Yes " : "No ") << "Misra C " << misra << ": " << directive;
std::string extra;
if (misra == 2012 && info.amendment >= 1)
extra = " amendment:" + std::to_string(info.amendment);
if (!extra.empty())
fout << std::string(10 - directive.size(), ' ') << extra;
fout << '\n';
}
for (const checkers::MisraInfo& info: checkers::misraC2012Rules) {
const std::string rule = std::to_string(info.a) + "." + std::to_string(info.b);
const bool active = isMisraRuleActive(mActiveCheckers, rule);
Expand All @@ -254,7 +265,7 @@ std::string CheckersReport::getReport(const std::string& criticalErrors) const
if (!active && !reqs.empty())
extra += " require:" + reqs.substr(1);
if (!extra.empty())
fout << std::string(7 - rule.size(), ' ') << extra;
fout << std::string(10 - rule.size(), ' ') << extra;
fout << '\n';
}
}
Expand Down
Loading