C++ reimplementation of cpplint 2.0
Cpplint is a command-line tool to check C/C++ files for style issues according to Google's C++ style guide. It used to be developed and maintained by Google Inc. One of its forks now maintains the project.
You can install the cpplint-cpp
command via pip.
pip install cpplint-cpp --no-index --find-links https://matyalatte.github.io/cpplint-cpp/packages.html
Here is an analysis of the performance differences between cpplint-cpp
and cpplint.py
against two repositories:
googletest
and cpplint-cpp
.
Measurements were taken on an Ubuntu runner with some scripts.
You can see cpplint-cpp
has significantly better performance, being over 30 times faster than cpplint.py
.
googletest-1.14.0 (s) | cpplint-cpp (s) | |
---|---|---|
cpplint-cpp | 0.439020 | 0.092547 |
cpplint.py | 21.639285 | 3.782867 |
Despite using multithreading with 4 cores, cpplint-cpp
has lower memory usage than cpplint.py
.
googletest-1.14.0 | cpplint-cpp | |
---|---|---|
cpplint-cpp | 15.46 MiB | 10.45 MiB |
cpplint.py | 23.08 MiB | 22.57 MiB |
Basically, cpplint-cpp
uses the same algorithm as cpplint.py
, but some changes have been made to reduce processing time.
- Added concurrent file processing.
- Removed some redundant function calls.
- Used JIT compiler for some regex patterns.
- Combined some regex patterns.
- Added
--timing
option to display the execution time. - Added
--threads=
option to specify the number of threads. - And other minor changes for optimization...
cpplint-cpp is a WIP project. Please note that the following features are not implemented yet.
- JUnit style outputs.
- Multibyte characters in stdin on Windows.
- Meson
- C++20 compiler
You can build cpplint-cpp
with the following commands.
meson setup build
meson compile -C build
meson test -C build
./build/cpplint-cpp --version
You can use presets/release.ini
to enable options for release build.
meson setup build --native-file=presets/release.ini
meson compile -C build
You can make a pip package with the following commands.
mkdir dist
cp ./build/cpplint-cpp ./dist
cp ./build/version.h ./dist
pip install build
python -m build
I do not accept feature requests related to cpplint specifications, including the addition of new rules. For such requests, please visit the original cpplint project to submit your suggestions.
See CONTRIBUTING.md
This software uses (or is inspired by) several open-source projects. I gratefully acknowledge the work of the following contributors:
-
Google Style Guides by Google Inc.
- Contribution: Original implementation of
cpplint.py
. - License: Apache License 2.0
- Contribution: Original implementation of
-
- Contribution: Latest updates of
cpplint.py
. - License: BSD 3-Clause License
- Contribution: Latest updates of
-
- Contribution: Regex matching.
- License: PCRE2 LICENCE
-
ThreadPool by progschj
- Contribution: Thread pool implementation
- License: zlib License
-
widechar_width.h by ridiculousfish
- Contribution: Reference tables for character widths.
- License: CC0 Public Domain