JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.
If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.
If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.
| CodeSonar® 9.2p0 | CONFIDENTIAL | CodeSecure Inc |
Two code regions are structurally highly similar but not identical.
The purpose of this check is to identify cases where code has been copied and pasted into a new context, but then adjusted to the new context in a way that does not preserve semantics. For example, variables may have have been renamed but one or more occurrences did not receive the correct new name.
To avoid issuing large numbers of spurious warnings, CodeSonar is tuned to report only cases where the two code regions are reasonably complex.
| Class Name | Copy-Paste Error | |||
|---|---|---|---|---|
| Significance | reliability | |||
| Mnemonic | MISC.CPE | |||
| Categories |
|
|||
| Availability | Available for all languages.
|
|||
| Enabling | Checks for this warning class are enabled by
default. To disable them, add the following WARNING_FILTER rule to the
project configuration file.
WARNING_FILTER += discard class="Copy-Paste Error" |
int MISC_CPE(int a, int b, int c) {
int x = 0;
int y = 0;
if (a > 5){
x = x + a;
y = y + a;
}
if (b > 5){
x = x + b;
y = y + a; /* "Copy-Paste Error" warning issued here:
* CodeSonar suspects that this was copy-pasted from the first IF statement
* and then then some - but not all - occurrences of variable a changed to b */
}
if (c > 5){
x = x + c;
y = y + c; /* ok */
}
return x+y;
}
The following configuration file parameters affect checks for this warning class.
To report problems with this documentation, please visit https://support.codesecure.com/.