1use super::{RuleId, Severity};
15
16#[derive(Debug, Clone, Copy, PartialEq, Eq)]
18pub struct Rule {
19 pub id: RuleId,
21 pub severity: Severity,
23 pub summary: &'static str,
25 pub source: &'static str,
27 pub needs_context: bool,
29}
30
31macro_rules! rules {
32 ($(
33 $konst:ident = $id:literal, $severity:ident, $context:literal, $summary:literal, $source:literal;
34 )*) => {
35 $(
36 #[doc = $summary]
37 #[doc = $source]
39 pub const $konst: RuleId = RuleId($id);
40 )*
41
42 pub static RULES: &[Rule] = &[$(
44 Rule {
45 id: RuleId($id),
46 severity: Severity::$severity,
47 summary: $summary,
48 source: $source,
49 needs_context: $context,
50 },
51 )*];
52 };
53}
54
55rules![
56 DUPLICATE_ID = "S2-ID-001", Error, false,
58 "Identifiers must be unique within the scope the standard names",
59 "`S2J`: \"Must be unique in the scope of the Resource Manager, for at least the duration of the session\", and per actuator for FRBC and DDBC operation modes.";
60 NON_FINITE = "S2-NUM-001", Error, false,
61 "Every number must be finite",
62 "JSON has no spelling for NaN or infinity, so a non-finite value cannot be sent at all.";
63 RANGE_ORDER = "S2-NUM-002", Error, false,
64 "A range's start must not be after its end",
65 "`S2J schemas/PEBC.AllowedLimitRange.range_boundary`: \"The start of the range shall be smaller or equal than the end of the range.\"";
66 RANGE_STRICT_ORDER = "S2-NUM-003", Error, false,
67 "A fill-level band's start must be strictly below its end",
68 "`S2J schemas/FRBC.OperationModeElement.fill_level_range`: \"The start of the NumberRange shall be smaller than the end of the NumberRange.\"";
69 FACTOR_RANGE = "S2-NUM-004", Error, false,
70 "An operation-mode factor must be within [0, 1]",
71 "`S2J`: \"The factor should be greater than or equal to 0 and less or equal to 1.\"";
72
73 ARRAY_BOUNDS = "S2-MSG-001", Error, false,
75 "An array must respect the schema's minItems and maxItems",
76 "Generated from `schema/s2-json`; the bounds are the schema's own.";
77 DUPLICATE_MESSAGE_ID = "S2-MSG-002", Warning, true,
78 "A message_id should not repeat within a session",
79 "Implied rather than stated: nothing in S2 JSON requires uniqueness, but a repeated id makes reception statuses ambiguous. A warning for that reason.";
80 TIMESTAMP_SKEW = "S2-MSG-003", Warning, true,
81 "A timestamp is further from the local clock than its meaning allows",
82 "No rule in the standard; a peer whose clock is wrong by hours will plan against the wrong quarter hour. Two thresholds, because S2 timestamps mean two things: one that says when something *happened* (`measurement_timestamp`, `transition_timestamp`, `InstructionStatusUpdate.timestamp`) must not be in the future by more than the configured skew tolerance, while one that says when something *will* happen (`valid_from`, `start_time`, `execution_time`) is expected to be in the future and is only remarked on beyond a year. Never an error: two conforming implementations with different clocks must still be able to talk, and nothing is ever reported for a timestamp in the past, which the standard says means \"already\".";
83
84
85 DECODE_FAILED = "S2-MSG-004", Error, false,
93 "The frame could not be decoded into an S2 message",
94 "`S2J schemas/ReceptionStatusValues`: INVALID_DATA is \"Message not understood (e.g. not valid JSON, no message_id found)\" and INVALID_MESSAGE is \"Message was not according to schema\". Which of the two is chosen is `DecodeError::status_value`; this identifier is what carries it into the diagnostic label.";
95 UNKNOWN_PROPERTY = "S2-MSG-005", Warning, false,
96 "A property the schema does not define was removed before decoding",
97 "`S2J` sets `additionalProperties: false` on every object, so a strict endpoint refuses such a message outright. A proxy reading in `Strictness::Lenient` forwards it instead and says what it dropped — a warning, because the proxy is not the party entitled to refuse.";
98 APPLICATION_REFUSED = "S2-MSG-006", Error, false,
99 "The receiving application refused the message through its inbound policy",
100 "`S2J schemas/ReceptionStatusValues`: TEMPORARY_ERROR is \"Receiver encountered an error ... try to send the message again\" and PERMANENT_ERROR \"an error which it cannot recover from\". Neither is a judgement about the message, so no other rule can express it; it is the one status a `Validate` implementation could never choose.";
101
102 ROLE_REQUIRED_FIELD = "S2-MSG-007", Error, false,
103 "A field that is optional in general is mandatory for this sender's role",
104 "`S2J messages/Handshake.supported_protocol_versions`: \"This field is mandatory for the RM, but optional for the CEM.\" The schema cannot express a requirement that depends on another field's value, so it lists the property as optional and says the rest in prose.";
105
106 PROFILE_FIELD = "S2-MSG-008", Error, true,
107 "A field must be present exactly when the negotiated wire profile defines it",
108 "`S2C §Versioning of JSON Schema files`: the negotiated version selects which schema the messages are read against, and the two tagged versions of S2 JSON differ in one field — `DDBC.SystemDescription.present_demand_rate` is required in `v0.0.2-beta` and was removed in `v1.0.0`, where `DDBC.PresentDemandStatus` carries it instead (erratum E13). The decoder already refuses the wrong shape on the way in; this is the same rule applied on the way *out*, so an endpoint learns at the call site rather than from the peer's `INVALID_MESSAGE`.";
109
110 ONE_VALUE_PER_QUANTITY = "S2-PM-001", Error, false,
112 "At most one value per CommodityQuantity",
113 "`S2J messages/PowerMeasurement.values`: \"at most one item per 'commodity_quantity'\", and the same for every PowerRange and PowerForecastValue array.";
114 PHASE_EXCLUSIVITY = "S2-PM-002", Warning, false,
115 "Per-phase and three-phase-symmetric quantities should not be mixed",
116 "Undocumented; `[s2-json #25]` asks for the exclusivity to be written down (erratum E12). A warning until it is.";
117 PERCENTILE_ORDER = "S2-PM-003", Warning, false,
118 "Confidence bands should be ordered from the lower limit to the upper",
119 "Inferred from the percentile semantics: a 68 % band lies inside a 95 % band. Not stated, so a warning.";
120 MEASUREMENT_NOT_OFFERED = "S2-PM-004", Error, true,
121 "A measurement may only use a quantity the resource said it provides",
122 "`S2J messages/ResourceManagerDetails.provides_power_measurement_types`: \"Array of all CommodityQuantities that this Resource Manager can provide measurements for.\"";
123 FORECAST_NOT_OFFERED = "S2-PM-005", Error, true,
124 "A forecast may only be sent by a resource that said it provides forecasts",
125 "`S2J messages/ResourceManagerDetails.provides_forecast`: \"Indicates whether the ResourceManager is able to provide PowerForecasts.\"";
126
127 CONTROL_TYPE_NOT_OFFERED = "S2-RMD-001", Error, true,
129 "The CEM may only select a control type the resource offers",
130 "`S2J messages/SelectControlType.control_type`: \"Must be one of the available ControlTypes as defined in the ResourceManagerDetails.\"";
131 CURRENCY_REQUIRED = "S2-RMD-002", Warning, true,
132 "A resource that publishes costs should declare a currency",
133 "`S2J messages/ResourceManagerDetails.currency`: \"Mandatory if cost information is published.\" Not stated is what counts as publishing it: the standard\'s own heat-pump walkthrough sends running_costs and transition_costs of zero while saying \"This heat pump does not define any costs related parameters, so no currency needs to be provided\" (erratum E17). Refusing that example would make this crate stricter than the documentation it implements, so it is a warning.";
134 DUPLICATE_ROLE = "S2-RMD-003", Warning, false,
135 "A resource should declare each role once per commodity",
136 "`S2J messages/ResourceManagerDetails.roles` is \"one or more energy Roles\" bounded at `maxItems: 3` \u{2014} exactly the number of `RoleType` values, while `Commodity` has four. A cap of three cannot be counting commodities, so it is counting role types, and a battery that is storage, load *and* generator for electricity is saying so in the only way the schema allows (erratum E30). What this rule reports is therefore the narrow case the schema still cannot express: the same `(role, commodity)` pair twice, which carries no information either way. A warning rather than an error, for the same reason as `S2-ACT-002` \u{2014} the schema does not say the items are distinct.";
137 NO_SELECTION_OFFERED = "S2-RMD-004", Warning, false,
138 "NO_SELECTION is not something a resource can offer",
139 "`S2J schemas/ControlType`: NO_SELECTION is \"to be used if no control type is or has been selected\" — a state, not a capability.";
140
141 NOT_ALLOWED_IN_STATE = "S2-STATE-001", Error, true,
143 "The message is not allowed in the session's current state",
144 "`S2C §State of communication`, the normative table of what may be sent when.";
145 NOT_ALLOWED_FOR_ROLE = "S2-STATE-002", Error, true,
146 "The message is not allowed from this role",
147 "`S2C §State of communication`: the table has a column per role.";
148 HANDSHAKE_UNDER_CONNECT = "S2-STATE-003", Warning, true,
149 "Handshake messages are redundant under S2 Connect",
150 "`S2C §Communication - JSON messages`: \"the Handshake and HandshakeResponse messages can not be sent. They are redundant by the pairing and session initiation process.\"";
151
152 COMMODITY_WITHOUT_POWER_RANGE = "S2-ACT-001", Warning, false,
156 "Every operation mode should publish a power range for each commodity the actuator supports",
157 "The schema does not require it, but `s2-python` — the reference implementation — refuses an FRBC.ActuatorDescription whose operation mode elements do not cover every entry of `supported_commodities`, so a message without them will not reach a peer built on it. A warning rather than an error because this crate refuses only what the standard refuses; the point of the rule is that the gap is worth seeing before a field trial finds it.";
158 DUPLICATE_SUPPORTED_COMMODITY = "S2-ACT-002", Warning, false,
159 "An actuator should list each supported commodity once",
160 "The schema bounds the array at four but does not say the items are distinct. `s2-python` rejects a repeat; a duplicate carries no information either way, so this crate reports rather than refuses.";
161
162 PREVIOUS_MODE_MISSING = "S2-STATUS-001", Warning, true,
164 "A status after the first for the same actuator should name the previous mode",
165 "`S2J messages/FRBC.ActuatorStatus.previous_operation_mode_id`: \"This value shall always be provided, unless the active FRBC.OperationMode is the first FRBC.OperationMode the Resource Manager is aware of.\" OMBC.Status and DDBC.ActuatorStatus carry the same field with the same sentence, so this is one rule rather than three — and \"the first the Resource Manager is aware of\" is per actuator, not per session.";
166 UNKNOWN_TIMER = "S2-STATUS-002", Error, true,
167 "A timer status must name a timer the description declares",
168 "`S2J schemas/Timer.id`: an identifier is \"unique in the scope of the OMBC.SystemDescription, FRBC.ActuatorDescription or DDBC.ActuatorDescription in which it is used\", so a `*.TimerStatus` naming a timer no description declares refers to nothing. Its own identifier rather than the transition rule's, because a `diagnostic_label` is worth having only if one identifier means one condition (D28) — and \"this transition points at a timer that does not exist\" and \"you are reporting on a timer that does not exist\" are two conditions an operator counts separately.";
169
170 DUPLICATE_INSTRUCTION_ID = "S2-INST-001", Error, true,
172 "An instruction identifier must not be reused within a session",
173 "`S2J`: \"Must be unique in the scope of the Resource Manager, for at least the duration of the session between Resource Manager and CEM.\"";
174 UNKNOWN_INSTRUCTION = "S2-INST-002", Error, true,
175 "An InstructionStatusUpdate must name an instruction that was sent",
176 "`S2J messages/InstructionStatusUpdate.instruction_id`: \"ID of this instruction (as provided by the CEM)\".";
177 STATUS_REGRESSION = "S2-INST-003", Warning, true,
178 "An instruction's status should not move backwards",
179 "The order statuses may take is undocumented (`[s2-json #26]`, erratum E11), so going from SUCCEEDED back to STARTED is a warning rather than an error.";
180 ABNORMAL_ONLY = "S2-INST-004", Error, true,
181 "An abnormal-condition-only mode, transition or range needs abnormal_condition",
182 "`S2J`: \"Indicates if this ... may only be used during an abnormal condition.\"";
183 BLOCKED_BY_TIMER = "S2-INST-005", Warning, true,
184 "The instructed transition is blocked by a timer that has not finished",
185 "`S2J schemas/Transition.blocking_timers`: \"List of IDs of Timers that block this Transition from initiating while at least one of these Timers is not yet finished.\" A warning because the CEM's view of a timer is always slightly stale.";
186 NO_SUCH_TRANSITION = "S2-INST-006", Warning, true,
187 "No transition is described from the active operation mode to the instructed one",
188 "the S2 documentation, *Operation modes*: \"a RM can activate another Operation Mode without the CEM requesting it, and it is even allowed to activate an Operation Mode even if there is no transition\" — so this is advice, not a refusal.";
189
190 REVOKE_ROLE_MISMATCH = "S2-REV-001", Warning, true,
192 "The revoked object type is not one this sender owns",
193 "`S2C §State of communication` lists RevokeObject only for the RM, while `S2J schemas/RevokableObjects` contains every instruction type, which only a CEM sends (erratum E6).";
194 REVOKE_UNKNOWN = "S2-REV-002", Warning, true,
195 "The revoked object was never published on this session",
196 "Not stated. Revoking something the peer never saw is harmless but almost always a bug.";
197
198 FRBC_ELEMENTS_CONTIGUOUS = "S2-FRBC-001", Error, false,
200 "An operation mode's fill-level bands must be contiguous",
201 "`S2J schemas/FRBC.OperationMode.elements`: \"The fill_level_ranges of the items in the Array must be contiguous.\"";
202 FRBC_LEAKAGE_CONTIGUOUS = "S2-FRBC-002", Error, false,
203 "Leakage bands must be contiguous",
204 "`S2J messages/FRBC.LeakageBehaviour.elements`: \"The fill_level_ranges of the elements must be contiguous.\"";
205 FRBC_UNKNOWN_ACTUATOR = "S2-FRBC-003", Error, true,
206 "An instruction must name an actuator the system description declares",
207 "`S2J messages/FRBC.Instruction.actuator_id`: \"ID of the actuator this instruction belongs to.\"";
208 FRBC_UNKNOWN_MODE = "S2-FRBC-004", Error, true,
209 "An instruction must name an operation mode that actuator has",
210 "`S2J messages/FRBC.Instruction.operation_mode`: \"ID of the FRBC.OperationMode that should be activated.\"";
211 FRBC_TRANSITION_REFERENCES = "S2-FRBC-005", Error, false,
212 "A transition must name operation modes and timers of its own actuator",
213 "`S2J schemas/Transition`: the ids are \"unique in the scope of the ... FRBC.ActuatorDescription in which it is used\".";
214 FRBC_NOT_OFFERED = "S2-FRBC-006", Error, true,
215 "Leakage, usage forecast and target profile may only be sent if the storage offers them",
216 "`S2J schemas/FRBC.StorageDescription`: the three `provides_*` flags.";
217 FRBC_FILL_LEVEL_OUT_OF_RANGE = "S2-FRBC-007", Warning, true,
218 "The reported fill level is outside the range the storage described",
219 "`S2J schemas/FRBC.StorageDescription.fill_level_range`: \"When the fill_level is not within this range, the Resource Manager can ignore instructions from the CEM.\" Reported so a CEM knows why it is being ignored.";
220
221 PEBC_BOTH_LIMITS = "S2-PEBC-001", Error, false,
223 "Power constraints need at least one upper and one lower allowed range",
224 "`S2J messages/PEBC.PowerConstraints.allowed_limit_ranges`: \"There shall be at least one PEBC.AllowedLimitRange for the UPPER_LIMIT and at least one AllowedLimitRange for the LOWER_LIMIT.\"";
225 PEBC_VALIDITY_WINDOW = "S2-PEBC-002", Error, false,
226 "valid_from must precede valid_until",
227 "`S2J messages/PEBC.PowerConstraints`: a window that ends before it starts is never in force.";
228 PEBC_ENVELOPE_LIMIT_ORDER = "S2-PEBC-003", Error, false,
229 "An envelope element's lower limit must not exceed its upper limit",
230 "`S2J schemas/PEBC.PowerEnvelopeElement.upper_limit`: \"The lower_limit must be smaller or equal to the upper_limit.\"";
231 PEBC_ONE_ENVELOPE_PER_QUANTITY = "S2-PEBC-004", Error, false,
232 "At most one envelope per CommodityQuantity",
233 "`S2J messages/PEBC.Instruction.power_envelopes`: \"at most one PEBC.PowerEnvelope for each CommodityQuantity.\"";
234 PEBC_UNKNOWN_CONSTRAINTS = "S2-PEBC-005", Error, true,
235 "An instruction must reference power constraints that are published and in force",
236 "`S2J messages/PEBC.Instruction.power_constraints_id`: \"Identifier of the PEBC.PowerConstraints this PEBC.Instruction was based on.\"";
237 PEBC_OUTSIDE_ALLOWED = "S2-PEBC-006", Error, true,
238 "An envelope limit must lie within an allowed range for its quantity",
239 "`S2J schemas/PEBC.PowerEnvelopeElement.upper_limit`: \"shall be in accordance with the constraints provided by the Resource Manager through any PEBC.AllowedLimitRange with limit_type UPPER_LIMIT.\"";
240 PEBC_ENERGY_ORDER = "S2-PEBC-007", Error, false,
241 "The lower average power must not exceed the upper",
242 "`S2J messages/PEBC.EnergyConstraint`: the description of `lower_average_power` repeats the line above it by mistake and says \"greater than or equal to lower_average_power\"; it means at most `upper_average_power` (erratum E3).";
243
244 PPBC_WINDOW = "S2-PPBC-001", Error, false,
246 "A profile's start must not be after its end",
247 "`S2J messages/PPBC.PowerProfileDefinition`: `start_time` is \"the first possible time the first PPBC.PowerSequence could start\" and `end_time` when the last \"shall be finished at the latest\".";
248 PPBC_UNKNOWN_SEQUENCE = "S2-PPBC-002", Error, true,
249 "An instruction must resolve profile, container and sequence together",
250 "`S2J messages/PPBC.ScheduleInstruction`: the three ids name a profile, a container within it, and a sequence within that.";
251 PPBC_NOT_INTERRUPTIBLE = "S2-PPBC-003", Error, true,
252 "Only a sequence that says it is interruptible may be interrupted",
253 "`S2J schemas/PPBC.PowerSequence.is_interruptible`: \"Indicates whether the option of pausing a sequence is available.\"";
254 PPBC_STATUS_COVERAGE = "S2-PPBC-004", Error, true,
255 "A profile status must cover every container of the profile",
256 "`S2J messages/PPBC.PowerProfileStatus.sequence_container_status`: \"Array with status information for all PPBC.PowerSequenceContainers in the PPBC.PowerProfileDefinition.\"";
257 PPBC_PROGRESS = "S2-PPBC-005", Error, false,
258 "A status for a sequence that has started must report its progress",
259 "`S2J schemas/PPBC.PowerSequenceContainerStatus.progress`: \"A value must be provided, unless no sequence has been selected or the selected sequence hasn't started yet.\" This is the half the sentence states plainly: once the selected sequence is running, the CEM is told how far in it is.";
260 PPBC_WINDOW_TOO_SHORT = "S2-PPBC-006", Warning, false,
261 "The window is shorter than the shortest sequence offered",
262 "Implied by the two together: a task that cannot finish inside its own window is one no CEM can schedule.";
263 PPBC_PROGRESS_UNEXPECTED = "S2-PPBC-007", Warning, false,
264 "Progress was reported for a sequence that has not started",
265 "The converse of `S2-PPBC-005`, and it is **not stated**. `S2J schemas/PPBC.PowerSequenceContainerStatus.progress` says a value \"must be provided, unless no sequence has been selected or the selected sequence hasn\u{2019}t started yet\" — which grants permission to omit it, and does not forbid sending it. A `progress` of zero beside a `SCHEDULED` status is redundant rather than wrong, and refusing it would make this crate stricter than the standard (D4). A warning, so a peer that means something by it is still heard.";
266 PPBC_SEQUENCE_NOT_NAMED = "S2-PPBC-008", Error, false,
267 "A status that says a sequence was selected must name which one",
268 "`S2J schemas/PPBC.PowerSequenceContainerStatus.selected_sequence_id`: \"When no ID is given, no sequence was selected yet.\" Read the other way round, which is the way a receiver reads it: a status whose `status` is anything but NOT_SCHEDULED asserts that a sequence *was* selected, and a CEM that is not told which one cannot match the progress to a duration.";
269
270 OMBC_UNKNOWN_MODE = "S2-OMBC-001", Error, true,
272 "An instruction must name an operation mode the system description declares",
273 "`S2J messages/OMBC.Instruction.operation_mode_id`: \"ID of the OMBC.OperationMode that should be activated.\"";
274 OMBC_TRANSITION_REFERENCES = "S2-OMBC-002", Error, false,
275 "A transition must name operation modes and timers of its own description",
276 "`S2J schemas/Transition`: the ids are \"unique in the scope of the OMBC.SystemDescription ... in which it is used\".";
277
278 DDBC_UNKNOWN_ACTUATOR = "S2-DDBC-001", Error, true,
280 "An instruction must name an actuator the system description declares",
281 "`S2J messages/DDBC.Instruction.actuator_id`: \"ID of the actuator this Instruction belongs to.\"";
282 DDBC_UNKNOWN_MODE = "S2-DDBC-002", Error, true,
283 "An instruction must name an operation mode that actuator has",
284 "`S2J messages/DDBC.Instruction.operation_mode_id`: \"ID of the DDBC.OperationMode\".";
285 DDBC_TRANSITION_REFERENCES = "S2-DDBC-003", Error, false,
286 "A transition must name operation modes and timers of its own actuator",
287 "`S2J schemas/Transition`: the ids are \"unique in the scope of the ... DDBC.ActuatorDescription in which it is used\".";
288 DDBC_FORECAST_NOT_OFFERED = "S2-DDBC-004", Error, true,
289 "A demand forecast may only be sent if the system description offers one",
290 "`S2J messages/DDBC.SystemDescription.provides_average_demand_rate_forecast`: \"Indicates whether the Resource Manager could provide a demand rate forecast.\"";
291];
292
293impl Rule {
294 #[must_use]
296 pub fn find(id: RuleId) -> Option<&'static Rule> {
297 RULES.iter().find(|r| r.id == id)
298 }
299}
300
301#[cfg(test)]
302mod tests {
303 use super::*;
304 use alloc::vec::Vec;
305
306 #[test]
307 fn identifiers_are_unique_and_well_formed() {
308 let mut ids: Vec<&str> = RULES.iter().map(|r| r.id.as_str()).collect();
309 let count = ids.len();
310 ids.sort_unstable();
311 ids.dedup();
312 assert_eq!(ids.len(), count, "duplicate rule identifier");
313
314 for rule in RULES {
315 let id = rule.id.as_str();
316 let mut parts = id.split('-');
317 assert_eq!(parts.next(), Some("S2"), "{id}");
318 let area = parts.next().unwrap_or_default();
319 assert!(
320 !area.is_empty() && area.chars().all(char::is_uppercase),
321 "{id}"
322 );
323 let number = parts.next().unwrap_or_default();
324 assert_eq!(number.len(), 3, "{id} should end in three digits");
325 assert!(number.chars().all(|c| c.is_ascii_digit()), "{id}");
326 assert_eq!(parts.next(), None, "{id}");
327 }
328 }
329
330 #[test]
331 fn the_table_really_is_in_identifier_order() {
332 let mut previous: Option<(&str, u32)> = None;
335 for rule in RULES {
336 let id = rule.id.as_str();
337 let mut parts = id.split('-').skip(1);
338 let area = parts.next().unwrap_or_default();
339 let number: u32 = parts.next().unwrap_or_default().parse().unwrap_or(0);
340 if let Some((previous_area, previous_number)) = previous
341 && previous_area == area
342 {
343 assert!(
344 number > previous_number,
345 "{id} follows S2-{previous_area}-{previous_number:03}"
346 );
347 }
348 previous = Some((area, number));
349 }
350 }
351
352 #[test]
353 fn every_rule_cites_a_source_and_says_what_it_checks() {
354 for rule in RULES {
355 assert!(rule.summary.len() > 20, "{} has no summary", rule.id);
356 assert!(rule.source.len() > 30, "{} has no citation", rule.id);
357 }
358 }
359
360 #[test]
361 fn ambiguity_is_a_warning_and_a_plain_requirement_is_an_error() {
362 for rule in RULES {
364 let cites_ambiguity = rule.source.contains("Not stated")
365 || rule.source.contains("not stated")
366 || rule.source.contains("Undocumented")
367 || rule.source.contains("undocumented")
368 || rule.source.contains("Inferred")
369 || rule.source.contains("Implied");
370 if cites_ambiguity {
371 assert_eq!(
372 rule.severity,
373 Severity::Warning,
374 "{} rests on an ambiguity and must not be an error",
375 rule.id
376 );
377 }
378 }
379 }
380
381 #[test]
382 fn lookup_works() {
383 assert_eq!(Rule::find(FRBC_UNKNOWN_MODE).unwrap().id, FRBC_UNKNOWN_MODE);
384 assert!(Rule::find(RuleId("S2-NOPE-001")).is_none());
385 }
386}