aboutsummaryrefslogtreecommitdiff
path: root/mingling_cli/src/linter.rs
blob: c85afc1b2a8fb440971a9daccaad9c47b85074f5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
use mingling::{
    Program,
    macros::{chain, dispatcher, entry, program_setup},
};

use crate::{
    linter::cmd_mlint::{CMDMinglingLinter, EntryMinglingLinter},
    metadata::setup::ResUsingJson,
};

pub mod cmd_mlint;
pub mod mlint_attr;
pub mod mlint_report;

#[program_setup]
pub fn mingling_linter_setup(program: &mut Program<crate::ThisProgram>) {
    program.with_setup(MinglingLinterCommandSetup);
}

#[program_setup]
pub fn mingling_linter_command_setup(program: &mut Program<crate::ThisProgram>) {
    program.with_dispatcher(CMDMinglingLinter);
    program.with_dispatcher(CMDLinterSupportRustAnalyzer);
    program.with_dispatcher(CMDLinterSupportRustAnalyzerWithClippy);
    program.with_dispatcher(CMDLinterSupportRustAnalyzerWithCheck);
}

// Aliases

dispatcher!("ra-lint-clippy",
    CMDLinterSupportRustAnalyzerWithClippy => EntryLinterSupportRustAnalyzerWithClippy
);

dispatcher!("ra-lint-check",
    CMDLinterSupportRustAnalyzerWithCheck => EntryLinterSupportRustAnalyzerWithCheck
);

dispatcher!("ra-lint",
    CMDLinterSupportRustAnalyzer => EntryLinterSupportRustAnalyzer
);

#[chain]
pub fn handle_ra_lint(
    _: EntryLinterSupportRustAnalyzer,
    use_json: &mut ResUsingJson,
) -> EntryMinglingLinter {
    use_json.using = true;
    entry!("--message-format=json")
}

#[chain]
pub fn handle_ra_lint_check(
    _: EntryLinterSupportRustAnalyzerWithCheck,
    use_json: &mut ResUsingJson,
) -> EntryMinglingLinter {
    use_json.using = true;
    entry!("--message-format=json", "--with-checker=cargo,check")
}

#[chain]
pub fn handle_ra_lint_clippy(
    _: EntryLinterSupportRustAnalyzerWithClippy,
    use_json: &mut ResUsingJson,
) -> EntryMinglingLinter {
    use_json.using = true;
    entry!("--message-format=json", "--with-checker=cargo,clippy")
}