How to run cpplint recursively for nested directories using glob pattern

If you’re using Google’s original cpplinter then its difficult to support glob pattern on python version < 3.
Google does not maintain the cpplinter. As there are many open PR.

There is a Forked of Google's cpplinter which address most of the missing features from the original version and is actively maintained. Once you switch to the Forked version then you can pass --recursive flag to traverse files recursively. For example,

Solution 1 [For Mac / *nix based systems Only]

$python <> --recursive */* 

Here, */* glob pattern tells it to traverse all the nested files.

Solution 2 [ For Windows and *nix based systems ]

$python <> --recursive <path_to_dir_where_you_want_to_run_linter_recursively> 

For example,

  • foo/bar/zoo/a/b/c/app.cpp
  • foo/bar/zoo/a/b/main.cpp
  • foo/bar/zoo/a/pch.h
$python <> --recursive bar 

will lint all three files nested inside bar directory. This approach works on the Mac / *nix based systems, too.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *