Skip to content

Commit aa07a70

Browse files
committed
BadCommandsCheck: limit to check function scope command usage
Non-bash and external global command usage should be caught during sourcing.
1 parent 138c199 commit aa07a70

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

src/pkgcheck/checks/codingstyle.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,15 @@ class BadCommandsCheck(Check):
6868
known_results = frozenset([DeprecatedEapiCommand, BannedEapiCommand])
6969

7070
def feed(self, pkg):
71-
for node, _ in bash.cmd_query.captures(pkg.tree.root_node):
72-
call = pkg.node_str(node)
73-
name = pkg.node_str(node.child_by_field_name('name'))
74-
lineno, colno = node.start_point
75-
if name in pkg.eapi.bash_cmds_banned:
76-
yield BannedEapiCommand(name, line=call, lineno=lineno+1, eapi=pkg.eapi, pkg=pkg)
77-
elif name in pkg.eapi.bash_cmds_deprecated:
78-
yield DeprecatedEapiCommand(name, line=call, lineno=lineno+1, eapi=pkg.eapi, pkg=pkg)
71+
for func_node, _ in bash.func_query.captures(pkg.tree.root_node):
72+
for node, _ in bash.cmd_query.captures(func_node):
73+
call = pkg.node_str(node)
74+
name = pkg.node_str(node.child_by_field_name('name'))
75+
lineno, colno = node.start_point
76+
if name in pkg.eapi.bash_cmds_banned:
77+
yield BannedEapiCommand(name, line=call, lineno=lineno+1, eapi=pkg.eapi, pkg=pkg)
78+
elif name in pkg.eapi.bash_cmds_deprecated:
79+
yield DeprecatedEapiCommand(name, line=call, lineno=lineno+1, eapi=pkg.eapi, pkg=pkg)
7980

8081

8182
class MissingSlash(results.VersionResult, results.Error):

0 commit comments

Comments
 (0)