1#[derive(Clone, Copy, Debug, PartialEq, Eq)]
6pub enum LintCode {
7 NotANode,
8 NotAFile,
9 NoDefaultRoot,
10 EntryPoint,
11 EntryPointRefused,
12 GridRowsPerBar,
13 MissingComment,
14 MalformedComment,
15 MultilineComment,
16 LongCommentBlock,
17 LongExpressionBody,
18 TagShape,
19 LiteralSampleRate,
20 KeyIsNotAPitch,
21 WindowInsideRamp,
22}
23
24impl LintCode {
25 pub const ALL: &'static [LintCode] = &[
26 LintCode::NotANode,
27 LintCode::NotAFile,
28 LintCode::NoDefaultRoot,
29 LintCode::EntryPoint,
30 LintCode::EntryPointRefused,
31 LintCode::GridRowsPerBar,
32 LintCode::MissingComment,
33 LintCode::MalformedComment,
34 LintCode::MultilineComment,
35 LintCode::LongCommentBlock,
36 LintCode::LongExpressionBody,
37 LintCode::TagShape,
38 LintCode::LiteralSampleRate,
39 LintCode::KeyIsNotAPitch,
40 LintCode::WindowInsideRamp,
41 ];
42
43 pub fn code_str(self) -> &'static str {
44 match self {
45 LintCode::NotANode => "not-a-node",
46 LintCode::NotAFile => "not-a-file",
47 LintCode::NoDefaultRoot => "no-default-root",
48 LintCode::EntryPoint => "entry-point",
49 LintCode::EntryPointRefused => "entry-point-refused",
50 LintCode::GridRowsPerBar => "grid-rows-per-bar",
51 LintCode::MissingComment => "missing-comment",
52 LintCode::MalformedComment => "malformed-comment",
53 LintCode::MultilineComment => "multiline-comment",
54 LintCode::LongCommentBlock => "long-comment-block",
55 LintCode::LongExpressionBody => "long-expression-body",
56 LintCode::TagShape => "tag-shape",
57 LintCode::LiteralSampleRate => "literal-sample-rate",
58 LintCode::KeyIsNotAPitch => "key-is-not-a-pitch",
59 LintCode::WindowInsideRamp => "window-inside-ramp",
60 }
61 }
62
63 pub fn help(self) -> &'static str {
65 match self {
66 LintCode::NotANode => {
67 "rename it to what a `@ref` can spell — letters, digits, `_`, `-`, `/` — if it \
68 is meant to be read as a node"
69 }
70 LintCode::NotAFile => {
71 "move the socket, FIFO or device out of the composition directory; a node is \
72 one regular file's whole text"
73 }
74 LintCode::NoDefaultRoot => {
75 "add a `master` node, or name the node every render should target"
76 }
77 LintCode::EntryPoint => {
78 "ref the node from something above it, or delete it if the name is a typo"
79 }
80 LintCode::EntryPointRefused => {
81 "fix the node the refusal names, or delete it: a whole-directory render reaches it"
82 }
83 LintCode::GridRowsPerBar => {
84 "make the row count a whole multiple of the filename's bar span, or restate the span"
85 }
86 LintCode::MissingComment | LintCode::MalformedComment => {
87 "give the node one `;`-comment line: `; Models: ... | Neglects: ... | IO: ... -> ... \
88 | Tags: ...`"
89 }
90 LintCode::MultilineComment => "fold the `;`-comment onto one line",
91 LintCode::LongCommentBlock => {
92 "move the prose out of the node and keep the one `;`-comment line"
93 }
94 LintCode::LongExpressionBody => "split the expression across nodes and `@ref` them",
95 LintCode::TagShape => {
96 "write `Tags:` as the one-line, comma-separated field the others use"
97 }
98 LintCode::LiteralSampleRate => {
99 "write the sample period as `sp` and let the render choose its rate"
100 }
101 LintCode::KeyIsNotAPitch => {
102 "hold one note name or a number of hertz in `variables/key`"
103 }
104 LintCode::WindowInsideRamp => {
105 "widen the window past the ramp, or shorten the shoulder it sits inside"
106 }
107 }
108 }
109}