SCR206: legacy-script-prefix
project., shared. or app. prefix that does not exist in 8.3
| Code | SCR206 |
| Name | legacy-script-prefix |
| Category | Scripts (SCR) |
| Default severity | error |
| Enabled by default | yes |
| Fix available | sometimes |
| Fix safety | unsafe |
| ign-lint equivalent | none |
What it does
Section titled “What it does”Reports project.x, shared.x and app.x where project, shared or
app is not defined anywhere the script can see. These were the script
library prefixes of Ignition 7 (app. the even older application
scripts). In 8.3 every top-level package of the project library is a
global of its own, and the prefixes are not defined: verified on an 8.3
gateway, project.x and shared.x raise NameError.
Nothing is reported when the name is bound (a variable, parameter, import
or a library package actually called project), when the script's
library is not fully known (a parent project outside the linted tree, tag
scripts of gateway resources), or inside a try that catches
NameError.
Why is this bad?
Section titled “Why is this bad?”The script raises NameError when it reaches the reference. Code
migrated from Ignition 7 often still carries these prefixes in places
that rarely run, such as error handlers.
Example
Section titled “Example”def runAction(self, event): project.util.refresh(self)Use instead:
def runAction(self, event): util.refresh(self)Removes the prefix when the name after it is a top-level package or
module of the project's library (with inheritance) and the script does
not bind that name itself. Unsafe: in Ignition 7, shared.x and
project.x were different libraries, so x in the 8.3 project may not be
the code the prefix meant.
Generated from the rule metadata by iglint generate-docs; iglint rule SCR206 prints the same page in the terminal. Source: docs/rules/SCR206.md.