Support Inheriting ALCops Configuration from Remote "alcops.json" Configurations #483
Replies: 3 comments 2 replies
|
I think this would be a useful addition for organizations maintaining multiple AL repositories. It allows common ALCops settings, such as naming patterns, complexity thresholds, and formatting preferences, to be maintained centrally while still allowing individual repositories to override specific values when needed. Actually, I'm a little annoyed that I didn't come up with the idea myself. :) The proposed configuration could use a dedicated {
"Extends": {
"Source": "https://example.com/company.alcops.json"
},
"SubscriberNamingPattern": "{Event Source}_{Event Name}[_{Element Name}]"
}
The effective configuration would be resolved as follows:
For the initial implementation, I would keep the scope deliberately limited:
These restrictions keep precedence rules, caching, error handling, and diagnostics predictable. Different centrally managed configurations can simply be maintained as separate files. There should be no fundamental limitation in The main operational consideration is network availability. The resolver should load the external configuration once per workspace path, use a short timeout, and fall back to the local configuration when the external source is unavailable or invalid. That keeps local development and CI builds functional even when the central configuration service cannot be reached. A more general question in this matter: Should ALCops report a configuration diagnostic whenever alcops.json or an external configuration cannot be read or parsed? Currently, parsing errors are handled silently: invalid JSON, unknown enum values, or incompatible value types cause ALCops to fall back to the built-in default settings. When an external source cannot be read, is unavailable, or is invalid, ALCops ignores it and uses the local configuration instead. |
|
I've set up Codex for the ALCops repositories and used it to create the following draft PRs:
As a disclaimer: |
|
Looks good. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Background
The AL Language extension already allows RuleSets to be centralized across multiple repositories by referencing external RuleSet files.
With
al.enableExternalRulesetsenabled, a local RuleSet can include one or more external RuleSets. This makes it possible to maintain rule severities centrally: if a rule should be promoted fromWarningtoError, for example, the change can be made once in the central RuleSet instead of updating every repository individually.Use case for ALCops
I recently came across a similar use case with ALCops, specifically with LC0098 – Event subscriber name does not match the configured template.
The event subscriber naming convention can be configured through
alcops.json, for example:{ "SubscriberNamingPattern": "{Event Source}_{Event Name}[_{Element Name}]" }However, if the same naming convention should apply to many repositories, the configuration currently needs to be added or changed separately in every repository.
For organizations maintaining a larger number of AL repositories, changing such a convention can therefore involve:
alcops.json,It would be useful if an
alcops.jsoncould inherit its configuration from a remotealcops.json, similar to external RuleSets in the AL Language extension.For example:
{ "InheritFromRemoteConfiguration": "https://example.com/alcops.config.json", "SubscriberNamingPattern": "{Event Source}_{Event Name}[_{Element Name}]" }Configuration precedence
My suggestion would be to treat the remote configuration as a base configuration and the local
alcops.jsonas an override.For example, if the remote configuration contains:
{ "CognitiveComplexityThreshold": 15, "SubscriberNamingPattern": "{Event Source}_{Event Name}" }and the repository contains:
{ "InheritFromRemoteConfiguration": "https://example.com/alcops.config.json", "SubscriberNamingPattern": "{Event Source}_{Event Name}[_{Element Name}]" }the effective configuration would be:
{ "CognitiveComplexityThreshold": 15, "SubscriberNamingPattern": "{Event Source}_{Event Name}[_{Element Name}]" }In other words:
This would still allow repositories to deviate from the centralized configuration where necessary.
Multiple inherited configurations?
I'm not sure whether supporting multiple inherited configurations would provide enough additional value to justify the extra complexity.
Something similar to the AL Language extension could theoretically be supported:
{ "InheritFromRemoteConfiguration": [ "https://example.com/company.alcops.json", "https://example.com/team.alcops.json" ] }However, this would require defining clear precedence rules if the same setting is specified by multiple configurations, e.g. whether the first or last configuration wins.
For the initial implementation, supporting a single inherited configuration might therefore be sufficient and would keep the behavior straightforward.
Benefits
The main benefit would be centralized ALCops configuration across many repositories.
Changes to naming conventions, complexity thresholds, formatting preferences, or future ALCops configuration options could be rolled out centrally without having to modify every repository individually.
Repositories could still override individual settings when necessary, while common defaults remain maintained in one place.
What do you think about that?
... and can there be technical limitations regarding alc.exe?
All reactions