Hello!
I am working on a new indentation check for clang-tidy.
The idea is to write a generic check that will work no matter if you prefer spaces or tabs or where you like to put { etc. It will just check for some common idioms.
Currently it is designed to warn if there is negative indentation below a if:
void warn1(int x)
{
if (x==0)
{ // CHECK-MESSAGES: :[[@LINE]]:4: warning: unexpected negative indentation below if [readability-indentation]
}
}
I am testing this experimental check right now on various projects. So far it has found 129 warnings in 354 debian projects. I've looked at a few warnings and think it looks good overall. I saw no project that consistently use negative indentations below if.
My work-in-progress code can be seen in the attached patches.
I also have seen that there was related work before to create a Windent flag:
https://llvm.org/bugs/show_bug.cgi?id=18938
Best regards,
Daniel Marjamäki
..................................................................................................................
Daniel Marjamäki Senior Engineer
Evidente ES East AB Warfvinges väg 34 SE-112 51 Stockholm Sweden
Mobile: +46 (0)709 12 42 62
E-mail: Daniel.Marjamaki@evidente.se
www.evidente.se
160129-indentation-clang.diff (3.63 KB)
160129-indentation-extra.diff (6.45 KB)