codefori / vscode-rpgle

RPGLE language tools for VS Code
MIT License
39 stars 20 forks source link

RPGLE Linting configurability #264

Closed sudhiraroraCVS closed 12 months ago

sudhiraroraCVS commented 1 year ago

Hi Team,

I work in CVS Health and was exploring Linting feature of RPGLE on VS Code for our discovery project on VS Code. Linting is a really good feature which is not available in RDI and we know RPGLINT.JSON file can some pre-defined linting parameters to enforce the rules but we want to use this feature to next level if there is way to add/configure our own rules for linting so that we can better use this feature of VS Code. Our Use case is : We have Dev code check list with a long list which our developers performs manual check on the code and we want to automate that. I know we can user Sonarqube scans which are available for RPGLE but that is too late in the game when code goes through CI pipeline. We want to enforce/configure our own rules during coding time so that we can force developers to fix the code early in the game.

We have huge list of Dev code checklist but below is 1 example from that list which we may want to add in RPG linting. So we want to understand if we have flexibility to add rules like below in RPG linter or we are just restricted to use pre-defined rules only. Please suggest. Check list item : Has SETLL and READE been used instead of CHAIN for performance.?

Thanks Sudhir.

priceaj commented 1 year ago

I believe the linting rules are harcoded but can be switched on or off with configuration.

I'm sure PRs would be accepted for new ones.

Out of interest is a SETLL and a READE genuinely faster than a keyed CHAIN?

I know it's faster to prove the existence of a record i.e. because you can use %FOUND on a SETLL without reading the fields into memory. However I wasn't aware of a performance difference otherwise.

How would you check this programmatically? Do you not allow any CHAIN operations in your programs at all?

priceaj commented 1 year ago

Linter requests can ba added as an issue here: https://github.com/codefori/vscode-rpgle

sudhiraroraCVS commented 1 year ago

Yeah that's for the same purpose you mentioned %Found with Setll instead of using CHAIN. I couldn't understand on your answer for new linting rules, it can be added ? what does PRs mean ?

priceaj commented 1 year ago

PR = Pull request i.e. you do the code in your own fork then submit to the main branch for review. Its not necessary, but obviously its the quickest way to get a feature into the plugin (assuming that it's accepted.)

Otherwise like I said if you have suggestions for Linting Rules you can submit them here : https://github.com/codefori/vscode-rpgle

You should submit each rule which you want individually

sudhiraroraCVS commented 1 year ago

Do we have a sample code for existing linting rules and where exactly it's coded currently ?

priceaj commented 1 year ago

Code is here: https://github.com/codefori/vscode-rpgle/blob/main/language/linter.ts

sudhiraroraCVS commented 1 year ago

2 questions :

  1. If we request new linting rules for RPG, they will be added as generic rule for everyone using VS Code for RPG development or there will be separate extension created just for our application to install and use the new rules.
  2. Below link which was provided to send suggestions for new linting rules, what information we need to provide on that link. Is there any specific steps we need to follow. Please share a reference if possible https://github.com/codefori/vscode-rpgle
sebjulliand commented 1 year ago

Hi @sudhiraroraCVS !

  1. Linting rule are built in the vscode-rpgle extension and are shared by every user of the extension. So yes, they are generic and for everyone. Since this is an open source project, your request may or may not be implemented - it all depends on the good will of those who contribute to this project 😄 Of course you can contribute yourself, that's the beauty of it. In case you need to have a separate extensioncreated just for you, you can always fork the vscode-rpgle repository and have your own version of the extension for your own use. But it will be up to you to add your rules and keep it in sync with the main repository.
  2. The best way to request a new rule would be to open an issue here, describing the rule. Providing a code sample and the expected result would be great. Here is an example of someone suggesting new options: https://github.com/codefori/vscode-rpgle/issues/257
sudhiraroraCVS commented 12 months ago

Thanks for the detailed response. There is a mention of creating our own extension and then we can add our rules. Can you share the steps to create our own extension or in case you have any reference then that would be great.

worksofliam commented 12 months ago

@sudhiraroraCVS See the guide here: https://code.visualstudio.com/api/get-started/your-first-extension

I am going to close this issue now. Thanks.