From a12912a8a88886dcd6a1f97d91c0043598341c08 Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Thu, 21 Nov 2024 08:33:33 -0600 Subject: [PATCH] Adds -ap to process all lints --- src/main.rs | 39 ++++++++++++++++++++++++--------------- vhdl/test.vhd | 4 ++-- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/src/main.rs b/src/main.rs index 0189f8b..bfbe87e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,7 +3,7 @@ //! #![deny(clippy::missing_docs_in_private_items)] -#![warn(clippy::pedantic)] +// #![warn(clippy::pedantic, clippy::correctness)] use anyhow::{anyhow, Context}; use clap::Parser; @@ -133,18 +133,7 @@ fn find_diagnostics_for_file( r" (?[^\s]*_\d*)\s*\| (?[^\s]*)\s*\|\s*(?[^\s]*) \| (?.*)" ); - let v = &Command::new("vsg") - .arg("-f") - .arg( - uri.to_file_path() - .map_err(|()| anyhow!("converting uri to file path"))?, - ) - .args(config) - .output() - .context("failed to run vsg linter")? - .stdout; - - let output = String::from_utf8_lossy(v); + let output = file_uri_to_diagnostic_string(uri, config)?; let matches = reg.captures_iter(&output); for m in matches { if let (Some(rule), Some(line), Some(solution)) = @@ -155,9 +144,9 @@ fn find_diagnostics_for_file( Err(_) => continue, }; let d = Diagnostic { - range, + range, // TODO: Should find the true range severity: Some(DiagnosticSeverity::WARNING), // Everything is a warning - code: Some(NumberOrString::String(rule.as_str().to_owned())), // The important second part + code: Some(NumberOrString::String(rule.as_str().to_owned())), message: solution.as_str().to_owned(), ..Default::default() }; @@ -167,6 +156,26 @@ fn find_diagnostics_for_file( Ok(vec_diag) } +/// Load the file and make a diagnostic as a string +fn file_uri_to_diagnostic_string(uri: &Url, config: &Vec) -> Result { + Ok(String::from_utf8_lossy( + &Command::new("vsg") + .arg("-ap") + .arg("-f") + .arg( + uri.to_file_path() + .map_err(|()| anyhow!("converting uri to file path"))?, + ) + .args(config) + .output() + .context("failed to run vsg linter")? + .stdout, + ) + .into_owned()) +} + +/// Make a range with a line position +// TODO: Find the actual range fn make_range(pos: u32) -> Range { Range::new( Position::new(pos.saturating_sub(1), 0), diff --git a/vhdl/test.vhd b/vhdl/test.vhd index 287f9c8..8621a09 100644 --- a/vhdl/test.vhd +++ b/vhdl/test.vhd @@ -5,9 +5,9 @@ architecture sim of test_tb is signal fork : boolean; signal join_1, join_2, join_3 : boolean; - + begin - + CONTROLLER_PROC : process begin report "Forking";