rspec/rules/S3395/rule.adoc

34 lines
548 B
Plaintext
Raw Normal View History

Classes defined inside functions, called local classes, are only visible within those functions. They have advantages in some situations, but if they're just being used as functors, lambdas are preferred.
2021-02-02 15:02:10 +01:00
2021-01-27 13:42:22 +01:00
This rule raises an issue when a ``++class++`` or ``++struct++`` is defined inside a function.
== Noncompliant Code Example
----
void doSomething() {
struct something { // Noncompliant
int a;
};
//...
}
----
== Compliant Solution
----
struct something { // Noncompliant
int a;
};
void doSomething() {
//...
}
----