Skip to content

feat: linter suppressions #440

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ pgt_query_ext_codegen = { path = "./crates/pgt_query_ext_codegen", version
pgt_query_proto_parser = { path = "./crates/pgt_query_proto_parser", version = "0.0.0" }
pgt_schema_cache = { path = "./crates/pgt_schema_cache", version = "0.0.0" }
pgt_statement_splitter = { path = "./crates/pgt_statement_splitter", version = "0.0.0" }
pgt_suppressions = { path = "./crates/pgt_suppressions", version = "0.0.0" }
pgt_text_edit = { path = "./crates/pgt_text_edit", version = "0.0.0" }
pgt_text_size = { path = "./crates/pgt_text_size", version = "0.0.0" }
pgt_treesitter_queries = { path = "./crates/pgt_treesitter_queries", version = "0.0.0" }
Expand Down
21 changes: 21 additions & 0 deletions crates/pgt_analyse/src/categories.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,27 @@ pub enum RuleCategory {
Transformation,
}

impl TryFrom<String> for RuleCategory {
type Error = String;

fn try_from(value: String) -> Result<Self, Self::Error> {
value.as_str().try_into()
}
}

impl TryFrom<&str> for RuleCategory {
type Error = String;

fn try_from(value: &str) -> Result<Self, Self::Error> {
match value {
"lint" => Ok(Self::Lint),
"action" => Ok(Self::Action),
"transformation" => Ok(Self::Transformation),
_ => Err(format!("Invalid Rule Category: {}", value)),
}
}
}

/// Actions that suppress rules should start with this string
pub const SUPPRESSION_ACTION_CATEGORY: &str = "quickfix.suppressRule";

Expand Down
4 changes: 2 additions & 2 deletions crates/pgt_diagnostics/src/location.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ impl Eq for Location<'_> {}
#[derive(Debug, Clone, Copy, Eq, PartialEq, Serialize, Deserialize)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[serde(rename_all = "camelCase")]
pub enum Resource<P> {
pub enum Resource<Path> {
/// The diagnostic is related to the content of the command line arguments.
Argv,
/// The diagnostic is related to the content of a memory buffer.
Memory,
/// The diagnostic is related to a file on the filesystem.
File(P),
File(Path),
}

impl<P> Resource<P> {
Expand Down
18 changes: 18 additions & 0 deletions crates/pgt_suppressions/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

[package]
authors.workspace = true
categories.workspace = true
description = "Provides an API that parses suppressions from SQL files, and provides a way to check if a diagnostic is suppressed."
edition.workspace = true
homepage.workspace = true
keywords.workspace = true
license.workspace = true
name = "pgt_suppressions"
repository.workspace = true
version = "0.0.0"

[dependencies]
pgt_analyse = { workspace = true }
pgt_diagnostics = { workspace = true }
pgt_text_size = { workspace = true }
tracing = { workspace = true }
Loading