Adds -ap to process all lints

This commit is contained in:
Dandaedre 2024-11-21 08:33:33 -06:00
parent 52ad5e459e
commit a12912a8a8
2 changed files with 26 additions and 17 deletions

View File

@ -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" (?<rule>[^\s]*_\d*)\s*\| (?<severity>[^\s]*)\s*\|\s*(?<line>[^\s]*) \| (?<solution>.*)"
);
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<String>) -> Result<String, anyhow::Error> {
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),

View File

@ -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";