Questions tagged [cpplint]

cpplint is an open source lint-like tool developed by Google, designed to ensure that C++ code conforms to Google's coding style guides. It reads source code files and flags deviations from the style guide. It suffers from both false positives and false negatives. False positives can be eliminated by tagging lines with //NOLINT. cpplint is implemented as Python script.

Source: http://en.wikipedia.org/wiki/Cpplint

cpplint implements what Google considers to be "best practices" in C++ coding. It also identifies syntax errors. It is rules based, and uses a number of heuristics to identify bad code.

52 questions
16
votes
2 answers

Should I use rand() or rand_r()?

I'm trying to get a random number in C++ and I'm using rand(). This is what cpplint says: Consider using rand_r(...) instead of rand(...) for improved thread safety. I'm switching to rand_r and this is what cppcheck says: Obsolete function…
Barbara Krein
  • 329
  • 2
  • 7
16
votes
4 answers

Google's style guide about input/output parameters as pointers

The Google C++ Style Guide draws a clear distinction (strictly followed by cpplint.py) between input parameters(→ const ref, value) and input-output or output parameters (→ non const pointers) : Parameters to C/C++ functions are either input to the…
suizokukan
  • 1,303
  • 4
  • 18
  • 33
15
votes
1 answer

Disable specific warnings from cpplint

When running cpplint, I run into some warnings that I'd like to completely disable. Specifically the copyright message & whitespaces: range.h:0: No copyright message found. You should have a line: "Copyright [year] " [legal/copyright]…
AnilRedshift
  • 7,937
  • 7
  • 35
  • 59
15
votes
2 answers

Why does cpplint discourage Streams?

I was just playing around with cpplint and tried running it on some code I had written for fun. I realized that the following lines were flagged with the error message :- #include ... #include yoohoo.cpp:3: Streams are highly…
user277465
12
votes
6 answers

difference between if(pointer) vs if(pointer != NULL) in c++, cpplint issue

I already checked this post Can I use if (pointer) instead of if (pointer != NULL)? and some other posts on net. But it is not stating any difference between two statements. Problem: As I run cpplint.py on my cpp code, I found issues where I check…
ashish
  • 319
  • 2
  • 12
8
votes
5 answers

Running CPPlint on whole project

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?
T M
  • 3,195
  • 2
  • 31
  • 52
6
votes
1 answer

How to make vim run "cpplint" after every "save" command?

I wish that each time I ":w" to save a .h/.cpp file in vim, vim will automatically run cpplint to check my format, and change the file if needed. How to specify this with autocmd? Thanks.
Troskyvs
  • 7,537
  • 7
  • 47
  • 115
5
votes
1 answer

cpplint.py & cmake: how to specify include files

Assume I have a project of the following directory structure: myproject ├── .git [...] ├── CMakeLists.txt └── src ├── CMakeLists.txt ├── foo.cc └── foo.h If in src/foo.cc I include the header file like #include "foo.h" and then run…
Georg P.
  • 2,785
  • 2
  • 27
  • 53
4
votes
0 answers

Google cpplint integration in QtCreator

Is it possible to integrate Google's cpplint in QtCreator? I've looked for a plugin or another way of integration but so far my search hasn't produced any results.
Radoslav Hristov
  • 1,032
  • 1
  • 10
  • 22
4
votes
1 answer

Cpplint could not find executable

I am trying to activate cpplint within vs code. I have installed it in Anacanda environment where executable /home/ubuntu/anaconda3/bin/cpplint I have a link to it ls -l /home/ubuntu/anaconda3/bin/cpplint Unfortunately per visual code cpplint…
user3428154
  • 1,174
  • 5
  • 18
  • 38
4
votes
4 answers

How to use cpplint code style checking with CMake?

The only online resources I have found are the CMake documentation on CMAKE__CPPLINT (link here) and this example (link here), but I cannot figure out how to actually use it inside a CMakeLists.txt file. I tried the example provided, but I…
Pinknoise
  • 53
  • 1
  • 5
4
votes
1 answer

static/global variable not permitted in C++

I have defined a global variable in my C++ class as follows : std::string VAR = "HELLO_WORLD"; But cpplint is telling me : Static/global string variables are not permitted. [runtime/string] [4] Do you have an idea why ?
klaus
  • 754
  • 8
  • 28
4
votes
1 answer

How to use the exclude_files regex in cpplint?

I am using cpplint to check my sourcode agains the google style guide. Cpplint's help says: cpplint.py supports per-directory configurations specified in CPPLINT.cfg files. CPPLINT.cfg file can contain a number of key=value pairs. Currently…
eDeviser
  • 1,605
  • 2
  • 17
  • 44
4
votes
1 answer

Flycheck-Google-Cpplint is not Configured Correctly

I am trying to install flycheck-google-cpplint in my emacs. But I get this error: (flycheck-mode 1) (eval-after-load 'flycheck '(progn (require 'flycheck-google-cpplint) (flycheck-add-next-checker 'c/c++-cppcheck …
Husain
  • 784
  • 1
  • 9
  • 22
3
votes
1 answer

Why can't I use ament_cpplint with cpplint plugins for various IDEs?

I am working with C++ code with ROS2. ROS2 has code style standards and one of the recommended linters is ament_cpplint, which is slightly different from cpplint Most IDEs/Editors for C++ (Clion, Atom, VS Code, Sublime Text) have plugins for cpplint…
ICRed
  • 31
  • 2
1
2 3 4