-
Notifications
You must be signed in to change notification settings - Fork 293
Open
Description
I have encountered a few patterns of false positives for whitespace/indent_namespace
.
All of them occur with the member initializer lists, which have multiple lines.
I hope this will be helpful for improvement.
cpplint version: 2.0.2
$ cpplint --version
Cpplint fork (https://github.com/cpplint/cpplint)
cpplint 2.0.2
Python 3.12.9 (main, Feb 4 2025, 14:38:38) [Clang 16.0.0 (clang-1600.0.26.6)]
case1: constructor with an empty body
namespace cpplint_issue {
class TestIndentNamespaceWithEmptyBody {
public:
explicit TestIndentNamespaceWithEmptyBody(const int a);
private:
const int number;
const int looooooong_attr1;
const int looooooong_attr2;
const int looooooong_attr3;
const int looooooong_attr4;
};
TestIndentNamespaceWithEmptyBody::TestIndentNamespaceWithEmptyBody(const int a)
: number(a),
looooooong_attr1(0),
looooooong_attr2(0),
looooooong_attr3(0),
looooooong_attr4(0) {} // <- This line causes a false positive.
} // namespace cpplint_issue
case2: use inline specifier
namespace cpplint_issue {
class TestIndentNamespaceWithInline {
public:
explicit TestIndentNamespaceWithInline(const int a);
private:
const int number;
const int looooooong_attr1;
const int looooooong_attr2;
const int looooooong_attr3;
const int looooooong_attr4;
};
inline TestIndentNamespaceWithInline::TestIndentNamespaceWithInline(const int a)
: number(a), // <- These lines cause a false positive.
looooooong_attr1(0), // <-
looooooong_attr2(0), // <-
looooooong_attr3(0), // <-
looooooong_attr4(0) { // <-
// do nothing
}
} // namespace cpplint_issue
case3: with a struct variable
namespace cpplint_issue {
struct Params {
int number;
};
class TestIndentNamespaceWithStructMember {
public:
explicit TestIndentNamespaceWithStructMember(const int a);
private:
const Params params;
const int looooooong_attr1;
const int looooooong_attr2;
const int looooooong_attr3;
const int looooooong_attr4;
};
TestIndentNamespaceWithStructMember::TestIndentNamespaceWithStructMember(const int a)
: params({a}),
looooooong_attr1(0), // <- These lines cause a false positive.
looooooong_attr2(0), // <-
looooooong_attr3(0), // <-
looooooong_attr4(0) { // <-
// do nothing
}
} // namespace cpplint_issue
wushenrong, fruffy and Bouncner