Skip to content

Conversation

@ludviggunne
Copy link
Collaborator

No description provided.

bool polyspace::isPolyspaceComment(const std::string &comment)
{
std::string::size_type pos = 0;
while (pos < comment.size() && std::strchr("/* ", comment[pos]))

Check warning

Code scanning / Cppcheck Premium

Condition 'comment.size()-pos<polyspace.size()' is always true Warning

Condition 'comment.size()-pos<polyspace.size()' is always true
bool convert(SuppressionList::Suppression &suppr) const;
};

class Parser {

Check warning

Code scanning / Cppcheck Premium

The class 'Parser' does not declare a constructor although it has private member variables which likely require initialization. Warning

The class 'Parser' does not declare a constructor although it has private member variables which likely require initialization.
@sonarqubecloud
Copy link

return mPeeked;
}

if (mComment.size() >= 2 && (mComment.substr(0, 2) == "/*" || mComment.substr(0, 2) == "//")) {
Copy link
Owner

Choose a reason for hiding this comment

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

use mComment.compare instead. Hmm.. I think that the mComment.size() >= 2 && is redundant however it's not bad to be explicitly safe.

bool polyspace::Suppression::convert(SuppressionList::Suppression &suppr) const
{
static const std::map<std::string, std::string> map = {
{ "MISRA-C3", "premium-misra-c-2012-" },
Copy link
Owner

Choose a reason for hiding this comment

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

if Settings::premiumArgs is nonempty (or contains misra-c-2012) then premium-misra-c-2012- is correct. Otherwise I think we can say misra-c2012- here

Comment on lines +862 to +864
if (comment.size() - pos < polyspace.size())
return false;
return comment.substr(pos, polyspace.size()) == polyspace;
Copy link
Owner

Choose a reason for hiding this comment

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

Something like this will do the same

Suggested change
if (comment.size() - pos < polyspace.size())
return false;
return comment.substr(pos, polyspace.size()) == polyspace;
return comment.compare(pos, polyspace.size(), polyspace, 0, polyspace.size()) == 0;

bool polyspace::isPolyspaceComment(const std::string &comment)
{
std::string::size_type pos = 0;
while (pos < comment.size() && std::strchr("/* ", comment[pos]))
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
while (pos < comment.size() && std::strchr("/* ", comment[pos]))
pos = comment.find_first_not_of("/* ");

Comment on lines +35 to +36
#include <simplecpp.h>

Copy link
Collaborator

Choose a reason for hiding this comment

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

No need for this include as you can just forward declare simplecpp::Token.

@firewave
Copy link
Collaborator

Should this be behind a flag? Always parsing for something very niche (and premium only?) seems undesired.

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.

3 participants