Skip to content

Conversation

@firewave
Copy link
Collaborator

@firewave firewave commented Mar 1, 2025

No description provided.

Comment on lines +1634 to +1703
const std::string manualUrl(premium ?
"https://files.cppchecksolutions.com/manual.pdf" :
"https://cppcheck.sourceforge.io/manual.pdf");
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These were switched.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Also we should not have the custom URL hardcoded and read it from cppcheck.cfg like the product name instead. I files https://trac.cppcheck.net/ticket/14208 about this.

@firewave
Copy link
Collaborator Author

firewave commented Mar 1, 2025

This is in preparation of avoiding unmatchedSuppression with premium-* suppressions - see https://trac.cppcheck.net/ticket/13663.

It also gets rid of loading the cppcheck.cfg twice into the settings.

@firewave firewave marked this pull request as draft March 1, 2025 16:21
Comment on lines 29 to 31
"productName": "NAME",
"about": "NAME",
"safety": true
"about": "NAME"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This test was based on the behavior that is loaded cppcheck.cfg first and being overriden by the CLI. But that is not how it was initially implemented. That behavior changed when the double loading was introduced in #5760.

@firewave firewave marked this pull request as ready for review March 1, 2025 16:58
@firewave firewave force-pushed the cmd-premium branch 2 times, most recently from b093636 to 7c9b217 Compare March 1, 2025 22:02
exitcode, _, stderr = cppcheck(['--xml-version=3', '--premium=safety-off', test_file], cppcheck_exe=exe)
exitcode, _, stderr = cppcheck(['--xml-version=3', test_file], cppcheck_exe=exe)
assert exitcode == 0
assert '<safety/>' not in stderr
Copy link
Owner

Choose a reason for hiding this comment

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

Cppcheck Premium should enable safety by default. So I expect <safety/> in xml output unless it's explicitly turned off with --premium=safety-off.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Cppcheck Premium should enable safety by default.

That means that it is explicitly enabled in cppcheck.cfg, right? Should it even be allowed to be disabled by default if it is premium (i.e. <safety> is missing or set to false)?

What about --no-safety? May it also override the premium safety (default)? Or should that be limited to --premium=safety-off?

I would be fine having special handling for the safety flag. I just would have it properly defined.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@danmar I need feedback on this to proceed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@danmar Still need feedback to be able to proceed.

Copy link
Owner

@danmar danmar Jun 12, 2025

Choose a reason for hiding this comment

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

That means that it is explicitly enabled in cppcheck.cfg, right?

yes.

Should it even be allowed to be disabled by default if it is premium (i.e. is missing or set to false)?

We can allow that it's off.

If the user provides --safety or --safety-off on the command line then those options should override what the cppcheck.cfg says.

imho if there is missing safety option in cppcheck.cfg then safety should be off by default.

my intention is that cppcheck.cfg is a general purpose interface so that everybody can customize cppcheck if they want to, maybe somebody wants that cppcheck will always execute certain extra addons.. there should be a minimum of cppcheck premium specific code in open source cppcheck.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@danmar Still need feedback to proceed.

FYI If this weren't premium-related I would have just defined things and merged it by now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks, I will get rid of any special handling.

That also makes safety within --premium redundant and I think we should deprecate/remove it.

exitcode, _, stderr = cppcheck(['--premium=autosar', '--xml', test_file], cppcheck_exe=exe)
assert exitcode == 0
assert 'id="unusedVariable"' in stderr
assert 'id="checkersReport"' not in stderr
Copy link
Owner

Choose a reason for hiding this comment

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

I expect to see checkersReport in the Cppcheck Premium output unless --premium=safety-off is provided.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That is because the config used in the test doesn't have safety set. The changes in this PR removed that it is always implicitly enabled.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually I removed it in the changes and inverted the checks. I reverted that change.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The actual problem is that cppcheck.cfg is read after the CLI options because of the assumption that the config should override those.

@firewave firewave marked this pull request as draft March 19, 2025 08:15
@firewave firewave force-pushed the cmd-premium branch 2 times, most recently from d342511 to 4979097 Compare September 25, 2025 10:31
@firewave firewave marked this pull request as ready for review September 25, 2025 10:31
Copy link
Owner

@danmar danmar left a comment

Choose a reason for hiding this comment

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

sorry I had this review comment pending.. hope it helps

exitcode, _, stderr = cppcheck(['--xml-version=3', '--premium=safety-off', test_file], cppcheck_exe=exe)
exitcode, _, stderr = cppcheck(['--xml-version=3', test_file], cppcheck_exe=exe)
assert exitcode == 0
assert '<safety/>' not in stderr
Copy link
Owner

@danmar danmar Jun 12, 2025

Choose a reason for hiding this comment

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

That means that it is explicitly enabled in cppcheck.cfg, right?

yes.

Should it even be allowed to be disabled by default if it is premium (i.e. is missing or set to false)?

We can allow that it's off.

If the user provides --safety or --safety-off on the command line then those options should override what the cppcheck.cfg says.

imho if there is missing safety option in cppcheck.cfg then safety should be off by default.

my intention is that cppcheck.cfg is a general purpose interface so that everybody can customize cppcheck if they want to, maybe somebody wants that cppcheck will always execute certain extra addons.. there should be a minimum of cppcheck premium specific code in open source cppcheck.

@firewave
Copy link
Collaborator Author

Looks like this is already complete.

I did not check if the non-premium and premium CLI flags are correctly working with each other. I think it is fine to assume that they are currently not being mixed and if we deprecate one set of them that should also not be an issue going forward.

@firewave firewave force-pushed the cmd-premium branch 4 times, most recently from b49b051 to e9acdd4 Compare October 15, 2025 02:41
@firewave firewave marked this pull request as draft October 15, 2025 03:02
@firewave

This comment was marked as resolved.

@firewave firewave force-pushed the cmd-premium branch 3 times, most recently from 6ac9ee0 to aabc350 Compare October 15, 2025 19:12
@firewave firewave marked this pull request as ready for review October 17, 2025 12:13
@sonarqubecloud
Copy link

@firewave
Copy link
Collaborator Author

Anything still to do here? I have several follow-ups lined up.

return false;
}

settings.premium = startsWith(settings.cppcheckCfgProductName, "Cppcheck Premium");
Copy link
Owner

Choose a reason for hiding this comment

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

it feels like this line of code belongs in LIB?

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