Skip to content

Don't err on non-const references by default #305

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ Changelog
===========

* Python versions less than 3.9 are no longer supported.
* The false positive for indented function parameters in namespaces was eradicated. (https://github.com/cpplint/cpplint/pull/304)
* build/include-what-you-use now recognizes c-style headers, such as <stdio.h> for symbols from <cstdio>. (https://github.com/cpplint/cpplint/pull/319)
* The warning on non-const references (runtime/references) is now disabled by default pursuant to the May 2020 Google style guide update. (https://github.com/cpplint/cpplint/pull/305)

2.0.1 (2025-03-09)
==================
Expand All @@ -26,7 +29,7 @@ Yet another overdue... hotfix. Sorry this took so long.
* Add a GitHub Action to publish to PyPI by @cclauss in https://github.com/cpplint/cpplint/pull/347

2.0.0 (2024-10-06)
================
==================

A large long-overdue modernization of the codebase!

Expand Down
1 change: 1 addition & 0 deletions cpplint.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@
_DEFAULT_FILTERS = [
"-build/include_alpha",
"-readability/fn_size",
"-runtime/references",
]

# The default list of categories suppressed for C (not C++) files.
Expand Down
12 changes: 1 addition & 11 deletions samples/codelite-sample/simple.def
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ src/*
4
Done processing src/pptable.cpp
Done processing src/pptable.h
Total errors found: 685
Total errors found: 675
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we finding fewer expected errors?


src/pptable.cpp:0: No copyright message found. You should have a line: "Copyright [year] <Copyright Owner>" [legal/copyright] [5]
src/pptable.cpp:1: Include the directory when naming header files [build/include_subdir] [4]
Expand Down Expand Up @@ -496,7 +496,6 @@ src/pptable.cpp:534: Tab found; better to use spaces [whitespace/tab] [1]
src/pptable.cpp:538: { should almost always be at the end of the previous line [whitespace/braces] [4]
src/pptable.cpp:539: Tab found; better to use spaces [whitespace/tab] [1]
src/pptable.cpp:542: Lines should be <= 80 characters long [whitespace/line_length] [2]
src/pptable.cpp:542: Is this a non-const reference? If so, make const or use a pointer: wxString &outStr [runtime/references] [2]
src/pptable.cpp:543: { should almost always be at the end of the previous line [whitespace/braces] [4]
src/pptable.cpp:544: Tab found; better to use spaces [whitespace/tab] [1]
src/pptable.cpp:545: Tab found; better to use spaces [whitespace/tab] [1]
Expand Down Expand Up @@ -534,7 +533,6 @@ src/pptable.cpp:578: Tab found; better to use spaces [whitespace/tab] [1]
src/pptable.cpp:579: Tab found; better to use spaces [whitespace/tab] [1]
src/pptable.cpp:582: Static/global string variables are not permitted. [runtime/string] [4]
src/pptable.cpp:584: Lines should be <= 80 characters long [whitespace/line_length] [2]
src/pptable.cpp:584: Is this a non-const reference? If so, make const or use a pointer: std::string& outStr [runtime/references] [2]
src/pptable.cpp:585: { should almost always be at the end of the previous line [whitespace/braces] [4]
src/pptable.cpp:586: Tab found; better to use spaces [whitespace/tab] [1]
src/pptable.cpp:587: Tab found; better to use spaces [whitespace/tab] [1]
Expand Down Expand Up @@ -621,9 +619,7 @@ src/pptable.h:30: Tab found; better to use spaces [whitespace/tab] [1]
src/pptable.h:31: Tab found; better to use spaces [whitespace/tab] [1]
src/pptable.h:32: Tab found; better to use spaces [whitespace/tab] [1]
src/pptable.h:49: Lines should be <= 80 characters long [whitespace/line_length] [2]
src/pptable.h:49: Is this a non-const reference? If so, make const or use a pointer: wxString &output [runtime/references] [2]
src/pptable.h:63: Lines should be <= 80 characters long [whitespace/line_length] [2]
src/pptable.h:63: Is this a non-const reference? If so, make const or use a pointer: std::string& outStr [runtime/references] [2]
src/pptable.h:69: Tab found; better to use spaces [whitespace/tab] [1]
src/pptable.h:70: Tab found; better to use spaces [whitespace/tab] [1]
src/pptable.h:71: Tab found; better to use spaces [whitespace/tab] [1]
Expand All @@ -646,15 +642,10 @@ src/pptable.h:88: Tab found; better to use spaces [whitespace/tab] [1]
src/pptable.h:89: Tab found; better to use spaces [whitespace/tab] [1]
src/pptable.h:90: Tab found; better to use spaces [whitespace/tab] [1]
src/pptable.h:91: Tab found; better to use spaces [whitespace/tab] [1]
src/pptable.h:91: Is this a non-const reference? If so, make const or use a pointer: wxFFile &fp [runtime/references] [2]
src/pptable.h:92: Tab found; better to use spaces [whitespace/tab] [1]
src/pptable.h:92: Lines should be <= 80 characters long [whitespace/line_length] [2]
src/pptable.h:92: Is this a non-const reference? If so, make const or use a pointer: wxString& initList [runtime/references] [2]
src/pptable.h:92: Is this a non-const reference? If so, make const or use a pointer: wxArrayString &initListArr [runtime/references] [2]
src/pptable.h:93: Tab found; better to use spaces [whitespace/tab] [1]
src/pptable.h:93: Lines should be <= 80 characters long [whitespace/line_length] [2]
src/pptable.h:93: Is this a non-const reference? If so, make const or use a pointer: std::string& initList [runtime/references] [2]
src/pptable.h:93: Is this a non-const reference? If so, make const or use a pointer: std::vector<std::string> &initListArr [runtime/references] [2]
src/pptable.h:94: Tab found; better to use spaces [whitespace/tab] [1]
src/pptable.h:95: Tab found; better to use spaces [whitespace/tab] [1]
src/pptable.h:96: Tab found; better to use spaces [whitespace/tab] [1]
Expand All @@ -676,7 +667,6 @@ src/pptable.h:115: Tab found; better to use spaces [whitespace/tab] [1]
src/pptable.h:115: Extra space before ( in function call [whitespace/parens] [4]
src/pptable.h:116: Tab found; better to use spaces [whitespace/tab] [1]
src/pptable.h:117: Tab found; better to use spaces [whitespace/tab] [1]
src/pptable.h:117: Is this a non-const reference? If so, make const or use a pointer: wxFFile &fp [runtime/references] [2]
src/pptable.h:118: Tab found; better to use spaces [whitespace/tab] [1]
src/pptable.h:119: Tab found; better to use spaces [whitespace/tab] [1]
src/pptable.h:120: Tab found; better to use spaces [whitespace/tab] [1]
Expand Down
7 changes: 1 addition & 6 deletions samples/silly-sample/cfg.def
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,17 @@
4
Done processing src/sillycode.cpp
Done processing src/sillycode.w
Total errors found: 26
Total errors found: 21
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we finding fewer expected errors?


src/sillycode.cpp:0: No copyright message found. You should have a line: "Copyright [year] <Copyright Owner>" [legal/copyright] [5]
src/sillycode.cpp:2: <ratio> is an unapproved C++11 header. [build/c++11] [5]
src/sillycode.cpp:3: Found C system header after other header. Should be: sillycode.h, c system, c++ system, other. [build/include_order] [4]
src/sillycode.cpp:4: Found C system header after other header. Should be: sillycode.h, c system, c++ system, other. [build/include_order] [4]
src/sillycode.cpp:14: Is this a non-const reference? If so, make const or use a pointer: vector<string>& v [runtime/references] [2]
src/sillycode.cpp:40: If/else bodies with multiple statements require braces [readability/braces] [4]
src/sillycode.cpp:66: Single-parameter constructors should be marked explicit. [runtime/explicit] [4]
src/sillycode.cpp:76: Single-parameter constructors should be marked explicit. [runtime/explicit] [4]
src/sillycode.cpp:85: Constructors callable with one argument should be marked explicit. [runtime/explicit] [4]
src/sillycode.cpp:86: Lines should be <= 80 characters long [whitespace/line_length] [2]
src/sillycode.cpp:118: Is this a non-const reference? If so, make const or use a pointer: N::X& a [runtime/references] [2]
src/sillycode.cpp:118: Is this a non-const reference? If so, make const or use a pointer: N::X& b [runtime/references] [2]
src/sillycode.cpp:123: Is this a non-const reference? If so, make const or use a pointer: N::X& a [runtime/references] [2]
src/sillycode.cpp:123: Is this a non-const reference? If so, make const or use a pointer: N::X& b [runtime/references] [2]
src/sillycode.cpp:171: Do not use variable-length arrays. Use an appropriately named ('k' followed by CamelCase) compile-time constant for the size. [runtime/arrays] [1]
src/sillycode.cpp:178: Static/global string variables are not permitted. [runtime/string] [4]
src/sillycode.cpp:199: If an else has a brace on one side, it should have it on both [readability/braces] [5]
Expand Down
9 changes: 2 additions & 7 deletions samples/silly-sample/filters.def
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,19 @@ Done processing src/sillycode.cpp
Category 'build' errors found: 5
Category 'legal' errors found: 1
Category 'readability' errors found: 4
Category 'runtime' errors found: 12
Total errors found: 22
Category 'runtime' errors found: 7
Total errors found: 17
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we finding fewer expected errors?


src/sillycode.cpp:0: No copyright message found. You should have a line: "Copyright [year] <Copyright Owner>" [legal/copyright] [5]
src/sillycode.cpp:1: Include the directory when naming header files [build/include_subdir] [4]
src/sillycode.cpp:2: <ratio> is an unapproved C++11 header. [build/c++11] [5]
src/sillycode.cpp:3: Found C system header after other header. Should be: sillycode.h, c system, c++ system, other. [build/include_order] [4]
src/sillycode.cpp:4: Found C system header after other header. Should be: sillycode.h, c system, c++ system, other. [build/include_order] [4]
src/sillycode.cpp:5: Do not use namespace using-directives. Use using-declarations instead. [build/namespaces] [5]
src/sillycode.cpp:14: Is this a non-const reference? If so, make const or use a pointer: vector<string>& v [runtime/references] [2]
src/sillycode.cpp:40: If/else bodies with multiple statements require braces [readability/braces] [4]
src/sillycode.cpp:66: Single-parameter constructors should be marked explicit. [runtime/explicit] [4]
src/sillycode.cpp:76: Single-parameter constructors should be marked explicit. [runtime/explicit] [4]
src/sillycode.cpp:85: Constructors callable with one argument should be marked explicit. [runtime/explicit] [4]
src/sillycode.cpp:118: Is this a non-const reference? If so, make const or use a pointer: N::X& a [runtime/references] [2]
src/sillycode.cpp:118: Is this a non-const reference? If so, make const or use a pointer: N::X& b [runtime/references] [2]
src/sillycode.cpp:123: Is this a non-const reference? If so, make const or use a pointer: N::X& a [runtime/references] [2]
src/sillycode.cpp:123: Is this a non-const reference? If so, make const or use a pointer: N::X& b [runtime/references] [2]
src/sillycode.cpp:171: Do not use variable-length arrays. Use an appropriately named ('k' followed by CamelCase) compile-time constant for the size. [runtime/arrays] [1]
src/sillycode.cpp:178: Static/global string variables are not permitted. [runtime/string] [4]
src/sillycode.cpp:199: If an else has a brace on one side, it should have it on both [readability/braces] [5]
Expand Down
7 changes: 1 addition & 6 deletions samples/silly-sample/includeorder_cfirst.def
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
1
3
Done processing src/sillycode.cpp
Total errors found: 123
Total errors found: 118
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we finding fewer expected errors?


src/sillycode.cpp:0: No copyright message found. You should have a line: "Copyright [year] <Copyright Owner>" [legal/copyright] [5]
src/sillycode.cpp:1: Include the directory when naming header files [build/include_subdir] [4]
Expand All @@ -13,7 +13,6 @@ src/sillycode.cpp:3: Found other system header after other header. Should be: s
src/sillycode.cpp:4: Found other system header after other header. Should be: sillycode.h, c system, c++ system, other. [build/include_order] [4]
src/sillycode.cpp:5: Do not use namespace using-directives. Use using-declarations instead. [build/namespaces] [5]
src/sillycode.cpp:8: public: should be indented +1 space inside class Date [whitespace/indent] [3]
src/sillycode.cpp:14: Is this a non-const reference? If so, make const or use a pointer: vector<string>& v [runtime/references] [2]
src/sillycode.cpp:15: { should almost always be at the end of the previous line [whitespace/braces] [4]
src/sillycode.cpp:39: { should almost always be at the end of the previous line [whitespace/braces] [4]
src/sillycode.cpp:40: Tab found; better to use spaces [whitespace/tab] [1]
Expand Down Expand Up @@ -43,15 +42,11 @@ src/sillycode.cpp:110: Tab found; better to use spaces [whitespace/tab] [1]
src/sillycode.cpp:111: Tab found; better to use spaces [whitespace/tab] [1]
src/sillycode.cpp:111: At least two spaces is best between code and comments [whitespace/comments] [2]
src/sillycode.cpp:113: public: should be indented +1 space inside class Vector2 [whitespace/indent] [3]
src/sillycode.cpp:118: Is this a non-const reference? If so, make const or use a pointer: N::X& a [runtime/references] [2]
src/sillycode.cpp:118: Is this a non-const reference? If so, make const or use a pointer: N::X& b [runtime/references] [2]
src/sillycode.cpp:119: { should almost always be at the end of the previous line [whitespace/braces] [4]
src/sillycode.cpp:120: Tab found; better to use spaces [whitespace/tab] [1]
src/sillycode.cpp:120: Missing space after , [whitespace/comma] [3]
src/sillycode.cpp:122: Weird number of spaces at line-start. Are you using a 2-space indent? [whitespace/indent] [3]
src/sillycode.cpp:122: Line ends in whitespace. Consider deleting these extra spaces. [whitespace/end_of_line] [4]
src/sillycode.cpp:123: Is this a non-const reference? If so, make const or use a pointer: N::X& a [runtime/references] [2]
src/sillycode.cpp:123: Is this a non-const reference? If so, make const or use a pointer: N::X& b [runtime/references] [2]
src/sillycode.cpp:124: { should almost always be at the end of the previous line [whitespace/braces] [4]
src/sillycode.cpp:125: Tab found; better to use spaces [whitespace/tab] [1]
src/sillycode.cpp:125: At least two spaces is best between code and comments [whitespace/comments] [2]
Expand Down
5 changes: 0 additions & 5 deletions samples/silly-sample/sed.def
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ sed -i '249s/\([^ ]\){/\1 {/' src/sillycode.cpp # Missing space before { [white
# src/sillycode.cpp:4: "Found C system header after other header. Should be: sillycode.h, c system, c++ system, other." [build/include_order] [4]
# src/sillycode.cpp:5: "Do not use namespace using-directives. Use using-declarations instead." [build/namespaces] [5]
# src/sillycode.cpp:8: "public: should be indented +1 space inside class Date" [whitespace/indent] [3]
# src/sillycode.cpp:14: "Is this a non-const reference? If so, make const or use a pointer: vector<string>& v" [runtime/references] [2]
# src/sillycode.cpp:15: "{ should almost always be at the end of the previous line" [whitespace/braces] [4]
# src/sillycode.cpp:39: "{ should almost always be at the end of the previous line" [whitespace/braces] [4]
# src/sillycode.cpp:40: "Tab found; better to use spaces" [whitespace/tab] [1]
Expand Down Expand Up @@ -47,13 +46,9 @@ sed -i '249s/\([^ ]\){/\1 {/' src/sillycode.cpp # Missing space before { [white
# src/sillycode.cpp:111: "Tab found; better to use spaces" [whitespace/tab] [1]
# src/sillycode.cpp:111: "At least two spaces is best between code and comments" [whitespace/comments] [2]
# src/sillycode.cpp:113: "public: should be indented +1 space inside class Vector2" [whitespace/indent] [3]
# src/sillycode.cpp:118: "Is this a non-const reference? If so, make const or use a pointer: N::X& a" [runtime/references] [2]
# src/sillycode.cpp:118: "Is this a non-const reference? If so, make const or use a pointer: N::X& b" [runtime/references] [2]
# src/sillycode.cpp:119: "{ should almost always be at the end of the previous line" [whitespace/braces] [4]
# src/sillycode.cpp:120: "Tab found; better to use spaces" [whitespace/tab] [1]
# src/sillycode.cpp:122: "Weird number of spaces at line-start. Are you using a 2-space indent?" [whitespace/indent] [3]
# src/sillycode.cpp:123: "Is this a non-const reference? If so, make const or use a pointer: N::X& a" [runtime/references] [2]
# src/sillycode.cpp:123: "Is this a non-const reference? If so, make const or use a pointer: N::X& b" [runtime/references] [2]
# src/sillycode.cpp:124: "{ should almost always be at the end of the previous line" [whitespace/braces] [4]
# src/sillycode.cpp:125: "Tab found; better to use spaces" [whitespace/tab] [1]
# src/sillycode.cpp:125: "At least two spaces is best between code and comments" [whitespace/comments] [2]
Expand Down
7 changes: 1 addition & 6 deletions samples/silly-sample/simple.def
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ src/*
4
Done processing src/sillycode.cpp
Done processing src/sillycode.w
Total errors found: 126
Total errors found: 121
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we finding fewer expected errors?


src/sillycode.cpp:0: No copyright message found. You should have a line: "Copyright [year] <Copyright Owner>" [legal/copyright] [5]
src/sillycode.cpp:1: Include the directory when naming header files [build/include_subdir] [4]
Expand All @@ -14,7 +14,6 @@ src/sillycode.cpp:3: Found C system header after other header. Should be: silly
src/sillycode.cpp:4: Found C system header after other header. Should be: sillycode.h, c system, c++ system, other. [build/include_order] [4]
src/sillycode.cpp:5: Do not use namespace using-directives. Use using-declarations instead. [build/namespaces] [5]
src/sillycode.cpp:8: public: should be indented +1 space inside class Date [whitespace/indent] [3]
src/sillycode.cpp:14: Is this a non-const reference? If so, make const or use a pointer: vector<string>& v [runtime/references] [2]
src/sillycode.cpp:15: { should almost always be at the end of the previous line [whitespace/braces] [4]
src/sillycode.cpp:39: { should almost always be at the end of the previous line [whitespace/braces] [4]
src/sillycode.cpp:40: Tab found; better to use spaces [whitespace/tab] [1]
Expand Down Expand Up @@ -44,15 +43,11 @@ src/sillycode.cpp:110: Tab found; better to use spaces [whitespace/tab] [1]
src/sillycode.cpp:111: Tab found; better to use spaces [whitespace/tab] [1]
src/sillycode.cpp:111: At least two spaces is best between code and comments [whitespace/comments] [2]
src/sillycode.cpp:113: public: should be indented +1 space inside class Vector2 [whitespace/indent] [3]
src/sillycode.cpp:118: Is this a non-const reference? If so, make const or use a pointer: N::X& a [runtime/references] [2]
src/sillycode.cpp:118: Is this a non-const reference? If so, make const or use a pointer: N::X& b [runtime/references] [2]
src/sillycode.cpp:119: { should almost always be at the end of the previous line [whitespace/braces] [4]
src/sillycode.cpp:120: Tab found; better to use spaces [whitespace/tab] [1]
src/sillycode.cpp:120: Missing space after , [whitespace/comma] [3]
src/sillycode.cpp:122: Weird number of spaces at line-start. Are you using a 2-space indent? [whitespace/indent] [3]
src/sillycode.cpp:122: Line ends in whitespace. Consider deleting these extra spaces. [whitespace/end_of_line] [4]
src/sillycode.cpp:123: Is this a non-const reference? If so, make const or use a pointer: N::X& a [runtime/references] [2]
src/sillycode.cpp:123: Is this a non-const reference? If so, make const or use a pointer: N::X& b [runtime/references] [2]
src/sillycode.cpp:124: { should almost always be at the end of the previous line [whitespace/braces] [4]
src/sillycode.cpp:125: Tab found; better to use spaces [whitespace/tab] [1]
src/sillycode.cpp:125: At least two spaces is best between code and comments [whitespace/comments] [2]
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy