Parameter not referenced (LC0095)
CodeCop AA0137 detects unreferenced parameters only in local procedures and explicitly excludes event subscribers. LC0095 covers the gaps: internal procedures, public procedures, and event subscribers.
A parameter that is never referenced in the procedure body clutters the signature, misleads callers about what the procedure needs, and creates unnecessary coupling. Removing it simplifies both the definition and every call site.
Covered by this rule
- Internal procedures
- Public procedures
- Event subscribers
Excluded from this rule
- Local procedures (AA0137 handles them)
- 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)
Example
codeunit 50100 MyCodeunit
{
procedure MyProcedure(MyVariant: Variant) // Parameter 'MyVariant' is not used in procedure 'MyProcedure'. [LC0095]
begin
end;
}
Fixed:
codeunit 50100 MyCodeunit
{
procedure MyProcedure()
begin
end;
}
Event subscriber 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 used in procedure 'OnBeforePostSalesDoc'. [LC0095]
begin
IsHandled := true;
end;
}
Code fix
A quick fix removes the unreferenced parameter from the procedure signature. It does not update call sites. Callers that pass an argument for the removed parameter need manual adjustment.
Relationship to AA0137
| Scope | AA0137 | LC0095 |
|---|---|---|
| Local procedures | ✅ | ❌ (defers to AA0137) |
| Internal procedures | ❌ | ✅ |
| Public procedures | ❌ | ✅ |
| Event subscribers | ❌ | ✅ |
| Triggers | ❌ | ❌ |
| Interface implementations | ❌ | ❌ |
| Event declarations | ❌ | ❌ |
See also
- AA0137 - Do not declare variables that are unused
- LC0052 - Internal procedure not referenced
- LC0053 - Internal procedure only used in current object