-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
base: main
Are you sure you want to change the base?
Conversation
70c91e1
to
aed1653
Compare
@firewave I seem to be missing something with the CMake build, could you point me in the right direction? As I understand it all the lib/ sources should be available in the GUI. /~https://github.com/danmar/cppcheck/actions/runs/12446323642/job/34748592068?pr=7096#step:12:141 |
Nevermind, found the problem. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a line in the releasenotes file also.
d4e9dec
to
d337781
Compare
lib/checkers.cpp
Outdated
@@ -2096,3 +2097,183 @@ std::vector<checkers::Info> checkers::certCppInfo{ | |||
{"MSC53-CPP", "L2"}, | |||
{"MSC54-CPP", "L2"}, | |||
}; | |||
|
|||
namespace checkers { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this file is autogenerated so don't change this file. Next time I autogenerate this file to make it uptodate this code will be removed it will be a mess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have a preference for which file these functions should be in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm ideally I think it would be better if this information was dynamic. cppcheck could fetch the list of checkers from premiumaddon at runtime. but that does not feel like a refactoring you should make in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I'm not sure if we're talking about the same functions. The functions I added don't depend on the premiumCheckers
map. Or am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have a preference for which file these functions should be in?
I suggest that it is added in the ErrorLogger.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been working on moving this logic to ErrorLogger
, unfortunatley it seems to be necessary to drag in a bunch of dependencies for the gui tests. Maybe these functions could be in its own file/some other file?
This reverts commit 24485853ad1cfa4d4a43aa1036fe9491e27b056f.
2ecfb14
to
e997eb9
Compare
@@ -1824,6 +1847,15 @@ void CmdLineParser::printHelp() const | |||
" currently only possible to apply the base paths to\n" | |||
" files that are on a lower level in the directory tree.\n" | |||
" --report-progress Report progress messages while checking a file (single job only).\n" | |||
" --report-type=<type> Add guideline and classification fields for specified coding standard.\n" | |||
" The available report types are:\n" | |||
" * normal Default, only show cppcheck error ID and severity)\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ")" seems redundant:
" * normal Default, only show cppcheck error ID and severity)\n" | |
" * normal Default, only show cppcheck error ID and severity\n" |
</term> | ||
<listitem> | ||
<para>Add guideline and classification fields for specified coding standard. The available report types are: | ||
<glosslist><glossentry><glossterm>normal</glossterm><glossdef><para>Default, only show cppcheck error ID and severity)</para></glossdef></glossentry><glossentry><glossterm>autosar</glossterm><glossdef><para>Autosar</para></glossdef></glossentry><glossentry><glossterm>certC</glossterm><glossdef><para>Cert C</para></glossdef></glossentry><glossentry><glossterm>certCpp</glossterm><glossdef><para>Cert Cpp</para></glossdef></glossentry><glossentry><glossterm>misraC</glossterm><glossdef><para>Misra C</para></glossdef></glossentry><glossentry><glossterm>misraCpp2008</glossterm><glossdef><para>Misra C++ 2008</para></glossdef></glossentry><glossentry><glossterm>misraCpp2023</glossterm><glossdef><para>Misra C++ 2023</para></glossdef></glossentry></glosslist> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm I would rather add some newlines here I think if each option was on a separate line that would be more readable.
*/ | ||
CPPCHECKLIB std::vector<std::string> splitString(const std::string& str, char sep); | ||
template<template<class ...> class T = std::vector> | ||
T<std::string> splitString(const std::string& str, char sep) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I see T is always std::vector
so I don't see a good reason to make it a template.
@@ -28,6 +28,7 @@ | |||
#include "platform.h" | |||
#include "standards.h" | |||
#include "suppressions.h" | |||
#include "errorlogger.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't have to include errorlogger.h here. As far as I see you can have a forward declaration of ReportType in settings.h and initialize the Settings::reportType in the constructor. That would probably reduce the dependencies.
ReportType reportType = ReportType::normal; | ||
|
||
/** @brief Maps cppcheck error ids to guidelines */ | ||
std::map<std::string, std::string> guidelineMapping; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
basically if this guidelineMapping map is created and used in ErrorLogger only it feels like it should be in ErrorLogger. But I don't know if there are problems to move it?
@@ -22,6 +22,7 @@ | |||
|
|||
#include "report.h" | |||
#include "showtypes.h" | |||
#include "common.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems unfortunate to replace the forward declaration with a include here.
@@ -24,6 +24,8 @@ | |||
#include <QMap> | |||
#include <QString> | |||
|
|||
#include "errorlogger.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a feeling that maybe it's better that errorlogger.h is included explicitly when needed.
WIP. Will add tests and HTML output.