Linter
The information below is specific to the linter in the RPGLE extension.
Opening the linter config
Use vscode-rpgle.openLintConfig
to open the rules configuration for the source youβre working in.
Or you can right click on a library filter:
If a linter rules file does not exist, you will be asked asked if you want to create one. The created file will provide some default rules, as below.
Relative lint config
- If you are developing in source members (
LIB/QRPGLESRC/MYSOURCE.RPGLE
)- the the linter config exists in
LIB/VSCODE/RPGLINT.JSON
. - Each library has its own rules configuration file, binding it to all RPGLE sources in that library.
- config changes get pickup when RPGLE sources are re-opened.
- the the linter config exists in
- When developing in the IFS:
- linter rules config exist in
.vscode/rpglint.json
relative to the current working directory. - config changes get pickup when RPGLE sources are re-opened.
- linter rules config exist in
- When developing in a local workspace
- linter rules exist in
.vscode/rpglint.json
relative to the workspace. - Local RPGLE gets scanned automatically when config is changed
- linter rules exist in
Lint options
Below are some available lint configs. See the rpglint.json
schema for the most up to date rules .
Type | Rule | Value | Description |
---|---|---|---|
π | indent | number | Indent for RPGLE. |
π | BlankStructNamesCheck | boolean | Struct names cannot be blank (*N). |
π | QualifiedCheck | boolean | Struct names must be qualified (QUALIFIED). |
π | PrototypeCheck | boolean | Prototypes can only be defined with either EXT, EXTPGM or EXTPROC |
π | ForceOptionalParens | boolean | Expressions must be surrounded by brackets. |
π | NoOCCURS | boolean | OCCURS is not allowed. |
π€ | NoSELECTAll | boolean | βSELECT *β is not allowed in Embedded SQL. |
π | UselessOperationCheck | boolean | Redundant operation codes (EVAL, CALLP) not allowed. |
π | UppercaseConstants | boolean | Constants must be in uppercase. |
π | IncorrectVariableCase | boolean | Variable names must match the case of the definition. |
π | RequiresParameter | boolean | Parentheses must be used on a procedure call, even if it has no parameters. |
π | RequiresProcedureDescription | boolean | Procedure titles and descriptions must be provided. |
π | StringLiteralDupe | boolean | Duplicate string literals are not allowed. |
π | RequireBlankSpecial | boolean | *BLANK must be used over empty string literals. |
π | CopybookDirective | string | Force which directive which must be used to include other source. (COPY or INCLUDE ) |
π | DirectivesCase | string | Directives must be in the specified case. (lower or upper ) |
π | UppercaseDirectives | boolean | Deprecated use DirectivesCase instead. Directives must be in uppercase. |
π€ | NoSQLJoins | boolean | JOINs in Embedded SQL are not allowed. |
π | NoGlobalsInProcedures | boolean | Globals are not allowed in procedures. |
π | SpecificCasing | array | Specific casing for op codes, declartions or built-in functions codes. |
π | NoCTDATA | boolean | CTDATA is not allowed. |
π | PrettyComments | boolean | Comments cannot be blank, must start with a space and have correct indentation. |
π | NoGlobalSubroutines | boolean | Global subroutines are not allowed. |
π | NoLocalSubroutines | boolean | Subroutines in procedures are not allowed. |
π | NoUnreferenced | boolean | Unreferenced definitions are not allowed. |
π | NoExternalTo | string array | Calls to certain APIs are not allowed. (EXTPROC / EXTPGM) |
π | NoExecuteImmediate | boolean | Embedded SQL statement with EXECUTE IMMEDIATE not allowed. |
π | NoExtProgramVariable | boolean | Declaring a prototype with EXTPGM and EXTPROC using a procedure is now allowed. |
π€π | IncludeMustBeRelative | boolean | When using copy or include statements, path must be relative to the root. Usage is only recommended for local/workspace projects. |
π€ | SQLHostVarCheck | boolean | Warns when referencing variables in Embedded SQL that are also defined locally. |
π€ | RequireOtherBlock | boolean | Requires SELECT blocks to have an OTHER block. |
Type key
Key | Value |
---|---|
π | Clean code |
π€ | Safe code |
π | Secure code |
SpecificCasing
example
This rule allows you to specify the casing required for any or all declares or BIFs.
If you want all DCL
to be lower case and all BIF
s to be upper case, then it would be coded like this:
If you wanted %parms
and %timestamp
to always be lower case, and all other BIFs to be upper case, then it would be coded like this:
Or, if for some reason, you wanted %timestamp
to always be coded as %TimeStamp
then it could be coded like this: