Browse pages
LS5008: Declared Event Is Raised by No Marked Act
LS5008 is a compiler check that reports a use case listing an event in raises that no method marked with it raises, because a listed event no method raises is a promise the code does not keep. This page states what the rule reports, where the error sits, and how to raise or unlist the event.
Reference#
What the Rule Enforces#
LS5008 enforces Raise the Declared Events from the Marked Act (litespec/backend/domain#raise-the-declared-events-from-the-marked-act). It runs in Domain only. Its category is LiteSpec.Traceability.
What the Rule Reports#
The rule reports a use case listing an event in raises that no root method marked with the use case raises. use-case/spending.submit-expense lists event/expense.submitted in raises. The diagnostic sits on each root method marked with the use case.
Failing Example#
/// <implements>use-case/spending.submit-expense</implements>
public void Submit()
{
State = new ExpenseSubmittedState();
}Passing Example#
/// <implements>use-case/spending.submit-expense</implements>
public void Submit()
{
State = new ExpenseSubmittedState();
RaiseDomainEvent(new ExpenseSubmittedEvent(Id));
}How to Fix#
Raise the listed event from a method marked with the use case, or remove it from raises.
Notes#
What the Rule Ignores#
The rule does not report a use case listing no event in raises. It does not report a use case whose every listed event a marked method raises. The rule stays silent when no .litespec/project.json is in reach, or when the docs root it names cannot be resolved; the CLI owns that configuration error. It does not run outside Domain.
Severity#
The rule reports an error. A finding that a live exception covers stays silent. An .editorconfig entry for the rule id overrides the computed severity.