RPGLE Linting and Content Assist with VS Code for IBM i

vscode-rpgle extensionA 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 lint options for:

  • Indentation, which is detected automatically by VS Code
  • Requiring brackets around IFWHEN, etc. operations
  • Making sure variable references match the way they are defined
  • So much more!

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:

  1. Install RPGLE language tools from the Marketplace
  2. Open the VS Code settings (Control / Command + Comma)
  3. Search for vscode-rpgle and enable Linter Support
  4. Connect to your IBM i using Code for IBM i
  5. Right click on a library filter and select ‘Open RPGLE lint configuration’
image

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!

image
Do you have ideas for other enhancements to VS Code for IBM i? Tell me about them!

2 replies
  1. David Knittle
    David Knittle says:

    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!

    Reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.