summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFedja Beader <fedja@protonmail.ch>2023-10-03 22:52:28 +0200
committerFedja Beader <fedja@protonmail.ch>2023-10-03 23:00:12 +0200
commit99b1e7f738c6afebef4fc080f64eda49c7116c66 (patch)
treeecf7c0c63b2da3c70a7311ecc7f952d16e5933de
parent0a2d34be04d72b8982cc2cd488f7e6432d30b40b (diff)
downloadmanaplus-cpplint-linelength.tar.gz
manaplus-cpplint-linelength.tar.bz2
manaplus-cpplint-linelength.tar.xz
manaplus-cpplint-linelength.zip
Add new CI job to warn if lines exceed 80 characters, set hard limit to 120.cpplint-linelength
Rationale: a hard limit of 80, while well intended, often results in less readable code. At least one outcome is that developers will give shorter and less clear names to variables. You can observe that it has happened in this codebase. There seems to be no general consensus on what should be a hard limit, with the discussion ranging mostly between 80 and 120, thus 120 is chosen here as the hard cut off.
-rw-r--r--tools/ci/branches/master/.gitlab-ci.yml11
-rwxr-xr-xtools/ci/jobs/cpplint.sh4
2 files changed, 12 insertions, 3 deletions
diff --git a/tools/ci/branches/master/.gitlab-ci.yml b/tools/ci/branches/master/.gitlab-ci.yml
index 610c4dfda..c2ad2ca89 100644
--- a/tools/ci/branches/master/.gitlab-ci.yml
+++ b/tools/ci/branches/master/.gitlab-ci.yml
@@ -267,12 +267,21 @@ mplint:
PACKAGES: gcc g++ git
make autoconf automake autopoint gettext
+cpplint_line_length_warning:
+ stage: prebuild
+ script:
+ - ./tools/ci/jobs/cpplint.sh --linelength=80
+ <<: *job-push
+ variables:
+ PACKAGES: wget grep
+ allow_failure: true
+
linters:
stage: prebuild
script:
- ./tools/ci/jobs/pngcheck.sh
- ./tools/ci/jobs/imagemagiccheck.sh
- - ./tools/ci/jobs/cpplint.sh
+ - ./tools/ci/jobs/cpplint.sh --linelength=120
- ./tools/ci/jobs/nsiqcppstyle.sh
<<: *job-push
variables:
diff --git a/tools/ci/jobs/cpplint.sh b/tools/ci/jobs/cpplint.sh
index 7bbccf271..0f63a77e3 100755
--- a/tools/ci/jobs/cpplint.sh
+++ b/tools/ci/jobs/cpplint.sh
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
-
+# Extra arguments will be passed to cpplint
export LOGFILE=cpplint.log
source ./tools/ci/scripts/init.sh
@@ -43,7 +43,7 @@ args+=("--filter=\
find src \
-type f \
-name "*.cpp" -o -name "*.hpp" -o -name "*.h" -o -name "*.cc" \
- -exec ./cpplint.py "${args[@]}" {} \+ 2>${ERRFILE}2
+ -exec ./cpplint.py "${args[@]}" "$@" {} \+ 2>${ERRFILE}2
grep ": " ${ERRFILE}2 | grep -v -e "src/debug/" \
-e "unittests/doctest.h" \