diff --git a/.qlty/qlty.toml b/.qlty/qlty.toml index fedabdedb..662b1d25e 100644 --- a/.qlty/qlty.toml +++ b/.qlty/qlty.toml @@ -95,6 +95,11 @@ name = "yamllint" plugins = ["osv-scanner", "trufflehog"] file_patterns = ["qlty-cli/tests/**"] +# Disable ripgrep from analyzing the ripgrep parser +[[ignore]] +plugins = ["ripgrep"] +file_patterns = ["**/ripgrep.rs"] + [[ignore]] rules = ["markdownlint/MD024"] file_patterns = ["CHANGELOG.md"] \ No newline at end of file diff --git a/qlty-check/src/parser/ripgrep.rs b/qlty-check/src/parser/ripgrep.rs index dc5140e7b..3b09ca48d 100644 --- a/qlty-check/src/parser/ripgrep.rs +++ b/qlty-check/src/parser/ripgrep.rs @@ -93,7 +93,7 @@ impl Parser for Ripgrep { tool: "ripgrep".into(), message: text.trim().to_string(), category: Category::Lint.into(), - level: Level::Medium.into(), + level: Level::Note.into(), rule_key: submatch.rg_match.text.clone(), location: Some(Location { path: path.text.clone(), @@ -136,11 +136,11 @@ mod test { "###; let issues = Ripgrep::default().parse("ripgrep", input); - insta::assert_yaml_snapshot!(issues.unwrap(), @r" + insta::assert_yaml_snapshot!(issues.unwrap(), @r###" - tool: ripgrep ruleKey: FIXME message: // FIXME TODO - level: LEVEL_MEDIUM + level: LEVEL_NOTE category: CATEGORY_LINT location: path: basic_e.in.rs @@ -152,7 +152,7 @@ mod test { - tool: ripgrep ruleKey: TODO message: // FIXME TODO - level: LEVEL_MEDIUM + level: LEVEL_NOTE category: CATEGORY_LINT location: path: basic_e.in.rs @@ -164,7 +164,7 @@ mod test { - tool: ripgrep ruleKey: NOTE message: // NOTE - level: LEVEL_MEDIUM + level: LEVEL_NOTE category: CATEGORY_LINT location: path: basic.in.rs @@ -176,7 +176,7 @@ mod test { - tool: ripgrep ruleKey: FIXME message: // FIXME TODO - level: LEVEL_MEDIUM + level: LEVEL_NOTE category: CATEGORY_LINT location: path: basic.in.rs @@ -188,7 +188,7 @@ mod test { - tool: ripgrep ruleKey: TODO message: // FIXME TODO - level: LEVEL_MEDIUM + level: LEVEL_NOTE category: CATEGORY_LINT location: path: basic.in.rs @@ -200,7 +200,7 @@ mod test { - tool: ripgrep ruleKey: HACK message: // HACK - level: LEVEL_MEDIUM + level: LEVEL_NOTE category: CATEGORY_LINT location: path: basic.in.rs @@ -209,7 +209,7 @@ mod test { startColumn: 7 endLine: 4 endColumn: 11 - "); + "###); } #[test] @@ -230,17 +230,17 @@ mod test { assert!(logs_contain("Failed to parse line number")); assert!(logs_contain("Failed to parse path")); - insta::assert_yaml_snapshot!(issues.unwrap(), @r" + insta::assert_yaml_snapshot!(issues.unwrap(), @r###" - tool: ripgrep ruleKey: NOTE message: // NOTE - level: LEVEL_MEDIUM + level: LEVEL_NOTE category: CATEGORY_LINT location: path: basic.in.rs range: startLine: 2 endLine: 2 - "); + "###); } } diff --git a/qlty-check/src/processor.rs b/qlty-check/src/processor.rs index bd93a9c34..fa57afd07 100644 --- a/qlty-check/src/processor.rs +++ b/qlty-check/src/processor.rs @@ -8,10 +8,7 @@ use crate::{ }; use anyhow::Result; use qlty_analysis::IssueCount; -use qlty_types::{ - analysis::v1::{Category, ExecutionVerb, Issue}, - level_from_str, -}; +use qlty_types::analysis::v1::{Category, ExecutionVerb, Issue}; use tracing::info; pub struct Processor { @@ -69,9 +66,7 @@ impl Processor { for issue in &self.issues { if let Some(fail_level) = self.plan.fail_level { - if issue.level - >= level_from_str(fail_level.as_str_name().to_lowercase().as_str()) as i32 - { + if issue.level >= fail_level as i32 { self.counts.failure_issues += 1; } } diff --git a/qlty-cli/src/commands/check.rs b/qlty-cli/src/commands/check.rs index 0d2458cb9..880b6d149 100644 --- a/qlty-cli/src/commands/check.rs +++ b/qlty-cli/src/commands/check.rs @@ -15,7 +15,6 @@ use qlty_cloud::format::JsonFormatter; use qlty_config::Workspace; use qlty_types::analysis::v1::ExecutionVerb; use qlty_types::analysis::v1::Level; -use qlty_types::level_from_str; use std::io::BufRead as _; use std::io::{self, Read}; use std::path::PathBuf; @@ -68,9 +67,9 @@ pub struct Check { #[arg(long, conflicts_with = "all")] pub sample: Option, - /// Minimum level of issues to show (high, medium, low) - #[arg(long)] - pub level: Option, + /// Minimum level of issues to show + #[arg(long, value_enum, default_value = "note")] + pub level: Level, /// Maximum number of concurrent jobs #[arg(short, long)] @@ -279,7 +278,7 @@ impl Check { settings.formatters = !self.no_formatters; settings.filters = CheckFilter::from_optional_list(self.filter.clone()); settings.upstream = self.compute_upstream()?; - settings.level = level_from_str(&self.level.clone().unwrap_or("".to_string())); + settings.level = self.level; settings.fail_level = if self.no_fail { None } else { diff --git a/qlty-cli/src/ui/level.rs b/qlty-cli/src/ui/level.rs index 462e0f230..e0995971d 100644 --- a/qlty-cli/src/ui/level.rs +++ b/qlty-cli/src/ui/level.rs @@ -6,7 +6,8 @@ pub fn formatted_level(level: Level) -> String { Level::High => style("high ").red().to_string(), Level::Medium => style("medium").magenta().to_string(), Level::Low => style("low ").yellow().to_string(), - Level::Fmt => style("fmt ").dim().to_string(), + Level::Fmt => style("fmt ").yellow().dim().to_string(), + Level::Note => style("note ").dim().to_string(), _ => format!("{:?}", level), } } diff --git a/qlty-plugins/plugins/linters/ripgrep/fixtures/__snapshots__/basic_v14.1.0.shot b/qlty-plugins/plugins/linters/ripgrep/fixtures/__snapshots__/basic_v14.1.0.shot index e93e78978..90bcccfea 100644 --- a/qlty-plugins/plugins/linters/ripgrep/fixtures/__snapshots__/basic_v14.1.0.shot +++ b/qlty-plugins/plugins/linters/ripgrep/fixtures/__snapshots__/basic_v14.1.0.shot @@ -5,7 +5,7 @@ exports[`linter=ripgrep fixture=basic version=14.1.0 1`] = ` "issues": [ { "category": "CATEGORY_LINT", - "level": "LEVEL_MEDIUM", + "level": "LEVEL_NOTE", "location": { "path": "basic.in.rs", "range": { @@ -32,7 +32,7 @@ exports[`linter=ripgrep fixture=basic version=14.1.0 1`] = ` }, { "category": "CATEGORY_LINT", - "level": "LEVEL_MEDIUM", + "level": "LEVEL_NOTE", "location": { "path": "basic.in.rs", "range": { @@ -59,7 +59,7 @@ exports[`linter=ripgrep fixture=basic version=14.1.0 1`] = ` }, { "category": "CATEGORY_LINT", - "level": "LEVEL_MEDIUM", + "level": "LEVEL_NOTE", "location": { "path": "basic.in.rs", "range": { @@ -86,7 +86,7 @@ exports[`linter=ripgrep fixture=basic version=14.1.0 1`] = ` }, { "category": "CATEGORY_LINT", - "level": "LEVEL_MEDIUM", + "level": "LEVEL_NOTE", "location": { "path": "basic.in.rs", "range": { @@ -113,7 +113,7 @@ exports[`linter=ripgrep fixture=basic version=14.1.0 1`] = ` }, { "category": "CATEGORY_LINT", - "level": "LEVEL_MEDIUM", + "level": "LEVEL_NOTE", "location": { "path": "basic.in.rs", "range": { diff --git a/qlty-plugins/plugins/linters/ripgrep/fixtures/__snapshots__/basic_v14.1.1.shot b/qlty-plugins/plugins/linters/ripgrep/fixtures/__snapshots__/basic_v14.1.1.shot index a848f0bad..83faf5dd4 100644 --- a/qlty-plugins/plugins/linters/ripgrep/fixtures/__snapshots__/basic_v14.1.1.shot +++ b/qlty-plugins/plugins/linters/ripgrep/fixtures/__snapshots__/basic_v14.1.1.shot @@ -5,7 +5,7 @@ exports[`linter=ripgrep fixture=basic version=14.1.1 1`] = ` "issues": [ { "category": "CATEGORY_LINT", - "level": "LEVEL_MEDIUM", + "level": "LEVEL_NOTE", "location": { "path": "basic.in.rs", "range": { @@ -32,7 +32,7 @@ exports[`linter=ripgrep fixture=basic version=14.1.1 1`] = ` }, { "category": "CATEGORY_LINT", - "level": "LEVEL_MEDIUM", + "level": "LEVEL_NOTE", "location": { "path": "basic.in.rs", "range": { @@ -59,7 +59,7 @@ exports[`linter=ripgrep fixture=basic version=14.1.1 1`] = ` }, { "category": "CATEGORY_LINT", - "level": "LEVEL_MEDIUM", + "level": "LEVEL_NOTE", "location": { "path": "basic.in.rs", "range": { @@ -86,7 +86,7 @@ exports[`linter=ripgrep fixture=basic version=14.1.1 1`] = ` }, { "category": "CATEGORY_LINT", - "level": "LEVEL_MEDIUM", + "level": "LEVEL_NOTE", "location": { "path": "basic.in.rs", "range": { @@ -113,7 +113,7 @@ exports[`linter=ripgrep fixture=basic version=14.1.1 1`] = ` }, { "category": "CATEGORY_LINT", - "level": "LEVEL_MEDIUM", + "level": "LEVEL_NOTE", "location": { "path": "basic.in.rs", "range": { diff --git a/qlty-types/src/lib.rs b/qlty-types/src/lib.rs index 4f7b092d5..9c7409300 100644 --- a/qlty-types/src/lib.rs +++ b/qlty-types/src/lib.rs @@ -286,7 +286,7 @@ impl analysis::v1::Level { impl clap::ValueEnum for analysis::v1::Level { fn value_variants<'a>() -> &'a [Self] { &[ - analysis::v1::Level::Unspecified, + analysis::v1::Level::Note, analysis::v1::Level::Fmt, analysis::v1::Level::Low, analysis::v1::Level::Medium, diff --git a/qlty-types/src/protos/qlty.analysis.v1.rs b/qlty-types/src/protos/qlty.analysis.v1.rs index 02124fc5f..ad3aaf8db 100644 --- a/qlty-types/src/protos/qlty.analysis.v1.rs +++ b/qlty-types/src/protos/qlty.analysis.v1.rs @@ -454,11 +454,11 @@ impl MessageLevel { #[repr(i32)] pub enum Level { Unspecified = 0, - Note = 5, - Fmt = 1, - Low = 2, - Medium = 3, - High = 4, + Note = 10, + Fmt = 20, + Low = 30, + Medium = 40, + High = 50, } impl Level { /// String value of the enum field names used in the ProtoBuf definition.