Variable not found
objectscriptQuality release
Id
OS0079
Rule type
Bug
Severity
Critical
Critical
SQALE characteristic
- Reliability
- Data
Remediation function
Constant/issue
Remediation cost
2h
A variable is used in a expression, but was neither passed as argument nor set before.
Declare or define as argument the variable you need to use, or remove the reference to the undefined variable.
Non-compliant code
Following code will compile, but on runtime the Add method will fail with "UNDEFINED error" message.
Method Add()
{
Set a=1
Set c=a+b // b is UNDEFINED
Write !,c
}
Compliant code
Method Add(b AS %Numeric)
{
Set a=1
Set c=a+b
Write !,c
}
Exceptions
Methods with ProcedureBlock=0 are not checked because those methods can use variables from global scope.
Parameters
| Name | Description | Default value |
|---|---|---|
bestPractice
| When activated, variables must be always explicitly declared and initialized
| false
|

