Skip to content

Make cpplint check actually work in CI #5929

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 4 commits into from
Mar 21, 2021
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
3 changes: 2 additions & 1 deletion .github/workflows/pull-request-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,8 @@ jobs:
# user input
DEBIAN_FRONTEND: noninteractive
run: |
pip install unidiff
sudo apt-get update
sudo apt-get install --no-install-recommends -yq python3-unidiff
- name: Check updated lines of code meet linting standards
env:
BASE_BRANCH: ${{ github.base_ref }}
Expand Down
1 change: 1 addition & 0 deletions regression/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ add_subdirectory(validate-trace-xml-schema)
add_subdirectory(cbmc-primitives)
add_subdirectory(goto-interpreter)
add_subdirectory(cbmc-sequentialization)
add_subdirectory(cpp-linter)

if(WITH_MEMORY_ANALYZER)
add_subdirectory(snapshot-harness)
Expand Down
1 change: 1 addition & 0 deletions regression/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ DIRS = cbmc \
cbmc-primitives \
goto-interpreter \
cbmc-sequentialization \
cpp-linter \
# Empty last line

ifeq ($(OS),Windows_NT)
Expand Down
1 change: 1 addition & 0 deletions regression/cpp-linter/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_test_pl_tests("../../../scripts/cpplint.py")
4 changes: 2 additions & 2 deletions regression/cpp-linter/Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
default: tests.log

test:
@../test.pl -p -c "python ../../../scripts/cpplint.py"
@../test.pl -p -c ../../../scripts/cpplint.py

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

show:
@for dir in *; do \
Expand Down
Empty file.
5 changes: 3 additions & 2 deletions regression/cpp-linter/assert/test.desc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
CORE
main.cpp

^main\.cpp:8: assert is deprecated, use INVARIANT instead \[build/deprecated\] \[4\]
^Total errors found: 1$
^regression/cpp-linter/assert/main\.cpp:8: assert is deprecated, use UNREACHABLE instead \[build/deprecated\] \[4\]
^# Total errors found: 1$
^EXIT=1$
^SIGNAL=0$
Empty file.
6 changes: 4 additions & 2 deletions regression/cpp-linter/class-decl-space/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ Author: Thomas Kiley, thomas@diffblue.com

\*******************************************************************/

// clang-format off
class temp_classt : public base_classt
{}

class another_class : public base_classt
class another_class: public base_classt
{}

class more_class:public base_classt
class more_class: public base_classt
{}

class nonderived
Expand Down Expand Up @@ -41,3 +42,4 @@ class testt
template<class U>
void bar(U t);
}
// clang-format on
Empty file.
22 changes: 13 additions & 9 deletions regression/cpp-linter/class-decl-space/test.desc
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
CORE
main.cpp

^main\.cpp:9: There shouldn.t be a space between class identifier and : \[readability/identifiers\] \[4\]$
^main\.cpp:12: There shouldn.t be a space between class identifier and : \[readability/identifiers\] \[4\]$
^main\.cpp:12: Class or struct identifier should end with t \[readability/identifiers\] \[4\]$
^main\.cpp:15: Class or struct identifier should end with t \[readability/identifiers\] \[4\]$
^main\.cpp:18: Class or struct identifier should end with t \[readability/identifiers\] \[4\]$
^main\.cpp:26: Class or struct identifier should end with t \[readability/identifiers\] \[4\]$
^main\.cpp:30: Remove spaces around < \[whitespace/operators\] \[4\]$
^main\.cpp:36: Remove spaces around < \[whitespace/operators\] \[4\]$
^Total errors found: 8$
^regression/cpp-linter/class-decl-space/main\.cpp:13: There should be a space between class identifier and : \[readability/identifier_spacing\] \[4\]$
^regression/cpp-linter/class-decl-space/main\.cpp:16: There should be a space between class identifier and : \[readability/identifier_spacing\] \[4\]$
^regression/cpp-linter/class-decl-space/main\.cpp:13: Class or struct identifier should end with t \[readability/identifiers\] \[4\]$
^regression/cpp-linter/class-decl-space/main\.cpp:16: Class or struct identifier should end with t \[readability/identifiers\] \[4\]$
^regression/cpp-linter/class-decl-space/main\.cpp:19: Class or struct identifier should end with t \[readability/identifiers\] \[4\]$
^regression/cpp-linter/class-decl-space/main\.cpp:27: Class or struct identifier should end with t \[readability/identifiers\] \[4\]$
^# Total errors found: 6$
^EXIT=1$
^SIGNAL=0$
--
--
The following patters are disabled as the corresponding checks in cpplint.py
were commented out in 56aea470fd6 for they yield too many false positives:
^regression/cpp-linter/class-decl-space/main\.cpp:31: Remove spaces around < \[whitespace/operators\] \[4\]$
^regression/cpp-linter/class-decl-space/main\.cpp:37: Remove spaces around < \[whitespace/operators\] \[4\]$
Empty file.
7 changes: 4 additions & 3 deletions regression/cpp-linter/do-while1/test.desc
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
CORE
main.cpp

^main\.cpp:31: Empty loop bodies should use \{\} or continue \[whitespace/empty_loop_body\] \[5\]$
^main\.cpp:38: Empty loop bodies should use \{\} or continue \[whitespace/empty_loop_body\] \[5\]$
^Total errors found: 2$
^regression/cpp-linter/do-while1/main\.cpp:31: Empty loop bodies should use \{\} or continue \[whitespace/empty_loop_body\] \[5\]$
^regression/cpp-linter/do-while1/main\.cpp:38: Empty loop bodies should use \{\} or continue \[whitespace/empty_loop_body\] \[5\]$
^# Total errors found: 2$
^EXIT=1$
^SIGNAL=0$
--
Empty file.
7 changes: 5 additions & 2 deletions regression/cpp-linter/do-while2/test.desc
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
CORE
main.cpp

^main\.cpp:26: while statement of do...while loop should be on a separate line to the closing brace \[readability/braces\] \[4\]
^Total errors found: 1$
^EXIT=0$
^SIGNAL=0$
--
--
Test was marked as disabled-by-default in a00edd3e6c54.
^main\.cpp:26: while statement of do...while loop should be on a separate line to the closing brace \[readability/braces\] \[4\]
^# Total errors found: 1$
Empty file.
9 changes: 7 additions & 2 deletions regression/cpp-linter/function-comment-header1/test.desc
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
CORE
KNOWNBUG
main.cpp

^main\.cpp:26: Could not find function header comment for foo \[readability/function_comment\] \[4\]
^Total errors found: 1$
^# Total errors found: 1$
^EXIT=1$
^SIGNAL=0$
--
--
The checking code in cpplint.py was broken in 7302e56a348, where a wrong indent
caused the check to never take place. That's fine, however, as we don't use
these function headers anymore.
Empty file.
9 changes: 7 additions & 2 deletions regression/cpp-linter/function-comment-header2/test.desc
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
CORE
KNOWNBUG
main.cpp

main\.cpp:15: Function header for fun missing Inputs: \[readability/function_comment\] \[4\]
main\.cpp:15: Function header for fun missing Outputs: \[readability/function_comment\] \[4\]
main\.cpp:15: Function header for fun missing Purpose: \[readability/function_comment\] \[4\]
^Total errors found: 3$
^# Total errors found: 3$
^EXIT=1$
^SIGNAL=0$
--
--
The checking code in cpplint.py was broken in 7302e56a348, where a wrong indent
caused the check to never take place. That's fine, however, as we don't use
these function headers anymore.
Empty file.
9 changes: 7 additions & 2 deletions regression/cpp-linter/function-comment-header3/test.desc
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
CORE
KNOWNBUG
main.cpp

^main\.cpp:20: Insert an empty line between function header comment and the function fun \[readability/function_comment\] \[4\]$
^Total errors found: 1$
^# Total errors found: 1$
^EXIT=1$
^SIGNAL=0$
--
--
The checking code in cpplint.py was broken in 7302e56a348, where a wrong indent
caused the check to never take place. That's fine, however, as we don't use
these function headers anymore.
Empty file.
9 changes: 7 additions & 2 deletions regression/cpp-linter/function-comment-header4/test.desc
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
CORE
KNOWNBUG
main.cpp

^main\.cpp:11: Function: name in the comment doesn.t match the function name \[readability/function_comment\] \[4\]
^Total errors found: 1$
^# Total errors found: 1$
^EXIT=1$
^SIGNAL=0$
--
--
The checking code in cpplint.py was broken in 7302e56a348, where a wrong indent
caused the check to never take place. That's fine, however, as we don't use
these function headers anymore.
Empty file.
2 changes: 1 addition & 1 deletion regression/cpp-linter/function-comment-header5/test.desc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CORE
main.cpp

^Total errors found: 0$
^# Total errors found: 0$
^EXIT=0$
^SIGNAL=0$
--
Empty file.
2 changes: 1 addition & 1 deletion regression/cpp-linter/function-comment-header6/test.desc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CORE
main.cpp

^Total errors found: 0$
^# Total errors found: 0$
^EXIT=0$
^SIGNAL=0$
--
Empty file.
2 changes: 1 addition & 1 deletion regression/cpp-linter/function-comment-header7/test.desc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CORE
main.cpp

^Total errors found: 0$
^# Total errors found: 0$
^EXIT=0$
^SIGNAL=0$
--
Empty file.
16 changes: 10 additions & 6 deletions regression/cpp-linter/if-else1/test.desc
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
CORE
main.cpp

^main\.cpp:24: Put braces on a separate next line \[whitespace/braces\] \[5\]$
^main\.cpp:26: Put braces on a separate next line \[whitespace/braces\] \[5\]$
^main\.cpp:26: Else if should be on a new line after closing brace \[readability/braces\] \[5\]$
^main\.cpp:28: Put braces on a separate next line \[whitespace/braces\] \[5\]$
^main\.cpp:28: Else should be on a new line after closing brace \[readability/braces\] \[5\]$
^Total errors found: 5$
^regression/cpp-linter/if-else1/main\.cpp:26: Else if should be on a new line after closing brace \[readability/braces\] \[5\]$
^regression/cpp-linter/if-else1/main\.cpp:28: Else should be on a new line after closing brace \[readability/braces\] \[5\]$
^# Total errors found: 2$
^EXIT=1$
^SIGNAL=0$
--
--
The following patters are disabled as the corresponding checks in cpplint.py
were removed in 692c4f377 for they are covered by clang-format:
^regression/cpp-linter/if-else1/main\.cpp:24: Put braces on a separate next line \[whitespace/braces\] \[5\]$
^regression/cpp-linter/if-else1/main\.cpp:26: Put braces on a separate next line \[whitespace/braces\] \[5\]$
^regression/cpp-linter/if-else1/main\.cpp:28: Put braces on a separate next line \[whitespace/braces\] \[5\]$
Empty file.
10 changes: 7 additions & 3 deletions regression/cpp-linter/if-else2/test.desc
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
CORE
main.cpp

^EXIT=0$
^SIGNAL=0$
--
--
The following patters are disabled as the corresponding checks in cpplint.py
were removed in 692c4f377 for they are covered by clang-format:
^main\.cpp:23: Put braces on a separate next line \[whitespace/braces\] \[5\]$
^main\.cpp:26: Put braces on a separate next line \[whitespace/braces\] \[5\]$
^main\.cpp:29: Put braces on a separate next line \[whitespace/braces\] \[5\]$
^Total errors found: 3$
^SIGNAL=0$
--
^# Total errors found: 3$
Empty file.
12 changes: 8 additions & 4 deletions regression/cpp-linter/if-else3/test.desc
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
CORE
main.cpp

^main\.cpp:24: Statement after an if should be on a new line \[readability/braces\] \[5\]$
^main\.cpp:25: Statement after else if should be on a new line \[readability/braces\] \[5\]$
^main\.cpp:26: Statement after else should be on a new line \[readability/braces\] \[5\]$
^Total errors found: 3$
^regression/cpp-linter/if-else3/main\.cpp:24: Statement after an if should be on a new line \[readability/braces\] \[5\]$
^regression/cpp-linter/if-else3/main\.cpp:25: Statement after else if should be on a new line \[readability/braces\] \[5\]$
^# Total errors found: 2$
^EXIT=1$
^SIGNAL=0$
--
--
The following patters are disabled as the corresponding checks in cpplint.py
were commented out in 56aea470fd6 for they yield too many false positives:
^regression/cpp-linter/if-else3/main\.cpp:26: Statement after else should be on a new line \[readability/braces\] \[5\]$
Empty file.
12 changes: 8 additions & 4 deletions regression/cpp-linter/if-else4/test.desc
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
CORE
main.cpp

^main\.cpp:24: Statement after an if should be on a new line \[readability/braces\] \[5\]$
^main\.cpp:25: Statement after else if should be on a new line \[readability/braces\] \[5\]$
^main\.cpp:26: Statement after else should be on a new line \[readability/braces\] \[5\]$
^Total errors found: 3$
^regression/cpp-linter/if-else4/main\.cpp:24: Statement after an if should be on a new line \[readability/braces\] \[5\]$
^regression/cpp-linter/if-else4/main\.cpp:25: Statement after else if should be on a new line \[readability/braces\] \[5\]$
^# Total errors found: 2$
^EXIT=1$
^SIGNAL=0$
--
--
The following patters are disabled as the corresponding checks in cpplint.py
were commented out in 56aea470fd6 for they yield too many false positives:
^regression/cpp-linter/if-else4/main\.cpp:26: Statement after else should be on a new line \[readability/braces\] \[5\]$
Empty file.
2 changes: 1 addition & 1 deletion regression/cpp-linter/if-else5/test.desc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CORE
main.cpp

^Total errors found: 0$
^# Total errors found: 0$
^EXIT=0$
^SIGNAL=0$
--
Empty file.
2 changes: 1 addition & 1 deletion regression/cpp-linter/if-else6/test.desc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CORE
main.cpp

^Total errors found: 0$
^# Total errors found: 0$
^EXIT=0$
^SIGNAL=0$
--
Empty file.
Empty file.
11 changes: 7 additions & 4 deletions regression/cpp-linter/multi-line-function-call1/test.desc
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
CORE
main.cpp

^EXIT=0$
^SIGNAL=0$
--
--
The following patters are disabled as the corresponding checks in cpplint.py
were commented out in 56aea470fd6 for they yield too many false positives:
^main\.cpp:29: If parameters or arguments require a line break, each parameter should be put on its own line\. \[whitespace/indent\] \[4\]
^main\.cpp:34: Indent of wrapped parenthesized expression or parameter or argument list should be 2 \[whitespace/indent\] \[4\]
^main\.cpp:43: If parameters or arguments require a line break, each parameter should be put on its own line\. \[whitespace/indent\] \[4\]
Expand All @@ -11,7 +17,4 @@ main.cpp
^main\.cpp:76: Indent of wrapped parenthesized expression or parameter or argument list should be 2 \[whitespace/indent\] \[4\]
^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\]
^main\.cpp:85: If parameters or arguments require a line break, each parameter should be put on its own line. \[whitespace/indent\] \[4\]
^Total errors found: 10$
^EXIT=1$
^SIGNAL=0$
--
^# Total errors found: 10$
Empty file.
11 changes: 7 additions & 4 deletions regression/cpp-linter/multi-line-function-call2/test.desc
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
CORE
main.cpp

^EXIT=0$
^SIGNAL=0$
--
--
The following patters are disabled as the corresponding checks in cpplint.py
were commented out in 56aea470fd6 for they yield too many false positives:
^main\.cpp:24: If parameters or arguments require a line break, each parameter should be put on its own line\. \[whitespace/indent\] \[4\]
^main\.cpp:29: Indent of wrapped parenthesized expression or parameter or argument list should be 2 \[whitespace/indent\] \[4\]
^main\.cpp:60: If parameters or arguments require a line break, each parameter should be put on its own line\. \[whitespace/indent\] \[4\]
^main\.cpp:65: If parameters or arguments require a line break, each parameter should be put on its own line\. \[whitespace/indent\] \[4\]
^Total errors found: 4$
^EXIT=1$
^SIGNAL=0$
--
^# Total errors found: 4$
Empty file.
2 changes: 1 addition & 1 deletion regression/cpp-linter/multi-line-function-call3/test.desc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CORE
main.cpp

^Total errors found: 0$
^# Total errors found: 0$
^EXIT=0$
^SIGNAL=0$
--
Empty file.
Empty file.
Empty file.
Empty file.
8 changes: 6 additions & 2 deletions regression/cpp-linter/operator-spacing1/test.desc
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
CORE
FUTURE
main.cpp

^main\.cpp:23: Remove spaces around = \[whitespace/operators\] \[4\]
^Total errors found: 1$
^# Total errors found: 1$
^EXIT=1$
^SIGNAL=0$
--
--
Test disabled (marked as "FUTURE") as the corresponding checks in cpplint.py
were commented out in 56aea470fd6 for they yield too many false positives.
Empty file.
2 changes: 1 addition & 1 deletion regression/cpp-linter/operator-spacing2/test.desc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CORE
main.cpp

^Total errors found: 0$
^# Total errors found: 0$
^EXIT=0$
^SIGNAL=0$
--
Empty file.
3 changes: 2 additions & 1 deletion regression/cpp-linter/operator-spacing3/test.desc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ main.cpp
^main\.cpp:27: Missing spaces around << \[whitespace/operators\] \[3\]
^main\.cpp:29: Remove spaces around << \[whitespace/operators\] \[4\]
^main\.cpp:29: Remove spaces around << \[whitespace/operators\] \[4\]
^Total errors found: 4$
^# Total errors found: 4$
^EXIT=1$
^SIGNAL=0$
--
2 changes: 1 addition & 1 deletion regression/cpp-linter/override-final/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Author: Thomas Kiley, thomas@diffblue.com

\*******************************************************************/

class test_classt:public base_classt
class test_classt : public base_classt
{
public:
virtual void fun() override final;
Expand Down
Empty file.
Loading