CachéQuality for VSCode now available
Hope most of you already familiar with project CachéQuality from @Daniel Tamajon. For those who don’t know about it, it is a static syntax analyzer for your code written for InterSystems products. It may help you to find and solve many different types of issues in your code, and even possible bugs before clients will find it in production. So, with help of CachéQuality you will be able to deliver a better product. You can find the complete list of rules used to check ObjectScript code here.
It was already available in Studio. And now it is also available in VSCode.
Installation
In Extension section of VSCode Search for cachequality and install SonarLint for CachéQuality. Make sure you installed VSCode for ObjectScript first to get a better experience. Note, you can find both extensions by searching for objectscript.
So, right after installing this extension you will be able to use without any configuration, and after opening any class, it will underline all found issues.
And you can hover underlined lines, to see some details.
You can also open details for the problem right in the VSCode.
VSCode has problems view, which can be activated by Cmd+Shift+M hotkey, and this view used to show a list of problems found in your opened source files. And you can find there a list of problems found by CacheQuality and go to the exact place.
Fixed lines will be rechecked after save
There are some limitations though. You aren't able to control the list of rules and some other parameters related to those rules. Extension delivered as preconfigured with default values. If you need more control you can use connected mode.
Connected mode
This extension also has such mode named as connected. In this mode, you can connect to your SonarQube server with installed CacheQuality plugin.
With SonarQube you can customize the list of rules. Disable or activate, and change the rule's parameters. For example, rule `To method has too many lines` by default triggered after 50 lines, and you will be able to change this number, and so on.
When you have SonarQube Server, you have to first analyze the whole of your project. There are different ways how to do do it, you can find details in the SonarQube documentation. And you need a token to get the access to your project from VSCode.
Change VSCode settings
"sonarlint.connectedMode.project": { "projectKey": "Samples", "serverId": "local" }, "sonarlint.connectedMode.servers": [ { "serverId": "local", "serverUrl": "http://localhost:9000", "token": "65b19eb2ef04cd81a033c89820acf65d1f349c4f" } ]
Keep in mind that projectKey
should be equal with defined on SonarQube, serverId from the list of the list defined in servers section.
After saving settings and after any changes on SonarQube side, you should update the binding, to make sure your VSCode side is up to date.
If the settings were updated correctly you’ll see the following notification:
If you would like to customize the list of used rules for your project, first you have to copy the built-in quality profile Caché Quality.
And activate the new profile to the project.
You may resolve some found issues in SonarQube, and VSCode extensions will see it and will not show it again.
For example, we have such problems.
Let's resolve the issue with the never invoked method as False Positive, and we a not going to fix the issue with the variable.
After reopening file, it will be reanalyzed with new information. And method %OnNew does not have unresolved issues anymore.
Issues and feedback
CacheQuality project itself is not open source, but the extension for VSCode is open. And you can fill any issues and feedback there.