Chore: Move linting from coala to pre-commit 59/5159/1
authorEric Ball <eball@linuxfoundation.org>
Tue, 6 Aug 2024 16:37:42 +0000 (09:37 -0700)
committerEric Ball <eball@linuxfoundation.org>
Tue, 6 Aug 2024 17:41:40 +0000 (10:41 -0700)
Issue-ID: LF-Jira RELENG-4799
Change-Id: I561f1c3165e36cbb9f49b2312ab00cfc6ac9f7f6
Signed-off-by: Eric Ball <eball@linuxfoundation.org>
.coafile [deleted file]
.pre-commit-config.yaml [new file with mode: 0644]
tox.ini

diff --git a/.coafile b/.coafile
deleted file mode 100644 (file)
index 5191c49..0000000
--- a/.coafile
+++ /dev/null
@@ -1,53 +0,0 @@
-[all]
-ignore = .tox/**,
-    .git/**,
-    .gitignore,
-    .gitreview,
-    .gitmodules,
-    **.sw?,
-    **.orig
-
-[all.GitCommit]
-bears = GitCommitBear
-ignore_length_regex = Signed-off-by,
-    Also-by,
-    Co-authored-by,
-    http://,
-    https://
-
-[all.reStructuredText]
-bears = SpaceConsistencyBear
-files = docs/**.rst
-use_spaces = true
-ignore = .git/**,
-    .tox/**,
-    src/type3_AndroidCloud/**,
-    src/foundation/**
-
-[all.ShellCheck]
-bears = ShellCheckBear,SpaceConsistencyBear
-files = **.sh
-shell = bash
-use_spaces = true
-ignore = src/type3_AndroidCloud/**,
-    src/foundation/**
-
-[all.YAML]
-bears = YAMLLintBear
-files = **.yaml, **.yml
-use_spaces = true
-ignore_length_regex = ^.*https?://
-yamllint_config = .yamllint.conf
-ignore = src/use_cases/**,
-    src/type3_AndroidCloud/**,
-    src/foundation/**
-
-
-[all.Python]
-bears = PyLintBear
-files = **.py
-use_spaces = true
-pylint_disable = E0401, W0401, C0111
-ignore = src/use_cases/**,
-    src/type3_AndroidCloud/**,
-    src/foundation/**
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644 (file)
index 0000000..569a97b
--- /dev/null
@@ -0,0 +1,17 @@
+---
+# To simplify and beautify the long regex for exclude, newlines (which will be
+# parsed into spaces) are followed by '*', in order to allow the regex to read
+# this whitespace as "0 or more spaces".
+exclude: >-
+  src/use_cases/seba_on_arm/src_repo/.*|
+  *\.git.*
+repos:
+  - repo: https://github.com/pre-commit/pre-commit-hooks
+    rev: v4.6.0
+    hooks:
+      - id: trailing-whitespace
+
+  - repo: https://github.com/jorisroovers/gitlint
+    rev: v0.19.1
+    hooks:
+      - id: gitlint
diff --git a/tox.ini b/tox.ini
index 0e89eb8..1bb1153 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -10,7 +10,7 @@ minversion = 1.6
 envlist =
   docs,
   docs-linkcheck,
-  coala,
+  pre-commit
 skipsdist = true
 passenv = TOX_WORK_DIR
 toxworkdir = {env:TOX_WORK_DIR:/tmp/v}
@@ -20,21 +20,17 @@ deps = -rdocs/requirements.txt
 commands =
     sphinx-build -b html -n -d {envtmpdir}/doctrees ./docs/ {toxinidir}/docs/_build/html
     echo "Generated docs available in {toxinidir}/docs/_build/html"
-whitelist_externals = echo
+allowlist_externals = echo
 
 [testenv:docs-linkcheck]
 deps = -rdocs/requirements.txt
 commands = sphinx-build -b linkcheck -d {envtmpdir}/doctrees ./docs/ {toxinidir}/docs/_build/linkcheck
 
-[testenv:coala]
+[testenv:pre-commit]
 basepython = python3
-install_command = python -m pip install --no-cache-dir {opts} {packages}
-whitelist_externals = rm
+allowlist_externals = rm
 deps =
-    coala
-    coala-bears
-    pygments~=2.3.1
-    requests~=2.21.0
+    pre-commit
 commands =
-    rm -rf src/use_cases/seba_on_arm/src_repo/
-    coala --non-interactive
+    pre-commit install
+    pre-commit run --all-files