Lints and suggestions for the Nix programming language
at main 65 lines 1.7 kB view raw
1use std::io; 2 3use thiserror::Error; 4 5#[derive(Error, Debug)] 6pub enum ConfigErr { 7 #[error("error parsing ignore list `{0}`")] 8 InvalidGlob(#[from] ignore::Error), 9 #[error("path error: {0}")] 10 InvalidPath(#[from] io::Error), 11 #[error("unable to parse `{0}` as line and column")] 12 InvalidPosition(String), 13 #[error("unable to parse `{0}` as warning code")] 14 InvalidWarningCode(String), 15 #[error("unable to parse config file: {0}")] 16 ConfFileParse(toml::de::Error), 17 #[error("unable to parse nix version: `{0}`")] 18 ConfFileVersionParse(String), 19} 20 21// #[derive(Error, Debug)] 22// pub enum LintErr { 23// #[error("[{0}] syntax error: {1}")] 24// Parse(PathBuf, ParseError), 25// } 26 27#[derive(Error, Debug)] 28pub enum FixErr { 29 // #[error("[{0}] syntax error: {1}")] 30 // Parse(PathBuf, ParseError), 31 #[error("path error: {0}")] 32 InvalidPath(#[from] io::Error), 33} 34 35#[derive(Error, Debug)] 36pub enum SingleFixErr { 37 #[error("path error: {0}")] 38 InvalidPath(#[from] io::Error), 39 #[error("position out of bounds: line {0}, col {1}")] 40 OutOfBounds(usize, usize), 41 #[error("{0} is too large")] 42 Conversion(usize), 43 #[error("nothing to fix")] 44 NoOp, 45} 46 47#[derive(Error, Debug)] 48pub enum ExplainErr { 49 #[error("lint with code `{0}` not found")] 50 LintNotFound(u32), 51} 52 53#[derive(Error, Debug)] 54pub enum StatixErr { 55 // #[error("linter error: {0}")] 56 // Lint(#[from] LintErr), 57 #[error("fixer error: {0}")] 58 Fix(#[from] FixErr), 59 #[error("single fix error: {0}")] 60 Single(#[from] SingleFixErr), 61 #[error("config error: {0}")] 62 Config(#[from] ConfigErr), 63 #[error("explain error: {0}")] 64 Explain(#[from] ExplainErr), 65}