Event subscriber parameter is not referenced
CodeCop AA0137 explicitly excludes event subscribers, and LC0095 covers non-local non-subscriber procedures. LC0099 fills the remaining subscriber-specific gap and reports unreferenced event subscriber parameters.
Event subscribers are often scaffolded with all event parameters, but implementations frequently need only a subset. Keeping only the parameters you actually use makes intent clearer and can reduce unnecessary data flow through subscriber signatures.
Example
codeunit 50100 MyCodeunit
{
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Sales-Post", OnBeforePostSalesDoc, '', false, false)]
local procedure OnBeforePostSalesDoc(var SalesHeader: Record "Sales Header"; var IsHandled: Boolean) // Parameter 'SalesHeader' is not referenced in event subscriber 'OnBeforePostSalesDoc'. [LC0099]
begin
IsHandled := true;
end;
}Fixed:
codeunit 50100 MyCodeunit
{
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Sales-Post", OnBeforePostSalesDoc, '', false, false)]
local procedure OnBeforePostSalesDoc(var IsHandled: Boolean)
begin
IsHandled := true;
end;
}Covered by this rule
- Event subscribers
Excluded from this rule
- Local procedures (AA0137 handles them)
- Internal procedures (covered by LC0095 )
- Public procedures (covered by LC0095 )
- Triggers (platform-defined signatures, cannot be changed)
- Interface implementations (bound by interface contract)
- Event declarations (
[IntegrationEvent]/[BusinessEvent], parameters define the subscriber contract) - Obsolete procedures (pending or removed, not worth modifying)
Severity rationale
LC0099 is reported as Info. Many teams keep generated subscriber signatures as-is, while others prefer trimming to used parameters only. Info severity provides guidance without forcing warning-level enforcement.
Fix behavior
The code action removes the unreferenced parameter from the subscriber signature.
Fix All is supported and scoped to event subscribers via the rule-specific equivalence key, so batch fixes do not affect non-subscriber procedures.
See also
- AA0137 - Do not declare variables that are unused
- LC0095 - Parameter is not referenced