Skip to content

matyalatte/cpplint-cpp

Repository files navigation

cpplint-cpp

License

C++ reimplementation of cpplint 2.0

What is cpplint?

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.

Installation

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

cpplint-cpp vs. cpplint.py

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.

Execution time

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

Memory usage

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

Changes from cpplint.py

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...

Unimplemented features

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.

Building

Requirements

Debug build

You can build cpplint-cpp with the following commands.

meson setup build
meson compile -C build
meson test -C build
./build/cpplint-cpp --version

Release build

You can use presets/release.ini to enable options for release build.

meson setup build --native-file=presets/release.ini
meson compile -C build

Build wheel package

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

Submitting Feature Requests

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.

Contributing

See CONTRIBUTING.md

Credits

This software uses (or is inspired by) several open-source projects. I gratefully acknowledge the work of the following contributors: