Tweet |
Introduction
As I've written about in recent posts, I'm using the Salesforce CLI Scanner to perform static code analysis on a number of my projects. As it's clearly part of my day to day use of the Salesforce CLI, I decided to add it to my CLI GUI.
TL;DR, pull the latest code from the Github repository, or clone it and follow the instructions to carry out the initial setup. When it starts up you'll have the Scanner command group.
Commands
I added the scanner as a new command group, with a couple of commands - listing the rules and running the scanner.
Listing Rules
Listing the rules is fairly straightforward as I used existing parameter types to capture the categories and language, should the user wish to provide them:
and only needed to include a function to process the return JSON to extract
the rule details and dump them to the log panel:
Running the Scanner
Running the scanner was a little more complex. First, I usually want to pick
the categories but I don't want to have to remember the exact names, so I
needed a mechanism to allow me to select from list of options. I've got a good
start for this around allowing the user to choose which log file to retrieve
from the Debugging command group. Under the hood I run the scanner:rule:list
command, process the output to extract the unique category names, then build a
select element using the categories as options. As I can choose multiple
options I set the multiple attribute and give it a size of 7. I don't
always want to choose though, so I didn't want to have to wait every time for
the command to run, so I gave myself a button to click:
I also typically want to open the file that the output is sent to, so I added
this capability too:
No comments:
Post a Comment