Code style carries many benefits, such as improved maintainability and support for a rich Coding Standard. However it’s not safe to rely on developers to always comply to style rules along the source code, that’s why automatic code style verification should be an initial concern for professional-level works.
For Qt projects, astyle is the recommended tool. But there are a few drawbacks on using it.
- it’s too intrusive. astyle performs code modification in-line, disturbing the repository sources instead of serving as a verification tool only
- weak didactic factor. Unlike pep8 script, which tells the developer exactly what the problem is and contributes to avoid it at the future (as a lesson learned effect)
- it’s output can not be easily integrated with another tools
I’ve created a shell script in order to overcome some of the previous issues. It’s available here. Some relevant features.
- quickfix-style list output
- QTest style output at the end
- Ignore moc created files
- All suggested modifications can be applied as one patch, directly available to the user
- Can be run inside a testsuite (make test) or as a standalone program
- try to extend astyle classes
- allow alternative code styles
- better source selection schema (integrated with qmake, maybe?)
- fix-up improper indentation on some important macros (foreach, .e.g.)
- test and make it work on MacOS