rspec/rules/S895/rule.adoc

39 lines
819 B
Plaintext
Raw Normal View History

Variables declared and never used in a project constitute noise and may indicate that the wrong variable name has been used somewhere. Removing these declarations reduces the possibility that they may later be used instead of the correct variable.
2021-02-02 15:02:10 +01:00
If padding is used within bit-fields, then the padding members should be unnamed to avoid violation of this rule.
== Noncompliant Code Example
----
extern void usefn ( int16_t a, int16_t b );
class C
{
// ...
};
C c; // Non-compliant - unused
void withunusedvar ( void )
{
int16_t unusedvar; // Noncompliant unused
struct s_tag
{
signed int a : 3;
signed int pad : 1; // Noncompliant should be unnamed
signed int b : 2;
} s_var;
s_var.a = 0;
s_var.b = 0;
usefn ( s_var.a, s_var.b );
}
----
== See
2021-01-26 14:30:57 +01:00
* MISRA {cpp}:2008, 0-1-3