BusinessCentral.LinterCop
BusinessCentral.LinterCop copied to clipboard
LC0084 Maybe exclude setup tables?
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?
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.
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...
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?