Skip to content

Commit 10489c0

Browse files
committed
eclass: avoid a level of indentation in EclassUsageCheck
Signed-off-by: Sam James <sam@gentoo.org>
1 parent f4be5e8 commit 10489c0

File tree

1 file changed

+37
-35
lines changed

1 file changed

+37
-35
lines changed

src/pkgcheck/checks/eclass.py

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -331,41 +331,43 @@ def check_exported_eclass_phase(
331331
yield ShadowedEclassPhase(missing, sorted(exported_phases[missing]), pkg=pkg)
332332

333333
def feed(self, pkg):
334-
if pkg.inherit:
335-
inherited: set[str] = set()
336-
inherits: list[tuple[list[str], int]] = []
337-
for node in bash.cmd_query.captures(pkg.tree.root_node).get("call", ()):
338-
name = pkg.node_str(node.child_by_field_name("name"))
339-
if name == "inherit":
340-
call = pkg.node_str(node)
341-
# filter out line continuations and conditional inherits
342-
if eclasses := [x for x in call.split()[1:] if x in pkg.inherit]:
343-
lineno, _colno = node.start_point
344-
if not inherited and eclasses[0] == pkg.inherit[0]:
345-
inherits.append((eclasses, lineno))
346-
347-
for eclass in eclasses:
348-
if eclass not in inherited:
349-
inherited.add(eclass)
350-
else:
351-
yield DuplicateEclassInherit(
352-
eclass, line=call, lineno=lineno + 1, pkg=pkg
353-
)
354-
355-
yield from self.check_provided_eclasses(pkg, inherits)
356-
yield from self.check_user_variables(pkg, inherits)
357-
# verify @PRE_INHERIT variable placement
358-
yield from self.check_pre_inherits(pkg, inherits)
359-
# verify @DEPRECATED variables or functions
360-
yield from self.check_deprecated_variables(pkg, inherits)
361-
yield from self.check_deprecated_functions(pkg, inherits)
362-
yield from self.check_exported_eclass_phase(pkg, inherits)
363-
364-
for eclass in pkg.inherit.intersection(self.deprecated_eclasses):
365-
replacement = self.deprecated_eclasses[eclass]
366-
if not isinstance(replacement, str):
367-
replacement = None
368-
yield DeprecatedEclass(eclass, replacement, pkg=pkg)
334+
if not pkg.inherit:
335+
return
336+
337+
inherited: set[str] = set()
338+
inherits: list[tuple[list[str], int]] = []
339+
for node in bash.cmd_query.captures(pkg.tree.root_node).get("call", ()):
340+
name = pkg.node_str(node.child_by_field_name("name"))
341+
if name == "inherit":
342+
call = pkg.node_str(node)
343+
# filter out line continuations and conditional inherits
344+
if eclasses := [x for x in call.split()[1:] if x in pkg.inherit]:
345+
lineno, _colno = node.start_point
346+
if not inherited and eclasses[0] == pkg.inherit[0]:
347+
inherits.append((eclasses, lineno))
348+
349+
for eclass in eclasses:
350+
if eclass not in inherited:
351+
inherited.add(eclass)
352+
else:
353+
yield DuplicateEclassInherit(
354+
eclass, line=call, lineno=lineno + 1, pkg=pkg
355+
)
356+
357+
yield from self.check_provided_eclasses(pkg, inherits)
358+
yield from self.check_user_variables(pkg, inherits)
359+
# verify @PRE_INHERIT variable placement
360+
yield from self.check_pre_inherits(pkg, inherits)
361+
# verify @DEPRECATED variables or functions
362+
yield from self.check_deprecated_variables(pkg, inherits)
363+
yield from self.check_deprecated_functions(pkg, inherits)
364+
yield from self.check_exported_eclass_phase(pkg, inherits)
365+
366+
for eclass in pkg.inherit.intersection(self.deprecated_eclasses):
367+
replacement = self.deprecated_eclasses[eclass]
368+
if not isinstance(replacement, str):
369+
replacement = None
370+
yield DeprecatedEclass(eclass, replacement, pkg=pkg)
369371

370372

371373
class EclassVariableScope(VariableScope, results.EclassResult):

0 commit comments

Comments
 (0)