diff --git a/src/check.rs b/src/check.rs new file mode 100644 index 0000000000..30fde191bb --- /dev/null +++ b/src/check.rs @@ -0,0 +1,31 @@ +use rustpython_parser::ast::Location; +use serde::{Deserialize, Serialize}; + +#[derive(Serialize, Deserialize)] +pub enum CheckKind { + ImportStarUsage, + IfTuple, +} + +impl CheckKind { + /// A four-letter shorthand code for the check. + pub fn code(&self) -> &'static str { + match self { + CheckKind::ImportStarUsage => "F403", + CheckKind::IfTuple => "F634", + } + } + + /// The body text for the check. + pub fn body(&self) -> &'static str { + match self { + CheckKind::ImportStarUsage => "Unable to detect undefined names", + CheckKind::IfTuple => "If test is a tuple, which is always `True`", + } + } +} + +pub struct Check { + pub kind: CheckKind, + pub location: Location, +} diff --git a/src/checker.rs b/src/checker.rs index 9f6d04d7f2..791f78576a 100644 --- a/src/checker.rs +++ b/src/checker.rs @@ -1,6 +1,6 @@ use rustpython_parser::ast::{ExprKind, Stmt, StmtKind, Suite}; -use crate::message::{Check, CheckKind}; +use crate::check::{Check, CheckKind}; use crate::visitor::{walk_stmt, Visitor}; struct Checker { diff --git a/src/lib.rs b/src/lib.rs index 7f514ed7f0..109e063155 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,8 +1,9 @@ mod cache; +mod check; pub mod checker; pub mod fs; pub mod linter; pub mod logging; pub mod message; -pub mod parser; -pub mod visitor; +mod parser; +mod visitor; diff --git a/src/message.rs b/src/message.rs index af7f16d325..b72400a6eb 100644 --- a/src/message.rs +++ b/src/message.rs @@ -4,6 +4,8 @@ use colored::Colorize; use rustpython_parser::ast::Location; use serde::{Deserialize, Serialize}; +use crate::check::CheckKind; + #[derive(Serialize, Deserialize)] #[serde(remote = "Location")] struct LocationDef { @@ -19,35 +21,6 @@ impl From for Location { } } -#[derive(Serialize, Deserialize)] -pub enum CheckKind { - ImportStarUsage, - IfTuple, -} - -impl CheckKind { - /// A four-letter shorthand code for the check. - pub fn code(&self) -> &'static str { - match self { - CheckKind::ImportStarUsage => "F403", - CheckKind::IfTuple => "F634", - } - } - - /// The body text for the check. - pub fn body(&self) -> &'static str { - match self { - CheckKind::ImportStarUsage => "Unable to detect undefined names", - CheckKind::IfTuple => "If test is a tuple, which is always `True`", - } - } -} - -pub struct Check { - pub kind: CheckKind, - pub location: Location, -} - #[derive(Serialize, Deserialize)] pub struct Message { pub kind: CheckKind,