C++: Omit assign case from cpp/non-constant-format
#14039
+0
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Running the following on
1000996 MRVA projects gave 1 result:Where both A and B are modules that both contain all the non-constant format code, except that B omits the lines also omitted in this PR. The one result comes from here with the source being the assignment in the
ifone line above it. However, this is an FP as the (virtual) function only ever returns constant strings without any formatting directives.DCA shows one missing result on Nelson, but it seems that one is not being flagged up for the reason it should be:
The query (after modification) highlights two sources:
I agree that this is a TF. However, the reason it's being flagged up is silly, i.e., because an assignment occurs on the right hand side of the the assignment to the element of
str_fmt. It seems that the query should actually try to detect whether mutable arrays are used as format strings instead of relying on an accidental occurring assignment on the right-hand side.