-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Open
Labels
Description
#include <iostream>
class A {
public:
int a;
int b;
explicit operator double(this const A& self) { return self.a + self.b; }
};
auto main(std::int32_t /*argc*/, const char* /*argv*/[]) -> std::int32_t {
auto c = A{.a = 1, .b = 2};
double d = double(c);
std::cout << d;
}
clang-tidy main.cpp
5809 warnings generated.
main.cpp:12:8: warning: variable name 'c' is too short, expected at least 3 characters [readability-identifier-length]
12 | auto c = A{.a = 1, .b = 2};
| ^
main.cpp:13:3: warning: use auto when initializing with a cast to avoid duplicating the type name [hicpp-use-auto]
13 | double d = double(c);
| ^~~~~~
| auto
main.cpp:13:10: warning: variable name 'd' is too short, expected at least 3 characters [readability-identifier-length]
13 | double d = double(c);
| ^
main.cpp:13:14: warning: redundant cast to the same type [google-readability-casting]
13 | double d = double(c);
| ^
note: this fix will not be applied because it overlaps with another fix
main.cpp:13:14: warning: redundant explicit casting to the same type 'double' as the sub-expression, remove this casting [readability-redundant-casting]
13 | double d = double(c);
| ^~~~~~~ ~
main.cpp:8:12: note: source type originates from the invocation of this method
8 | explicit operator double(this const A& self) { return self.a + self.b; }
| ^
Suppressed 5804 warnings (5804 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.