RPGLE Linting and Content Assist with VS Code for IBM i
A great IDE contains features that increase your coding speed and accuracy so you can focus on your program’s logic. One of my favorite productivity enhancers, content assist, has been bundled in Visual Studio Code for IBM i since its inception. Content assist gives you autocomplete options for code as you write it, reducing syntax errors.
Today we’re announcing a new killer productivity tool for Code for IBM i—a built-in linter!
A linter is a static code analysis tool used to flag programming errors, bugs, stylistic errors and suspicious constructs. It’s like a giant lint roller, but one that captures sloppy code rather than cat hairs. Some linters already existed for RPGLE, like rpglelint, which was a big inspiration for this extension feature.
Our linter has many lint options, including:
- Indentation, which is detected automatically by VS Code
- Requiring brackets around
IF
,WHEN
, etc. operations - Ensuring that variable references match the way they are defined
For more RPG linter options, refer to the documentation for popular RPG linter options and the full list of linter options.
The new RPGLE Language Tools extension
With the addition of linting to content assist and other Code for IBM i language tools, we decided to move all the VS Code for IBM i language tools into an optional extension with its own code base. This made sense for many reasons, including the size of the code base required to parse RPGLE source.
So, as of just a few days ago, you can now download the new RPGLE language tools extension (codename vscode-rpgle) from the Visual Studio Code Marketplace. The extension adds a magnitude of functionality for writing free-format RPGLE, such as:
- Content assist
- Outline view
- Fixed format column assist
- and now . . . linting!
Getting started with RPGLE linting
The RPGLE language tools extension depends on Code for IBM i to access source code from /copy
and /include
statements, so make sure you have already installed Code for IBM i. From there:
- Install RPGLE language tools from the Marketplace
- Open the VS Code settings (Control / Command + Comma)
- Search for
vscode-rpgle
and enable Linter Support - Connect to your IBM i using Code for IBM i
- Right click on a library filter and select ‘Open RPGLE lint configuration’
If the lint configuration doesn’t exist, it will prompt you to create one. This feature will create a source file called vscode
in the chosen library, and rpglint.json
inside of that source file. It will be created with some default options turned on. This is not an opinionated linter, but we default with the most useful ones enabled.
From there, you can open any **FREE
RPGLE source code and expect the linter to do the job!
Do you have ideas for other enhancements to VS Code for IBM i? Tell me about them!
- Code for IBM i: https://github.com/halcyon-tech/vscode-ibmi
- RPGLE language tools: https://github.com/halcyon-tech/vscode-rpgle
For additional information on Code for i, see Visual Studio Code for IBM i: A Resource Guide.
buenas tardes… no me esta funcionando el Linter para Rpg lo configuro pero no me muestra los errores o cambios en el código
Is there a full list of Linter options and what they do?
Kevin, yes, most Linter options are listed here: https://codefori.github.io/docs/#/pages/extensions/rpgle/linter?id=lint-options
And for the always updated list, check here: https://github.com/codefori/vscode-rpgle/blob/main/schemas/rpglint.json
The link at “So much more!” is broken – it gives a 404.
Thanks, Jon! Link has been corrected.
The VSCODE file gets created and the member within, but the member is empty. Does not seem to be a security issue. i can update the member outside of VSCODE. I am looking forward to trying the linter!
HI, David, please document your issue at https://github.com/halcyon-tech/vscode-ibmi/issues and Liam can take a look. Include a screen shot if you can, to make it clear what’s happening.