Skip to content

VIEW018: fragile-component-reference

Script or binding navigates the component tree

Code VIEW018
Name fragile-component-reference
Category View structure (VIEW)
Default severity warning
Enabled by default no
Fix available no
ign-lint equivalent BadComponentReferenceRule

Reports scripts and bindings that reach other components by walking the component tree:

  • in scripts: calls of getSibling, getParent, getChild and getChildren, and self.parent / self.children;
  • in expression bindings, expression transforms, expression-structure bindings and property bindings: relative component paths ../Sibling... and ./Child....

Scripts are parsed with the Jython parser and expressions with the expression parser, so text in comments and string literals never counts, and ../ is not also reported as ./. One finding per script or binding lists every pattern it uses.

Such references break silently when components are renamed, moved or wrapped in a new container. View custom properties, view parameters and message handlers keep components decoupled. This is a style rule and is not in the default set.

self.getSibling('Total').props.text = str(value)

Use instead: bind Total.props.text to {view.custom.total} and write self.view.custom.total = value.

  • forbidden-patterns (default [".getSibling(", ".getParent(", ".getChild(", ".getChildren(", "self.parent.", "self.children.", "self.parent)", "self.children)", "self.parent,", "self.children,", "self.parent\n", "self.children\n", "self.parent\r", "self.children\r", "../", "./"]): the patterns to report, in ign-lint's notation: .getSibling(, .getParent(, .getChild(, .getChildren(, self.parent. (and the other self.parent forms), self.children. (and its other forms), ../ (paths going up) and ./ (paths relative to the component itself). Other strings are matched as plain text in the script or expression. An empty list means the default list (all of these).
  • case-sensitive (default true): when false, method and attribute names and text patterns match case-insensitively.

Equivalent of BadComponentReferenceRule (forbidden_patterns, case_sensitive) with the same messages in iglint ign-lint. ign-lint matches substrings: it also reports text in comments, strings and invalid expressions, and every ../ also counts as ./ (bug 18); iglint does not.

Set in [rules.VIEW018] of iglint.toml (or [tool.iglint.rules.VIEW018] in pyproject.toml).

Option Type Default Description
forbidden-patterns array of strings [".getSibling(", ".getParent(", ".getChild(", ".getChildren(", "self.parent.", "self.children.", "self.parent)", "self.children)", "self.parent,", "self.children,", "self.parent\n", "self.children\n", "self.parent\r", "self.children\r", "../", "./"] Patterns to report.
case-sensitive boolean true Match names case-sensitively.

ign-lint kwargs in a rule_config.json: forbidden_patterns -> forbidden-patterns, case_sensitive -> case-sensitive.


Generated from the rule metadata by iglint generate-docs; iglint rule VIEW018 prints the same page in the terminal. Source: docs/rules/VIEW018.md.