]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[pre-commit] Add tclint hook
authorTom de Vries <tdevries@suse.de>
Thu, 18 Sep 2025 06:08:41 +0000 (08:08 +0200)
committerTom de Vries <tdevries@suse.de>
Thu, 18 Sep 2025 06:08:41 +0000 (08:08 +0200)
Add a pre-commit hook that enables tclint [1] (a Tcl linter) for the gdb
testsuite.

The pre-commit hook doesn't reference the official url, because that one
doesn't have pre-commit support yet [2].

Instead, it uses a fork on my personal github account.  The fork contains a
tag v0.6.0-gdb, which is the official v0.6.0 release plus a commit adding a
.pre-commit-hooks.yaml file.  Given that this is a personal github account, I
thought it would be safer to refer to the git SHA than to the tag.

Also add a tclint configuration file gdb/tclint.toml.

In the configuration file, we still ignore most dirs because they're not
tclint-clean.

Consequently, the tclint pre-commit check passes:
...
$ pre-commit run --all-files -v tclint
tclint........................Passed
- hook id: tclint
- duration: 0.25s
$
...

PR testsuite/33403
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33403

Approved-By: Tom Tromey <tom@tromey.com>
[1] https://github.com/nmoroze/tclint
[2] https://github.com/nmoroze/tclint/issues/110

.pre-commit-config.yaml
gdb/tclint.toml [new file with mode: 0644]

index a4a8a5fa1efd31b7aa77251488976045cf63571b..5b651b45fd2791a7c18f535b52761f211fed1612 100644 (file)
@@ -88,3 +88,18 @@ repos:
       verbose: true
       always_run: true
       stages: [commit-msg]
+  - # We'd like to use the official repo, like this:
+    #   repo: https://github.com/nmoroze/tclint
+    #   rev: v0.6.0
+    # but it doesn't have a .pre-commit-hooks.yaml file.
+    # Work around this by using an unoffical repo.  The repo contains a tag
+    # v0.6.0-gdb that adds a .pre-commit-hooks.yaml file to the v0.6.0 release
+    # of the offical repo.  Since we're using an unofficial repo, use the git
+    # SHA instead of the tag.
+    repo: https://github.com/vries/tclint.git
+    rev: 2e6b4510fb3d3d6f8f2609af0f7158fabc0c96e4
+    hooks:
+    - id: tclint
+      args: [--config, gdb/tclint.toml]
+      types_or: [file]
+      files: 'gdb/testsuite/.*\.(exp|tcl)$'
diff --git a/gdb/tclint.toml b/gdb/tclint.toml
new file mode 100644 (file)
index 0000000..1cfb0b2
--- /dev/null
@@ -0,0 +1,63 @@
+# Copyright 2025 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Configuration file for tclint ( https://github.com/nmoroze/tclint ).
+
+exclude = [
+"gdb/testsuite/boards",
+"gdb/testsuite/config",
+"gdb/testsuite/lib",
+"gdb/testsuite/gdb.arch",
+"gdb/testsuite/gdb.base",
+"gdb/testsuite/gdb.btrace",
+"gdb/testsuite/gdb.compile",
+"gdb/testsuite/gdb.cp",
+"gdb/testsuite/gdb.ctf",
+"gdb/testsuite/gdb.dwarf2",
+"gdb/testsuite/gdb.fortran",
+"gdb/testsuite/gdb.guile",
+"gdb/testsuite/gdb.mi",
+"gdb/testsuite/gdb.opencl",
+"gdb/testsuite/gdb.perf",
+"gdb/testsuite/gdb.python",
+"gdb/testsuite/gdb.reverse",
+"gdb/testsuite/gdb.stabs",
+"gdb/testsuite/gdb.threads",
+"gdb/testsuite/gdb.trace",
+]
+
+# A maximum line length of 80 is current policy, but it hasn't been too
+# strictly enforced.  It's the most frequent and least harmful violation.
+# Ignore this for now.
+ignore = ["line-length"]
+
+extensions = ["exp", "tcl"]
+
+[style]
+# Used by tclfmt.  Doesn't support the mixed TAB and spaces style we use. See
+# this tclint issue ( https://github.com/nmoroze/tclint/issues/109 ).
+indent = 4
+
+# Used by both tclint and tclfmt.  Current policy is 80.
+line-length = 80
+
+# Used by tclfmt.
+max-blank-lines = 1
+
+# Used by tclfmt.  False conflicts with emacs tcl mode.
+indent-namespace-eval = true
+
+# Used by tclfmt.
+spaces-in-braces = false