Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

60 lines
1.4 KiB
Plaintext
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

== Why is this an issue?
Unless you are in a library codebase context, functions that are declared in your program but never executed are dead code that should be removed. Cleaning out dead code decreases the size of the maintained codebase, making it easier to understand the program and preventing bugs from being introduced.
*Note:* S1144 is a subset of this rule; hence, it should be deactivated when this rule is activated.
=== Noncompliant code example
[source,cpp]
----
void unusedStaticFunction() { // Noncompliant
}
void unusedGlobalFunction() { // Noncompliant: it is not called in the entire program
}
void undefinedGlobalFunction(); // Noncompliant
class A {
public:
A(int i) : i(i){} // Compliant it is called in "main"
void startUsed() { // Compliant, the member function "startUsed" is called in "main"
}
void startUnused() { // Noncompliant, the member function "startUnused" is not called in the program
}
private:
A(): i(0) { // Compliant, private and deleted constructor are an exception
}
int i;
};
int main() // Compliant, "main" is an exception.
{
A a{2};
a.startUsed();
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Remove this unused function.
'''
== Comments And Links
(visible only on this page)
=== relates to: S1144
endif::env-github,rspecator-view[]