Running CPPlint on whole project
Asked Answered
A

5

8

I want to run cpplint.py on my whole project not for single file to get a report for all C/C++ files in the project. How to do this on macOS and Windows?

Alleenallegation answered 9/7, 2015 at 5:0 Comment(0)
A
4

I have just find answer for some part of my question under this great post

"Shell Foo: Getting a cpplint Breakdown Report On All Project Source Files"

Here is the way how to run cpplint for a project on a Mac

.python cpplint.py --linelength=120 --counting=detailed $( find . -name \*.h -or -name \*.cc | grep -vE "^\.\/build\/" )

For Windows there is a post about integration in Visual Studio. How to integrate cpplint.py into Visual Studio

Alleenallegation answered 9/7, 2015 at 5:29 Comment(1)
$( find . -name \*.h -or -name \*.cc | grep -vE "^./build/" ) escape the * sNiemann
L
4

I am using Ubuntu, so my experience is just reference.

./cpplint.py ~/projects/* ~/projects/*/*
# or you can:
./cpplint.py ~/projects/*.* ~/projects/*/*.*
Luanaluanda answered 1/9, 2016 at 6:48 Comment(0)
Z
2

If you want to execute cpplint on all folder recursively, in Ubuntu you can use:

find FOLDER_PATH -iname *.h -iname *.cpp | xargs cpplint

where FOLDER_PATH is relative or full path to your project folder, also you can specify which files you want to check by name or by extensions and you can concatenate as many you need times,

find FOLDER_PATH -iname *.h  -iname *.cpp -iname *.java

in my case, i run cpplint inside my project folder and i want to check src folder, so for me it's

find ./src -iname *.h  -iname *.cc | xargs cpplint
Zloty answered 21/7, 2020 at 9:11 Comment(0)
B
0

7 year old question. But I just wanted to add that on Windows, you can use PowerShell of course. This is the script that I use, which recurses through every folder from the location where the script is executed, only takes files, and filters on the extensions specified in the array:

ForEach(                                                                   `
$item in Get-ChildItem                                                     `
    -Path .                                                                `
    -Recurse                                                               `
    -Include *.cc, *.cpp, *cxx, *.h, *.hpp                                 `
    | Where { ! $_.PSIsContainer }) {
    python -m cpplint --linelength=80 $item 
}
Bo answered 4/11, 2022 at 8:21 Comment(0)
L
0

There is a fork of cpplink on GitHub, which is available via PyPI:

pip install cpplint

Since Dec 6, 2015 it has a --recursive argument for cpplint

From cpplint --help:

Search for files to lint recursively. Each directory given in the list of files to be linted is replaced by all files that descend from that directory. Files with extensions not in the valid extensions list are excluded.

Below is an example of linting recursively on the src/ folder:

cpplint --quiet --counting=detailed --linelength=120 --recursive src/

Default linted extensions are ['c', 'c++', 'cc', 'cpp', 'cu', 'cuh', 'cxx', 'h', 'h++', 'hh', 'hpp', 'hxx']. Other file types will be ignored. Change the extensions with the --extensions flag.

Ledge answered 23/12, 2022 at 4:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.