Skip to content

Conversation

@GNL10
Copy link
Contributor

@GNL10 GNL10 commented Oct 25, 2025

No description provided.

@GNL10
Copy link
Contributor Author

GNL10 commented Oct 25, 2025

Currently after the UTs finish there is a file that does not get deleted (e.g. outputfile_18314070737314589129.plist).
This is caused by the UT added in this PR. When reportErr is called inside in the negative scenario.

Not entirely sure what the most appropriate way to delete that file should be.

lib/cppcheck.cpp Outdated
const std::size_t dotPosition = filename.find('.');

if (dotPosition == std::string::npos) {
ErrorMessage::FileLocation loc(filename, 0, 0);
Copy link
Owner

Choose a reason for hiding this comment

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

Cppcheck will not check files without extension unless they are explicitly added somehow. So it's not analyzed by mistake.

Can we try to handle such files instead.. if there is no dot then skip the substr below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm I think in the end there might be no issues with the code at all.

The initial issue was pointing to this:
filename2.substr(0, filename2.find('.'))

However filename2.substr(0, std::string::npos) is valid. It basically just keeps the string unchanged and copies it from start to finish.
It isn't immediately obvious, but it is what happens.

GNL10 added 2 commits October 27, 2025 23:32
When file does not have suffix, the full name is used.
@sonarqubecloud
Copy link

@danmar
Copy link
Owner

danmar commented Oct 28, 2025

I like this PR. But CI fails right now.

@danmar
Copy link
Owner

danmar commented Oct 28, 2025

strange it seems to complain about the test you added:
https://github.com/danmar/cppcheck/actions/runs/18859083744/job/53813515383?pr=7911#step:11:132

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