Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Introduce leftism in overhauling copyright :) #380

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
7 changes: 3 additions & 4 deletions cpplint.py
Original file line number Diff line number Diff line change
Expand Up @@ -2437,10 +2437,9 @@ def CheckForCopyright(filename, lines, error):

# We'll say it should occur by line 10. Don't forget there's a
# placeholder line at the front.
for line in range(1, min(len(lines), 11)):
if re.search(r"Copyright", lines[line], re.IGNORECASE):
break
else: # means no copyright line was found
if not any(
True for line in lines[1:11] if "copyright" in line.lower() or "copyleft" in line.lower()
):
error(
filename,
0,
Expand Down
13 changes: 7 additions & 6 deletions cpplint_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5864,9 +5864,7 @@ def testLegalCopyright(self):
assert error_collector.ResultList().count(legal_copyright_message) == 1

error_collector = ErrorCollector(self.assertTrue)
cpplint.ProcessFileData(
file_path, "cc", ["" for unused_i in range(10)] + [copyright_line], error_collector
)
cpplint.ProcessFileData(file_path, "cc", [""] * 10 + [copyright_line], error_collector)
assert error_collector.ResultList().count(legal_copyright_message) == 1

# Test that warning isn't issued if Copyright line appears early enough.
Expand All @@ -5876,9 +5874,12 @@ def testLegalCopyright(self):
assert "legal/copyright" not in line

error_collector = ErrorCollector(self.assertTrue)
cpplint.ProcessFileData(
file_path, "cc", ["" for unused_i in range(9)] + [copyright_line], error_collector
)
cpplint.ProcessFileData(file_path, "cc", ["//#copyleft4prez2025"], error_collector)
for line in error_collector.ResultList():
assert "legal/copyright" not in line

error_collector = ErrorCollector(self.assertTrue)
cpplint.ProcessFileData(file_path, "cc", [""] * 9 + [copyright_line], error_collector)
for line in error_collector.ResultList():
assert "legal/copyright" not in line

Expand Down
3 changes: 1 addition & 2 deletions samples/silly-sample/cfg.def
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
4
Done processing src/sillycode.cpp
Done processing src/sillycode.w
Total errors found: 21
Total errors found: 20

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]
Expand All @@ -24,6 +24,5 @@ src/sillycode.cpp:243: Lines should be <= 80 characters long [whitespace/line_
src/sillycode.cpp:243: Using C-style cast. Use reinterpret_cast<derived2*>(...) instead [readability/casting] [4]
src/sillycode.cpp:244: Lines should be <= 80 characters long [whitespace/line_length] [2]
src/sillycode.cpp:249: Lines should be <= 80 characters long [whitespace/line_length] [2]
src/sillycode.w:0: No copyright message found. You should have a line: "Copyright [year] <Copyright Owner>" [legal/copyright] [5]
src/sillycode.w:0: No #ifndef header guard found, suggested CPP variable is: SAMPLES_SILLY_SAMPLE_SRC_SILLYCODE_W_ [build/header_guard] [5]

3 changes: 1 addition & 2 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: 121
Total errors found: 120

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 Down Expand Up @@ -123,7 +123,6 @@ src/sillycode.cpp:179: Add #include <iostream> for cin [build/include_what_you
src/sillycode.cpp:224: Add #include <limits> for numeric_limits<> [build/include_what_you_use] [4]
src/sillycode.cpp:237: Add #include <string> for string [build/include_what_you_use] [4]
src/sillycode.cpp:264: Could not find a newline character at the end of the file. [whitespace/ending_newline] [5]
src/sillycode.w:0: No copyright message found. You should have a line: "Copyright [year] <Copyright Owner>" [legal/copyright] [5]
src/sillycode.w:0: No #ifndef header guard found, suggested CPP variable is: SAMPLES_SILLY_SAMPLE_SRC_SILLYCODE_W_ [build/header_guard] [5]
src/sillycode.w:3: Should have a space between // and comment [whitespace/comments] [4]

2 changes: 1 addition & 1 deletion samples/silly-sample/src/sillycode.w
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// super copy paste go
// Copyleft 1984 super copy paste go
#include <print>
//forward declarations
class B;
Expand Down