1#[derive(Clone, Copy, Debug, PartialEq, Eq)]
6pub enum LintCode {
7 MissingComment,
8 MalformedComment,
9 MultilineComment,
10 LongCommentBlock,
11 LongExpressionBody,
12 LiteralSampleRate,
13 Arity,
14 KeyIsNotAPitch,
15 ParameterHasNoDefault,
16 SupportNeverEnds,
17}
18
19impl LintCode {
20 pub const ALL: &'static [LintCode] = &[
21 LintCode::MissingComment,
22 LintCode::MalformedComment,
23 LintCode::MultilineComment,
24 LintCode::LongCommentBlock,
25 LintCode::LongExpressionBody,
26 LintCode::LiteralSampleRate,
27 LintCode::Arity,
28 LintCode::KeyIsNotAPitch,
29 LintCode::ParameterHasNoDefault,
30 LintCode::SupportNeverEnds,
31 ];
32
33 pub fn code_str(self) -> &'static str {
34 match self {
35 LintCode::MissingComment => "missing-comment",
36 LintCode::MalformedComment => "malformed-comment",
37 LintCode::MultilineComment => "multiline-comment",
38 LintCode::LongCommentBlock => "long-comment-block",
39 LintCode::LongExpressionBody => "long-expression-body",
40 LintCode::LiteralSampleRate => "literal-sample-rate",
41 LintCode::Arity => "arity",
42 LintCode::KeyIsNotAPitch => "key-is-not-a-pitch",
43 LintCode::ParameterHasNoDefault => "parameter-has-no-default",
44 LintCode::SupportNeverEnds => "support-never-ends",
45 }
46 }
47
48 pub fn help(self) -> &'static str {
50 match self {
51 LintCode::MissingComment | LintCode::MalformedComment => {
52 "give the node one `;`-comment line: `; Models: ... | Neglects: ... | IO: ... -> ... \
53 | Tags: ...`"
54 }
55 LintCode::MultilineComment => "fold the `;`-comment onto one line",
56 LintCode::LongCommentBlock => {
57 "move the prose out of the node and keep the one `;`-comment line"
58 }
59 LintCode::LongExpressionBody => "split the expression across nodes and `@ref` them",
60 LintCode::LiteralSampleRate => {
61 "write the sample period as `sp` and let the render choose its rate"
62 }
63 LintCode::Arity => "give the call what its builtin reads, as `sva-cli builtins` lists",
64 LintCode::KeyIsNotAPitch => {
65 "hold one note name or a number of hertz in `variables/key`"
66 }
67 LintCode::ParameterHasNoDefault => {
68 "give the parameter a `name = value` line above the expression, so the node plays bare"
69 }
70 LintCode::SupportNeverEnds => {
71 "crop it, or shape it to decay, so a bare render of it ends"
72 }
73 }
74 }
75}