• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pomsky-lang / pomsky / 6421193078

05 Oct 2023 03:30PM UTC coverage: 80.191%. Remained the same
6421193078

push

github

Aloso
chore: fix formatting

3 of 3 new or added lines in 2 files covered. (100.0%)

3267 of 4074 relevant lines covered (80.19%)

246.52 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

67.65
/pomsky-bin/src/args/warnings.rs
1
use std::{ffi::OsString, str::FromStr};
2

3
use pomsky::diagnose::DiagnosticKind;
4

5
use super::ParseArgsError;
6

7
#[derive(Debug, PartialEq)]
×
8
pub(crate) enum DiagnosticSet {
9
    All,
10
    Disabled(Vec<DiagnosticKind>),
×
11
    Enabled(Vec<DiagnosticKind>),
×
12
}
13

14
impl DiagnosticSet {
15
    pub(crate) fn is_enabled(&self, kind: DiagnosticKind) -> bool {
4✔
16
        match self {
4✔
17
            DiagnosticSet::All => true,
2✔
18
            DiagnosticSet::Disabled(set) => !set.contains(&kind),
2✔
19
            DiagnosticSet::Enabled(set) => set.contains(&kind),
×
20
        }
21
    }
4✔
22

23
    pub(super) fn parse(value: OsString, mut warnings: Self) -> Result<Self, ParseArgsError> {
3✔
24
        let value = value.to_string_lossy();
3✔
25
        if value.as_ref() == "0" {
5✔
26
            Ok(DiagnosticSet::Enabled(vec![]))
1✔
27
        } else {
28
            let mut warning_list_own = vec![];
2✔
29
            let warning_list = match &mut warnings {
2✔
30
                DiagnosticSet::Disabled(set) => set,
×
31
                DiagnosticSet::Enabled(_) => return Ok(warnings),
×
32
                DiagnosticSet::All => &mut warning_list_own,
2✔
33
            };
34

35
            for warning in value.split(',') {
4✔
36
                let (kind_str, val) = warning
4✔
37
                    .trim_start()
38
                    .rsplit_once('=')
39
                    .ok_or_else(|| ParseArgsError::WarningsNoEquals(warning.to_string()))?;
2✔
40

41
                if val != "0" {
2✔
42
                    return Err(ParseArgsError::WarningsNoZero(kind_str.to_string()));
×
43
                }
44

45
                let kind = DiagnosticKind::from_str(kind_str).map_err(|_| {
2✔
46
                    ParseArgsError::Other(format!(
×
47
                        "`{kind_str}` is not a recognized diagnostic kind"
48
                    ))
49
                })?;
×
50

51
                let (DiagnosticKind::Compat | DiagnosticKind::Deprecated) = kind else {
2✔
52
                    return Err(ParseArgsError::WarningsNotAllowed(kind_str.to_string()));
×
53
                };
54

55
                warning_list.push(kind);
2✔
56
            }
57

58
            if matches!(warnings, DiagnosticSet::All) {
2✔
59
                Ok(DiagnosticSet::Disabled(warning_list_own))
2✔
60
            } else {
61
                Ok(warnings)
×
62
            }
63
        }
2✔
64
    }
3✔
65
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc