BusinessCentral.LinterCop
BusinessCentral.LinterCop copied to clipboard
LC0010 does not work in code-workspaces
The LC0010 documentation states the Lintercop.json needs to be part of the 'project' root. When opening the project roots folder, the LC0010 is calculated correctly.
However, when opening a code-workspace file (all our apps have a workspace with an alpackages shortcut, App folder and Test folder), the LC0010 does no longer respect the settings from the individual app / project folders.
Just tried to reproduce, and it works for me. I can even have individual LinterCop.json files for each workspace folder
Did you reload the window after you changed the json file?
I did reload and it did not work at first. Then I opened the project root folder instead. Reopened the workspace again and it did work.
WIll keep an eye on it and re-open if needed / if I can better simulate an off-scenario.
Thx!
Hey Stefan.
Please find below a setup of our workspaces.
The code-workspace contains various folders:
"folders": [
{
"path": "../.alpackages"
},
{
"path": "../Dynavision Core/App",
"name": "ESCA - Core"
},
{
"path": "App",
"name": "ESCN - Purchasing and Procurement Center"
},
{
"path": "Test",
"name": "ESCN - Purchasing and Procurement Center (Test)"
}
],
... of which only one (the /App
folder) contains a LinterCop.json
file
{ "cyclomaticComplexetyThreshold": 25, "maintainablityIndexThreshold": 20, "enableRule0011ForTableFields": false }
Still files under the /App
folder result in LC0010 warnings, where they should not, since the cyclomaticComplexetyThreshold
has been increased to 25 for these files.
Hi. I also have this problem.
Code for repro: https://github.com/ernestasjuska/BcLinterCop225.
Workspace contains two folders MainApp and workspace root ("."). MainApp does not have any dependencies so you can compile it without downloading any symbols. Codeunit C has long function used to trigger LC0010. I also added LinterCop.json that is supposed to kill all LC0010 warnings (in practice I will use different values).
If I run AL: Package on MainApp I get:
c:\Users\ernjus\Desktop\Multi-LinterCop225\MainApp\C.Codeunit.al(1,16): warning LC0015: The application object Codeunit "MY C" is not covered by any permission set in the extension.
Which I expected - no warning about cyclomatic complexity so LinterCop.json is actually considered.
If I then uncomment workspace folder WrapperApp (which does not exist but should not matter) and then run AL: Package on MainApp I get:
c:\Users\ernjus\Desktop\Multi-LinterCop225\MainApp\C.Codeunit.al(1,16): warning LC0015: The application object Codeunit "MY C" is not covered by any permission set in the extension.
c:\Users\ernjus\Desktop\Multi-LinterCop225\MainApp\C.Codeunit.al(3,24): warning LC0010: Cyclomatic complexity: 16, Maintainability index: 44
Which is unexpected - there is a warning about cyclomatic complexity so clearly LinterCop.json was not considered.
And if I create WrapperApp folder and put same LinterCop.json file inside. It also does not consider it, but if I restart extension host then it is considered.
WrapperApp is the first folder in the workspace so my guess is that LinterCop does not read LinterCop.json from the app folder. Rather it reads it from the first workspace root folder and there is also some caching "magic". So I moved that WrapperApp to be after MainApp and now LinterCop.json is considered regardless WrapperApp folder is added to workspace or not.
This code is very fishy: :) https://github.com/StefanMaron/BusinessCentral.LinterCop/blob/adc08461678a732af720e1498a1b87608f583435/Helpers/LinterSettings.cs#L20 There is assumption about current process working directory matching MainApp folder. I think it is better to be explicit here.
Thanks.
CC: @StefanMaron
If I'm not mistaken @StefanMaron has resolved this in v0.29.6..
@fvet and/or @ernestasjuska Could you confirm this?
@Arthurvdv I'm currently not using LC0010 pro-actively, however I just tested the reported scenario again in my workspace and can confirm that all works, so I'll be closing the issue ;)