From 78889efa3768dcd917abc33f5e55c0e55b211b4a Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Mon, 31 Oct 2022 09:20:14 -0400 Subject: [PATCH] Modify public API to return Check rather than Message (#524) --- src/lib.rs | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 56e0f56ece..74c01b72e1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,12 +10,12 @@ use settings::pyproject; use settings::Settings; use crate::autofix::fixer::Mode; +use crate::checks::Check; use crate::linter::{check_path, tokenize}; -use crate::message::Message; use crate::settings::configuration::Configuration; mod ast; -mod autofix; +pub mod autofix; pub mod cache; pub mod check_ast; mod check_lines; @@ -48,7 +48,7 @@ pub mod source_code_locator; pub mod visibility; /// Run ruff over Python source code directly. -pub fn check(path: &Path, contents: &str) -> Result> { +pub fn check(path: &Path, contents: &str) -> Result> { // Find the project root and pyproject.toml. let project_root = pyproject::find_project_root(&[path.to_path_buf()]); match &project_root { @@ -80,17 +80,5 @@ pub fn check(path: &Path, contents: &str) -> Result> { &Mode::None, )?; - // Convert to messages. - let messages: Vec = checks - .into_iter() - .map(|check| Message { - kind: check.kind, - fixed: check.fix.map(|fix| fix.applied).unwrap_or_default(), - location: check.location, - end_location: check.end_location, - filename: path.to_string_lossy().to_string(), - }) - .collect(); - - Ok(messages) + Ok(checks) }