diff options
author | Thomas Bracht Laumann Jespersen <t@laumann.xyz> | 2022-04-20 13:57:17 +0200 |
---|---|---|
committer | Arthur Zamarin <arthurzam@gentoo.org> | 2022-05-14 10:25:04 +0300 |
commit | c2001e0c6ebf1c30c75ff919b9dcda4b3ba89621 (patch) | |
tree | 432d752c14d802dd78525bb9a6e26bc09fdbde9b | |
parent | new check: LICENSE should not contain variables (diff) | |
download | pkgcheck-c2001e0c6ebf1c30c75ff919b9dcda4b3ba89621.tar.gz pkgcheck-c2001e0c6ebf1c30c75ff919b9dcda4b3ba89621.tar.bz2 pkgcheck-c2001e0c6ebf1c30c75ff919b9dcda4b3ba89621.zip |
new check: calls to eend without an argument
Calls to eend should always have an argument, there's already a QA
notice in portage for this.
Signed-off-by: Thomas Bracht Laumann Jespersen <t@laumann.xyz>
Closes: https://github.com/pkgcore/pkgcheck/pull/365
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
4 files changed, 44 insertions, 0 deletions
diff --git a/src/pkgcheck/checks/codingstyle.py b/src/pkgcheck/checks/codingstyle.py index 2140881d..56e0f7ec 100644 --- a/src/pkgcheck/checks/codingstyle.py +++ b/src/pkgcheck/checks/codingstyle.py @@ -79,6 +79,29 @@ class BadCommandsCheck(Check): yield DeprecatedEapiCommand(name, line=call, lineno=lineno+1, eapi=pkg.eapi, pkg=pkg) +class EendMissingArg(results.LineResult, results.Warning): + """Ebuild calls eend with no arguments.""" + + @property + def desc(self): + return f'eend with no arguments, on line {self.lineno}' + + +class EendMissingArgCheck(Check): + """Scan an ebuild for calls to eend with no arguments.""" + + _source = sources.EbuildParseRepoSource + known_results = frozenset([EendMissingArg]) + + def feed(self, pkg): + for func_node, _ in bash.func_query.captures(pkg.tree.root_node): + for node, _ in bash.cmd_query.captures(func_node): + line = pkg.node_str(node) + if line == "eend": + lineno, _ = node.start_point + yield EendMissingArg(line=line, lineno=lineno+1, pkg=pkg) + + class MissingSlash(results.VersionResult, results.Error): """Ebuild uses a path variable missing a trailing slash.""" diff --git a/testdata/data/repos/standalone/EendMissingArgCheck/EendMissingArg/expected.json b/testdata/data/repos/standalone/EendMissingArgCheck/EendMissingArg/expected.json new file mode 100644 index 00000000..5ccb6433 --- /dev/null +++ b/testdata/data/repos/standalone/EendMissingArgCheck/EendMissingArg/expected.json @@ -0,0 +1 @@ +{"__class__": "EendMissingArg", "category": "EendMissingArgCheck", "package": "EendMissingArg", "version": "0", "line": "eend", "lineno": 10} diff --git a/testdata/data/repos/standalone/EendMissingArgCheck/EendMissingArg/fix.patch b/testdata/data/repos/standalone/EendMissingArgCheck/EendMissingArg/fix.patch new file mode 100644 index 00000000..2a0330c3 --- /dev/null +++ b/testdata/data/repos/standalone/EendMissingArgCheck/EendMissingArg/fix.patch @@ -0,0 +1,9 @@ +--- standalone/EendMissingArgCheck/EendMissingArg/EendMissingArg-0.ebuild 2022-04-20 14:25:14.385255909 +0200 ++++ fixed/EendMissingArgCheck/EendMissingArg/EendMissingArg-0.ebuild 2022-04-20 15:42:04.363051160 +0200 +@@ -7,5 +7,5 @@ + + src_install() { + ebegin "installing" +- eend ++ eend $? + } diff --git a/testdata/repos/standalone/EendMissingArgCheck/EendMissingArg/EendMissingArg-0.ebuild b/testdata/repos/standalone/EendMissingArgCheck/EendMissingArg/EendMissingArg-0.ebuild new file mode 100644 index 00000000..4db1fcc3 --- /dev/null +++ b/testdata/repos/standalone/EendMissingArgCheck/EendMissingArg/EendMissingArg-0.ebuild @@ -0,0 +1,11 @@ +EAPI=8 + +DESCRIPTION="Ebuild calling eend without an argument" +HOMEPAGE="https://github.com/pkgcore/pkgcheck" +LICENSE="BSD" +SLOT="0" + +src_install() { + ebegin "installing" + eend +} |