BusinessCentral.LinterCop icon indicating copy to clipboard operation
BusinessCentral.LinterCop copied to clipboard

LC0084 Maybe exclude setup tables?

Open Dennis-van-Es opened this issue 10 months ago • 2 comments

When we activated this rule we got 4K notifications. Most because of tables like Sales Setup, Purchase Setup, Company Info. Tables that we know are there. So maybe this rule can be modified to only apply when there are parameters specified?

Dennis-van-Es avatar Jan 14 '25 10:01 Dennis-van-Es

Thank you for the suggestion! This is the initial version of the rule, and refining it to reduce unnecessary diagnostics would definitely be great.

For setup tables like Sales Setup, Purchase Setup, and Company Information, the likelihood of these being missing is extremely low, so it makes sense to not have the diagnostics triggering for them.

However, the rule can be especially useful for setup tables introduced by other extensions (e.g., VAR or PTE). In such cases, it's not uncommon for the setup record to be missing. Without proper handling, the warning might appear as: The My App Setup does not exist. Identification fields and values: Primary Key=''.

For users, this can be confusing and difficult to interpret. The intent of the rule is to help developers proactively handle scenarios where a setup record might not exist, ensuring clearer behavior in the code.

Currently, the rule also applies to base app setup tables, where I could use idea's on how the rule can be adapt to reduce possible unnecessary diagnostics.

Arthurvdv avatar Jan 17 '25 08:01 Arthurvdv

In my opinion My App Setup should be present, just like Sales Setup. When the app is installed, updated, or a new company is created, the setup should be there. So, (again) in my opinion) when a .Get() is found in the code, without parameters, and the primary key is a code[10] field, it would be ok to not raise a warning or error. I'd prefer not to have to handle a missing setup table every time I need to use it.

EDIT: Maybe it is possible to create a rule that checks if setup tables are created during installation or upgrading an app, and when creating a new company...

Dennis-van-Es avatar Jan 20 '25 09:01 Dennis-van-Es

Could this perhaps be an array of table IDs in the LinterCop.json file, where a user adds tables to prevent the warning from being displayed?

nickgoddard777 avatar Mar 19 '25 22:03 nickgoddard777