]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Improve `pylintrc`.
authorNicholas Nethercote <n.nethercote@gmail.com>
Wed, 5 Apr 2023 23:25:15 +0000 (09:25 +1000)
committerNicholas Nethercote <n.nethercote@gmail.com>
Wed, 5 Apr 2023 23:29:08 +0000 (09:29 +1000)
- Move it to `auxprogs/`, alongside `pybuild.sh`.
- Disable the annoying design lints, instead of just modifying the
  values (which often requires modifying them again later).

auxprogs/pybuild.sh
auxprogs/pylintrc [new file with mode: 0644]
cachegrind/Makefile.am
cachegrind/cg_annotate.in
cachegrind/pylintrc [deleted file]

index 432a768c5130532b8e75612d91744333200fee49..371189a68fdff25007f7d78614ea2d0b0829c779 100755 (executable)
@@ -44,8 +44,9 @@ set -e
 ver=3.9
 pyver=py39
 
-infile=$1
-outfile=$2
+auxprogs=$1
+infile=$2
+outfile=$3
 if [ -z "$outfile" ] ; then
     exit 1
 fi
@@ -80,7 +81,7 @@ ruff check --target-version $pyver $infile
 echo
 
 echo "== pylint =="
-pylint --py-version $ver $infile
+pylint --rcfile=$auxprogs/pylintrc --py-version $ver $infile
 
 echo "== config.status =="
 make $outfile
diff --git a/auxprogs/pylintrc b/auxprogs/pylintrc
new file mode 100644 (file)
index 0000000..8f51d2d
--- /dev/null
@@ -0,0 +1,28 @@
+# How to create this file.
+# - Generate with `pylint --generate-rcfile > pylintrc`. Do this in a directory
+#   that doesn't already contain a `pylintrc` file, because the output is
+#   affected by any existing `pylintrc` file.
+# - Then modify entries resulting in unreasonable warnings.
+#   - If a lint is never interesting, add it to the `disable=` list with an
+#     explanatory comment.
+#   - If a lint is interesting but needs modification, comment out the original
+#     value, add a new value along with an explanatory comment.
+# - Remove all non-modified entries.
+
+[MESSAGES CONTROL]
+
+disable=
+    # We don't care about having docstrings for all functions/classes.
+    missing-class-docstring, missing-function-docstring,
+    # We don't care about large functions, sometimes it's necessary.
+    too-many-branches, too-many-locals, too-many-statements,
+    # Zero or one public methods in a class is fine.
+    too-few-public-methods,
+
+[BASIC]
+
+# Good variable names regexes, separated by a comma. If names match any regex,
+# they will always be accepted
+#good-names-rgxs=
+# We allow any lower-case variable name of length 1 or 2.
+good-names-rgxs=\b[a-z]\b,\b[a-z][a-z0-9]\b
index cbaa90522b17143b399bb6e3c9d33f38899d0a8a..0e0ef12b4d91714ce06b3072659491caedd57447 100644 (file)
@@ -76,14 +76,14 @@ endif
 
 # "Build" `cg_annotate`. The `+` avoids warnings about the jobserver.
 pyann:
-       +../auxprogs/pybuild.sh cg_annotate.in cg_annotate
+       +../auxprogs/pybuild.sh ../auxprogs cg_annotate.in cg_annotate
 
 # "Build" `cg_diff`. The `+` avoids warnings about the jobserver.
 pydiff:
-       +../auxprogs/pybuild.sh cg_diff.in cg_diff
+       +../auxprogs/pybuild.sh ../auxprogs cg_diff.in cg_diff
 
 # "Build" `cg_merge`. The `+` avoids warnings about the jobserver.
 pymerge:
-       +../auxprogs/pybuild.sh cg_merge.in cg_merge
+       +../auxprogs/pybuild.sh ../auxprogs cg_merge.in cg_merge
 
 .PHONY: pyann pydiff pymerge
index dcc60de2e65c571a4e619b6856bb1783d1198dbc..5dad969f6af4ffc39afd61dfdc89cb1bdb6b4e37 100755 (executable)
@@ -73,7 +73,7 @@ class Args(Namespace):
             raise ValueError
 
         def add_bool_argument(
-            p: ArgumentParser, new_name: str, old_name: str, help: str
+            p: ArgumentParser, new_name: str, old_name: str, help_: str
         ) -> None:
             """
             Add a bool argument that defaults to true.
@@ -92,7 +92,7 @@ class Args(Namespace):
                 new_flag,
                 default=True,
                 action=BooleanOptionalAction,
-                help=help,
+                help=help_,
             )
             p.add_argument(
                 f"{old_flag}=yes",
diff --git a/cachegrind/pylintrc b/cachegrind/pylintrc
deleted file mode 100644 (file)
index 4b2cfb3..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-# How to create this file.
-# - Generate with `pylint --generate-rcfile > pylintrc`.
-# - Then modify entries resulting in unreasonable warnings. Comment out the
-#   original value, and add another comment line explaining the modification.
-# - Remove all non-modified entries.
-
-[BASIC]
-
-# Minimum line length for functions/classes that require docstrings, shorter
-# ones are exempt.
-#docstring-min-length=-1
-# We don't care about having docstrings for all functions/classes.
-docstring-min-length=1000
-
-# Good variable names regexes, separated by a comma. If names match any regex,
-# they will always be accepted
-#good-names-rgxs=
-# We allow any lower-case variable name of length 1 or 2.
-good-names-rgxs=\b[a-z]\b,\b[a-z][a-z0-9]\b
-
-[VARIABLES]
-
-# List of names allowed to shadow builtins
-#allowed-redefined-builtins=
-# We use `help` reasonably as an argument.
-allowed-redefined-builtins=help
-
-[DESIGN]
-
-# Maximum number of arguments for function / method.
-#max-args=5
-# We have some large functions.
-max-args=7
-
-# Maximum number of branch for function / method body.
-#max-branches=12
-# We have some large functions.
-max-branches=25
-
-# Maximum number of locals for function / method body.
-#max-locals=15
-# We have some large functions.
-max-locals=25
-
-# Maximum number of statements in function / method body.
-#max-statements=50
-# We have some large functions.
-max-statements=65
-
-# Minimum number of public methods for a class (see R0903).
-#min-public-methods=2
-# We have some useful classes with little more than `__init__`.
-min-public-methods=0