You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[clang-tidy][modernize-use-starts-ends-with] Fix minor mistake in error message
In one of the cases recently added to this check in #110448, the error message is no longer accurate as the comparison is not with zero. #116033 brought my attention to this as it may add another comparison without zero.
Remove the `[!=] 0` part of the diagnostic. This is in line with some other checks e.g. modernize-use-emplace.
```
> cat tmp.cpp
#include <string>
bool f(std::string u, std::string v) {
return u.rfind(v) == u.size() - v.size();
}
# Before.
> ./build/bin/clang-tidy -checks="-*,modernize-use-starts-ends-with" tmp.cpp -- -std=c++20
tmp.cpp:3:12: warning: use ends_with instead of rfind() == 0 [modernize-use-starts-ends-with]
3 | return u.rfind(v) == u.size() - v.size();
| ^~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~
| ends_with( )
# After.
> ./build/bin/clang-tidy -checks="-*,modernize-use-starts-ends-with" tmp.cpp -- -std=c++20
tmp.cpp:3:12: warning: use ends_with instead of rfind [modernize-use-starts-ends-with]
3 | return u.rfind(v) == u.size() - v.size();
| ^~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~
| ends_with( )
```
0 commit comments