Skip to content

Fix copy-paste-error#5444

Merged
danmar merged 1 commit into
cppcheck-opensource:mainfrom
CodeSecure-SE:feature/fix-copy-paste-error
Sep 13, 2023
Merged

Fix copy-paste-error#5444
danmar merged 1 commit into
cppcheck-opensource:mainfrom
CodeSecure-SE:feature/fix-copy-paste-error

Conversation

@markhermeling
Copy link
Copy Markdown
Contributor

This is a warning we found during static analyis with CodeSecure CodeSonar.

It flagged a suspicious copy-paste error, where it finds code that seems to have been copied from another location, with some, but not all, variables substituted.

Unclear to me if this truly is a problem, or intentional, but I wanted to provide the feedback as I am not sure how to test this.

Lines 5614 to 5619 in lib/symboldatabase.cpp are a copy from 5597-5602 with vartok replaced by valuetok, except for line 5616

@danmar
Copy link
Copy Markdown
Collaborator

danmar commented Sep 13, 2023

hmm.. if arguments[j] is a "::" token then as far as I see vartok and valuetok will be the same. so as far as I see, technically this makes no difference.

Your change looks reasonable to me. It seems reasonable to use valuetok instead of vartok there.

@danmar danmar merged commit 6e6b374 into cppcheck-opensource:main Sep 13, 2023
@danmar
Copy link
Copy Markdown
Collaborator

danmar commented Sep 13, 2023

Thanks for your contribution!

I am not sure if I see a good heuristic we can have to spot this also. If somebody can think of a good heuristic it would be great to create a Trac issue and describe the heuristic. A good heuristic should ideally not generate false positives for real code.

@danmar
Copy link
Copy Markdown
Collaborator

danmar commented Sep 13, 2023

I added your name in our AUTHORS file: 11e5c11

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