Skip to content

Commit e010007

Browse files
authored
Merge pull request #5929 from tautschnig/fix-cpplint-action
Make cpplint check actually work in CI
2 parents e166f4c + a5b3008 commit e010007

File tree

71 files changed

+152
-83
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+152
-83
lines changed

.github/workflows/pull-request-checks.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,8 @@ jobs:
364364
# user input
365365
DEBIAN_FRONTEND: noninteractive
366366
run: |
367-
pip install unidiff
367+
sudo apt-get update
368+
sudo apt-get install --no-install-recommends -yq python3-unidiff
368369
- name: Check updated lines of code meet linting standards
369370
env:
370371
BASE_BRANCH: ${{ github.base_ref }}

regression/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ add_subdirectory(validate-trace-xml-schema)
7272
add_subdirectory(cbmc-primitives)
7373
add_subdirectory(goto-interpreter)
7474
add_subdirectory(cbmc-sequentialization)
75+
add_subdirectory(cpp-linter)
7576

7677
if(WITH_MEMORY_ANALYZER)
7778
add_subdirectory(snapshot-harness)

regression/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ DIRS = cbmc \
4545
cbmc-primitives \
4646
goto-interpreter \
4747
cbmc-sequentialization \
48+
cpp-linter \
4849
# Empty last line
4950

5051
ifeq ($(OS),Windows_NT)

regression/cpp-linter/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
add_test_pl_tests("../../../scripts/cpplint.py")

regression/cpp-linter/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
default: tests.log
22

33
test:
4-
@../test.pl -p -c "python ../../../scripts/cpplint.py"
4+
@../test.pl -p -c ../../../scripts/cpplint.py
55

66
tests.log: ../test.pl
7-
@../test.pl -p -c "python ../../../scripts/cpplint.py"
7+
@../test.pl -p -c ../../../scripts/cpplint.py
88

99
show:
1010
@for dir in *; do \

regression/cpp-linter/assert/module_dependencies.txt

Whitespace-only changes.
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
CORE
22
main.cpp
33

4-
^main\.cpp:8: assert is deprecated, use INVARIANT instead \[build/deprecated\] \[4\]
5-
^Total errors found: 1$
4+
^regression/cpp-linter/assert/main\.cpp:8: assert is deprecated, use UNREACHABLE instead \[build/deprecated\] \[4\]
5+
^# Total errors found: 1$
6+
^EXIT=1$
67
^SIGNAL=0$

regression/cpp-linter/catch-cast/module_dependencies.txt

Whitespace-only changes.

regression/cpp-linter/class-decl-space/main.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ Author: Thomas Kiley, [email protected]
66
77
\*******************************************************************/
88

9+
// clang-format off
910
class temp_classt : public base_classt
1011
{}
1112

12-
class another_class : public base_classt
13+
class another_class: public base_classt
1314
{}
1415

15-
class more_class:public base_classt
16+
class more_class: public base_classt
1617
{}
1718

1819
class nonderived
@@ -41,3 +42,4 @@ class testt
4142
template<class U>
4243
void bar(U t);
4344
}
45+
// clang-format on

regression/cpp-linter/class-decl-space/module_dependencies.txt

Whitespace-only changes.
Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
CORE
22
main.cpp
33

4-
^main\.cpp:9: There shouldn.t be a space between class identifier and : \[readability/identifiers\] \[4\]$
5-
^main\.cpp:12: There shouldn.t be a space between class identifier and : \[readability/identifiers\] \[4\]$
6-
^main\.cpp:12: Class or struct identifier should end with t \[readability/identifiers\] \[4\]$
7-
^main\.cpp:15: Class or struct identifier should end with t \[readability/identifiers\] \[4\]$
8-
^main\.cpp:18: Class or struct identifier should end with t \[readability/identifiers\] \[4\]$
9-
^main\.cpp:26: Class or struct identifier should end with t \[readability/identifiers\] \[4\]$
10-
^main\.cpp:30: Remove spaces around < \[whitespace/operators\] \[4\]$
11-
^main\.cpp:36: Remove spaces around < \[whitespace/operators\] \[4\]$
12-
^Total errors found: 8$
4+
^regression/cpp-linter/class-decl-space/main\.cpp:13: There should be a space between class identifier and : \[readability/identifier_spacing\] \[4\]$
5+
^regression/cpp-linter/class-decl-space/main\.cpp:16: There should be a space between class identifier and : \[readability/identifier_spacing\] \[4\]$
6+
^regression/cpp-linter/class-decl-space/main\.cpp:13: Class or struct identifier should end with t \[readability/identifiers\] \[4\]$
7+
^regression/cpp-linter/class-decl-space/main\.cpp:16: Class or struct identifier should end with t \[readability/identifiers\] \[4\]$
8+
^regression/cpp-linter/class-decl-space/main\.cpp:19: Class or struct identifier should end with t \[readability/identifiers\] \[4\]$
9+
^regression/cpp-linter/class-decl-space/main\.cpp:27: Class or struct identifier should end with t \[readability/identifiers\] \[4\]$
10+
^# Total errors found: 6$
11+
^EXIT=1$
1312
^SIGNAL=0$
1413
--
14+
--
15+
The following patters are disabled as the corresponding checks in cpplint.py
16+
were commented out in 56aea470fd6 for they yield too many false positives:
17+
^regression/cpp-linter/class-decl-space/main\.cpp:31: Remove spaces around < \[whitespace/operators\] \[4\]$
18+
^regression/cpp-linter/class-decl-space/main\.cpp:37: Remove spaces around < \[whitespace/operators\] \[4\]$

regression/cpp-linter/do-while1/module_dependencies.txt

Whitespace-only changes.
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
CORE
22
main.cpp
33

4-
^main\.cpp:31: Empty loop bodies should use \{\} or continue \[whitespace/empty_loop_body\] \[5\]$
5-
^main\.cpp:38: Empty loop bodies should use \{\} or continue \[whitespace/empty_loop_body\] \[5\]$
6-
^Total errors found: 2$
4+
^regression/cpp-linter/do-while1/main\.cpp:31: Empty loop bodies should use \{\} or continue \[whitespace/empty_loop_body\] \[5\]$
5+
^regression/cpp-linter/do-while1/main\.cpp:38: Empty loop bodies should use \{\} or continue \[whitespace/empty_loop_body\] \[5\]$
6+
^# Total errors found: 2$
7+
^EXIT=1$
78
^SIGNAL=0$
89
--

regression/cpp-linter/do-while2/module_dependencies.txt

Whitespace-only changes.
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
CORE
22
main.cpp
33

4-
^main\.cpp:26: while statement of do...while loop should be on a separate line to the closing brace \[readability/braces\] \[4\]
5-
^Total errors found: 1$
4+
^EXIT=0$
65
^SIGNAL=0$
76
--
7+
--
8+
Test was marked as disabled-by-default in a00edd3e6c54.
9+
^main\.cpp:26: while statement of do...while loop should be on a separate line to the closing brace \[readability/braces\] \[4\]
10+
^# Total errors found: 1$

regression/cpp-linter/function-comment-header1/module_dependencies.txt

Whitespace-only changes.
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
CORE
1+
KNOWNBUG
22
main.cpp
33

44
^main\.cpp:26: Could not find function header comment for foo \[readability/function_comment\] \[4\]
5-
^Total errors found: 1$
5+
^# Total errors found: 1$
6+
^EXIT=1$
67
^SIGNAL=0$
78
--
9+
--
10+
The checking code in cpplint.py was broken in 7302e56a348, where a wrong indent
11+
caused the check to never take place. That's fine, however, as we don't use
12+
these function headers anymore.

regression/cpp-linter/function-comment-header2/module_dependencies.txt

Whitespace-only changes.
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
CORE
1+
KNOWNBUG
22
main.cpp
33

44
main\.cpp:15: Function header for fun missing Inputs: \[readability/function_comment\] \[4\]
55
main\.cpp:15: Function header for fun missing Outputs: \[readability/function_comment\] \[4\]
66
main\.cpp:15: Function header for fun missing Purpose: \[readability/function_comment\] \[4\]
7-
^Total errors found: 3$
7+
^# Total errors found: 3$
8+
^EXIT=1$
89
^SIGNAL=0$
910
--
11+
--
12+
The checking code in cpplint.py was broken in 7302e56a348, where a wrong indent
13+
caused the check to never take place. That's fine, however, as we don't use
14+
these function headers anymore.

regression/cpp-linter/function-comment-header3/module_dependencies.txt

Whitespace-only changes.
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
CORE
1+
KNOWNBUG
22
main.cpp
33

44
^main\.cpp:20: Insert an empty line between function header comment and the function fun \[readability/function_comment\] \[4\]$
5-
^Total errors found: 1$
5+
^# Total errors found: 1$
6+
^EXIT=1$
67
^SIGNAL=0$
78
--
9+
--
10+
The checking code in cpplint.py was broken in 7302e56a348, where a wrong indent
11+
caused the check to never take place. That's fine, however, as we don't use
12+
these function headers anymore.

regression/cpp-linter/function-comment-header4/module_dependencies.txt

Whitespace-only changes.
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
CORE
1+
KNOWNBUG
22
main.cpp
33

44
^main\.cpp:11: Function: name in the comment doesn.t match the function name \[readability/function_comment\] \[4\]
5-
^Total errors found: 1$
5+
^# Total errors found: 1$
6+
^EXIT=1$
67
^SIGNAL=0$
78
--
9+
--
10+
The checking code in cpplint.py was broken in 7302e56a348, where a wrong indent
11+
caused the check to never take place. That's fine, however, as we don't use
12+
these function headers anymore.

regression/cpp-linter/function-comment-header5/module_dependencies.txt

Whitespace-only changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CORE
22
main.cpp
33

4-
^Total errors found: 0$
4+
^# Total errors found: 0$
55
^EXIT=0$
66
^SIGNAL=0$
77
--

regression/cpp-linter/function-comment-header6/module_dependencies.txt

Whitespace-only changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CORE
22
main.cpp
33

4-
^Total errors found: 0$
4+
^# Total errors found: 0$
55
^EXIT=0$
66
^SIGNAL=0$
77
--

regression/cpp-linter/function-comment-header7/module_dependencies.txt

Whitespace-only changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CORE
22
main.cpp
33

4-
^Total errors found: 0$
4+
^# Total errors found: 0$
55
^EXIT=0$
66
^SIGNAL=0$
77
--

regression/cpp-linter/if-else1/module_dependencies.txt

Whitespace-only changes.
Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
CORE
22
main.cpp
33

4-
^main\.cpp:24: Put braces on a separate next line \[whitespace/braces\] \[5\]$
5-
^main\.cpp:26: Put braces on a separate next line \[whitespace/braces\] \[5\]$
6-
^main\.cpp:26: Else if should be on a new line after closing brace \[readability/braces\] \[5\]$
7-
^main\.cpp:28: Put braces on a separate next line \[whitespace/braces\] \[5\]$
8-
^main\.cpp:28: Else should be on a new line after closing brace \[readability/braces\] \[5\]$
9-
^Total errors found: 5$
4+
^regression/cpp-linter/if-else1/main\.cpp:26: Else if should be on a new line after closing brace \[readability/braces\] \[5\]$
5+
^regression/cpp-linter/if-else1/main\.cpp:28: Else should be on a new line after closing brace \[readability/braces\] \[5\]$
6+
^# Total errors found: 2$
7+
^EXIT=1$
108
^SIGNAL=0$
119
--
10+
--
11+
The following patters are disabled as the corresponding checks in cpplint.py
12+
were removed in 692c4f377 for they are covered by clang-format:
13+
^regression/cpp-linter/if-else1/main\.cpp:24: Put braces on a separate next line \[whitespace/braces\] \[5\]$
14+
^regression/cpp-linter/if-else1/main\.cpp:26: Put braces on a separate next line \[whitespace/braces\] \[5\]$
15+
^regression/cpp-linter/if-else1/main\.cpp:28: Put braces on a separate next line \[whitespace/braces\] \[5\]$

regression/cpp-linter/if-else2/module_dependencies.txt

Whitespace-only changes.
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
CORE
22
main.cpp
33

4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
--
8+
The following patters are disabled as the corresponding checks in cpplint.py
9+
were removed in 692c4f377 for they are covered by clang-format:
410
^main\.cpp:23: Put braces on a separate next line \[whitespace/braces\] \[5\]$
511
^main\.cpp:26: Put braces on a separate next line \[whitespace/braces\] \[5\]$
612
^main\.cpp:29: Put braces on a separate next line \[whitespace/braces\] \[5\]$
7-
^Total errors found: 3$
8-
^SIGNAL=0$
9-
--
13+
^# Total errors found: 3$

regression/cpp-linter/if-else3/module_dependencies.txt

Whitespace-only changes.
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
CORE
22
main.cpp
33

4-
^main\.cpp:24: Statement after an if should be on a new line \[readability/braces\] \[5\]$
5-
^main\.cpp:25: Statement after else if should be on a new line \[readability/braces\] \[5\]$
6-
^main\.cpp:26: Statement after else should be on a new line \[readability/braces\] \[5\]$
7-
^Total errors found: 3$
4+
^regression/cpp-linter/if-else3/main\.cpp:24: Statement after an if should be on a new line \[readability/braces\] \[5\]$
5+
^regression/cpp-linter/if-else3/main\.cpp:25: Statement after else if should be on a new line \[readability/braces\] \[5\]$
6+
^# Total errors found: 2$
7+
^EXIT=1$
88
^SIGNAL=0$
99
--
10+
--
11+
The following patters are disabled as the corresponding checks in cpplint.py
12+
were commented out in 56aea470fd6 for they yield too many false positives:
13+
^regression/cpp-linter/if-else3/main\.cpp:26: Statement after else should be on a new line \[readability/braces\] \[5\]$

regression/cpp-linter/if-else4/module_dependencies.txt

Whitespace-only changes.
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
CORE
22
main.cpp
33

4-
^main\.cpp:24: Statement after an if should be on a new line \[readability/braces\] \[5\]$
5-
^main\.cpp:25: Statement after else if should be on a new line \[readability/braces\] \[5\]$
6-
^main\.cpp:26: Statement after else should be on a new line \[readability/braces\] \[5\]$
7-
^Total errors found: 3$
4+
^regression/cpp-linter/if-else4/main\.cpp:24: Statement after an if should be on a new line \[readability/braces\] \[5\]$
5+
^regression/cpp-linter/if-else4/main\.cpp:25: Statement after else if should be on a new line \[readability/braces\] \[5\]$
6+
^# Total errors found: 2$
7+
^EXIT=1$
88
^SIGNAL=0$
99
--
10+
--
11+
The following patters are disabled as the corresponding checks in cpplint.py
12+
were commented out in 56aea470fd6 for they yield too many false positives:
13+
^regression/cpp-linter/if-else4/main\.cpp:26: Statement after else should be on a new line \[readability/braces\] \[5\]$

regression/cpp-linter/if-else5/module_dependencies.txt

Whitespace-only changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CORE
22
main.cpp
33

4-
^Total errors found: 0$
4+
^# Total errors found: 0$
55
^EXIT=0$
66
^SIGNAL=0$
77
--

regression/cpp-linter/if-else6/module_dependencies.txt

Whitespace-only changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CORE
22
main.cpp
33

4-
^Total errors found: 0$
4+
^# Total errors found: 0$
55
^EXIT=0$
66
^SIGNAL=0$
77
--

regression/cpp-linter/multi-line-comment/module_dependencies.txt

Whitespace-only changes.

regression/cpp-linter/multi-line-function-call1/module_dependencies.txt

Whitespace-only changes.
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
CORE
22
main.cpp
33

4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
--
8+
The following patters are disabled as the corresponding checks in cpplint.py
9+
were commented out in 56aea470fd6 for they yield too many false positives:
410
^main\.cpp:29: If parameters or arguments require a line break, each parameter should be put on its own line\. \[whitespace/indent\] \[4\]
511
^main\.cpp:34: Indent of wrapped parenthesized expression or parameter or argument list should be 2 \[whitespace/indent\] \[4\]
612
^main\.cpp:43: If parameters or arguments require a line break, each parameter should be put on its own line\. \[whitespace/indent\] \[4\]
@@ -11,7 +17,4 @@ main.cpp
1117
^main\.cpp:76: Indent of wrapped parenthesized expression or parameter or argument list should be 2 \[whitespace/indent\] \[4\]
1218
^main\.cpp:81: If parameters or arguments require a line break, the closing bracket should be on the same line as the final parameter \[whitespace/indent\] \[4\]
1319
^main\.cpp:85: If parameters or arguments require a line break, each parameter should be put on its own line. \[whitespace/indent\] \[4\]
14-
^Total errors found: 10$
15-
^EXIT=1$
16-
^SIGNAL=0$
17-
--
20+
^# Total errors found: 10$

regression/cpp-linter/multi-line-function-call2/module_dependencies.txt

Whitespace-only changes.
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
CORE
22
main.cpp
33

4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
--
8+
The following patters are disabled as the corresponding checks in cpplint.py
9+
were commented out in 56aea470fd6 for they yield too many false positives:
410
^main\.cpp:24: If parameters or arguments require a line break, each parameter should be put on its own line\. \[whitespace/indent\] \[4\]
511
^main\.cpp:29: Indent of wrapped parenthesized expression or parameter or argument list should be 2 \[whitespace/indent\] \[4\]
612
^main\.cpp:60: If parameters or arguments require a line break, each parameter should be put on its own line\. \[whitespace/indent\] \[4\]
713
^main\.cpp:65: If parameters or arguments require a line break, each parameter should be put on its own line\. \[whitespace/indent\] \[4\]
8-
^Total errors found: 4$
9-
^EXIT=1$
10-
^SIGNAL=0$
11-
--
14+
^# Total errors found: 4$

regression/cpp-linter/multi-line-function-call3/module_dependencies.txt

Whitespace-only changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CORE
22
main.cpp
33

4-
^Total errors found: 0$
4+
^# Total errors found: 0$
55
^EXIT=0$
66
^SIGNAL=0$
77
--

regression/cpp-linter/multi-line-string1/module_dependencies.txt

Whitespace-only changes.

regression/cpp-linter/multi-line-string2/module_dependencies.txt

Whitespace-only changes.

regression/cpp-linter/namespace/module_dependencies.txt

Whitespace-only changes.

regression/cpp-linter/operator-spacing1/module_dependencies.txt

Whitespace-only changes.
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
CORE
1+
FUTURE
22
main.cpp
33

44
^main\.cpp:23: Remove spaces around = \[whitespace/operators\] \[4\]
5-
^Total errors found: 1$
5+
^# Total errors found: 1$
6+
^EXIT=1$
67
^SIGNAL=0$
78
--
9+
--
10+
Test disabled (marked as "FUTURE") as the corresponding checks in cpplint.py
11+
were commented out in 56aea470fd6 for they yield too many false positives.

regression/cpp-linter/operator-spacing2/module_dependencies.txt

Whitespace-only changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CORE
22
main.cpp
33

4-
^Total errors found: 0$
4+
^# Total errors found: 0$
55
^EXIT=0$
66
^SIGNAL=0$
77
--

regression/cpp-linter/operator-spacing3/module_dependencies.txt

Whitespace-only changes.

regression/cpp-linter/operator-spacing3/test.desc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ main.cpp
55
^main\.cpp:27: Missing spaces around << \[whitespace/operators\] \[3\]
66
^main\.cpp:29: Remove spaces around << \[whitespace/operators\] \[4\]
77
^main\.cpp:29: Remove spaces around << \[whitespace/operators\] \[4\]
8-
^Total errors found: 4$
8+
^# Total errors found: 4$
9+
^EXIT=1$
910
^SIGNAL=0$
1011
--

regression/cpp-linter/override-final/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Author: Thomas Kiley, [email protected]
66
77
\*******************************************************************/
88

9-
class test_classt:public base_classt
9+
class test_classt : public base_classt
1010
{
1111
public:
1212
virtual void fun() override final;

regression/cpp-linter/override-final/module_dependencies.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)