diff options
author | Arthur Zamarin <arthurzam@gentoo.org> | 2023-09-22 12:12:27 +0300 |
---|---|---|
committer | Arthur Zamarin <arthurzam@gentoo.org> | 2023-09-23 18:12:43 +0300 |
commit | 3fcc1f919251c10c1f1ea105f776d7e9c6f5e18e (patch) | |
tree | ddd5b1ea99d834b6de6c7793be69a0ed450dc5ec /src | |
parent | SelfAssignment: check for global scope self assignments (diff) | |
download | pkgcheck-3fcc1f919251c10c1f1ea105f776d7e9c6f5e18e.tar.gz pkgcheck-3fcc1f919251c10c1f1ea105f776d7e9c6f5e18e.tar.bz2 pkgcheck-3fcc1f919251c10c1f1ea105f776d7e9c6f5e18e.zip |
BannedPhaseCall: detect calls of phase functions directly
Resolves: https://github.com/pkgcore/pkgcheck/issues/625
Closes: https://bugs.gentoo.org/596616
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/pkgcheck/checks/codingstyle.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/pkgcheck/checks/codingstyle.py b/src/pkgcheck/checks/codingstyle.py index ad75436b..1838be28 100644 --- a/src/pkgcheck/checks/codingstyle.py +++ b/src/pkgcheck/checks/codingstyle.py @@ -61,11 +61,19 @@ class BannedEapiCommand(_EapiCommandResult, results.Error): _status = "banned" +class BannedPhaseCall(results.Error, results.LineResult): + """Ebuild calls a phase function directly.""" + + @property + def desc(self): + return f"line {self.lineno}: calling phase function {self.line!r} directly is invalid" + + class BadCommandsCheck(Check): """Scan ebuild for various deprecated and banned command usage.""" _source = sources.EbuildParseRepoSource - known_results = frozenset([DeprecatedEapiCommand, BannedEapiCommand]) + known_results = frozenset({DeprecatedEapiCommand, BannedEapiCommand, BannedPhaseCall}) def feed(self, pkg): for func_node, _ in bash.func_query.captures(pkg.tree.root_node): @@ -81,6 +89,8 @@ class BadCommandsCheck(Check): yield DeprecatedEapiCommand( name, line=call, lineno=lineno + 1, eapi=pkg.eapi, pkg=pkg ) + elif name in pkg.eapi.phases.values(): + yield BannedPhaseCall(line=name, lineno=lineno + 1, pkg=pkg) class EendMissingArg(results.LineResult, results.Warning): |