summaryrefslogtreecommitdiff
path: root/utils/checkstyle.py
AgeCommit message (Collapse)Author
2019-07-01utils: checkstyle.py: Refactor formatters and checkers supportLaurent Pinchart
Introduce two new base classes for the code formatters and style checkers, with an auto-registration mechanism that automatically uses all derived classes. This will allow easier addition of new formatters and checkers. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-02-13utils: checkstyle: Catch LOG() usage without an explicit categoryLaurent Pinchart
Add support for checkers not related to code formatting to the checkstyle.py script, and create a first checker that catches usage of the LOG() macro without an explicit category. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-01-22utils: checkstyle: Add support for clang-formatLaurent Pinchart
clang-format produces better results than astyle as it can better match the libcamera coding style. Default to clang-format over astyle, fall back to astyle if clang-format isn't found, and add a --formatter command line option to select a formatter manually. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2018-12-21utils: checkstyle: add keep-one-line-blocksKieran Bingham
Enable --keep-one-line-blocks to prevent astyle from wanting to move single inlined blocks to cover 4 lines such as: - virtual int init() { return 0; } + virtual int init() + { + return 0; + } Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2018-12-19utils: checkstyle.py: Strip trailing white spacesLaurent Pinchart
As astyle doesn't strip trailing white spaces, strip them manually. Organize the code to allow for new additional formatting steps if needed. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2018-12-19utils: checkstyle.py: Highlight trailing white space at end of lineLaurent Pinchart
In order to facilitate interpretation of diffs, highlight trailing white space at end of lines with a red background. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2018-12-19utils: checkstyle.py: Support execution from non-root directoriesLaurent Pinchart
The git diff command is invoked with relative paths, which causes git to fail to locate files when the checkstyle.py script is run from subdirectories of the git tree. Fix this by prepending the absolute path to the git tree root directory to the file names. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2018-12-14utils: Add Python-based commit style checker scriptLaurent Pinchart
checkstyle.py is a reimplementation of checkstyle.sh in Python, that should be easier to extend with additional features. Three additional features and enhancements are already implemented: - While retaining the default behaviour of operating on the HEAD commit, a list of commits can also be specified on the command line. - Correct line numbers are printed in the diff output. - The index and working tree are not touched, they can be dirty. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>