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 #13362: Misra report on command line #7096

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

ludviggunne
Copy link
Contributor

WIP. Will add tests and HTML output.


const std::vector<checkers::MisraInfo> &info = checkers::misraC2012Rules;
const auto it = std::find_if(info.cbegin(), info.cend(), [&](const checkers::MisraInfo &i) {
return i.a == std::stoi(components[0]) && i.b == std::stoi(components[1]);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::stoi twice for each entry in info..

@@ -1417,6 +1419,125 @@ void CppCheck::executeAddons(const std::string& dumpFile, const FileWithDetails&
}
}

void CppCheck::setClassification(ErrorMessage &errMsg) const {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ultimate goal would be that we only have functions to determine classification and guideline in one place. Right now we have it in both lib and gui.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a use case in the GUI that the report type is changed after the analysis. Therefore the GUI needs to be able to take existing results and determine classification and guideline.
The GUI doesn't store the original ErrorMessage objects though as far as I remember. I therefore think it would be preferable if these functions did not use the whole ErrorMessage object.

@@ -480,7 +480,11 @@ std::string ErrorMessage::toXML() const
tinyxml2::XMLPrinter printer(nullptr, false, 2);
printer.OpenElement("error", false);
printer.PushAttribute("id", id.c_str());
if (!guideline.empty())
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You will need to tweak ErrorLogger::serialize and ErrorLogger::deserialize also otherwise it will not always work when running multiple threads with -j2

@@ -1504,6 +1625,9 @@ void CppCheck::executeAddons(const std::vector<std::string>& files, const std::s
}
errmsg.file0 = file0;

setGuideline(errmsg);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible to adjust the guideline and classification here directly. It would also be possible to do it a bit later.
One advantage with doing it later would be that it avoids the serialization/deserialization problem.

However if we do it here then we should tweak the GUI.. it means the GUI doesn't need to determine the classification/guideline anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants