From c1f2bfe5361d5e3aa5316c26d9354cbd2e63880f Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Tue, 24 Nov 2020 03:25:45 +0100 Subject: [PATCH 1/3] Recommend to add --quiet when using raw systemclt enable/disable --- package_linter.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/package_linter.py b/package_linter.py index 4638409..ebb5879 100755 --- a/package_linter.py +++ b/package_linter.py @@ -1141,6 +1141,17 @@ class Script(TestSuite): "and should be avoided at all cost. Use 'reload' instead." ) + @test() + def quiet_systemctl_enable(self): + + systemctl_enable = [line + for line in [' '.join(line) for line in self.lines] + if re.search(r"systemctl.*(enable|disable)", line)] + + if any("-q" not in cmd for cmd in systemctl_enable): + message = "Please add --quiet to systemctl enable/disable commands to avoid unecessary warnings when the script runs" + yield Warning(message) if self.name in ["_common.sh", "install"] else Info(message) + @test(only=["install"]) def argument_fetching(self): From b00ef3d23cad038f6b2a5e43b790aaa6166e3ec1 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Tue, 24 Nov 2020 03:45:10 +0100 Subject: [PATCH 2/3] Make sure wget is quiet --- package_linter.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/package_linter.py b/package_linter.py index ebb5879..0517984 100755 --- a/package_linter.py +++ b/package_linter.py @@ -1152,6 +1152,17 @@ class Script(TestSuite): message = "Please add --quiet to systemctl enable/disable commands to avoid unecessary warnings when the script runs" yield Warning(message) if self.name in ["_common.sh", "install"] else Info(message) + @test() + def quiet_wget(self): + + wget_cmds = [line + for line in [' '.join(line) for line in self.lines] + if re.search(r"^wget ", line)] + + if any(" -q " not in cmd and "--quiet" not in cmd and "2>" not in cmd for cmd in wget_cmds): + message = "Please redirect wget's stderr to stdout with 2>&1 to avoid unecessary warnings when the script runs (yes, wget is annoying and displays a warning even when things are going okay >_> ...)" + yield Warning(message) if self.name in ["_common.sh", "install"] else Info(message) + @test(only=["install"]) def argument_fetching(self): From 6cc1b2f3302205a883195ab7dfca4e46060ef883 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Wed, 25 Nov 2020 02:11:26 +0100 Subject: [PATCH 3/3] Report is_public default value being a string --- package_linter.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/package_linter.py b/package_linter.py index 0517984..d893a53 100755 --- a/package_linter.py +++ b/package_linter.py @@ -984,6 +984,10 @@ class Manifest(TestSuite): "The type '%s' for argument '%s' is not recognized... " "it probably doesn't behave as you expect ? Choose among those instead : %s" % (argument["type"], argument["name"], ', '.join(recognized_types)) ) + elif argument["type"] == "boolean" and argument.get("default", True) not in [True, False]: + yield Warning( + "Default value for boolean-type arguments should be a boolean... (in particular, make sure it's not a string!)" + ) if "choices" in argument.keys(): choices = [c.lower() for c in argument["choices"]]