Skip to content
Merged
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
2 changes: 2 additions & 0 deletions Cargo.lock

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

58 changes: 58 additions & 0 deletions crates/pgls_configuration/src/analyser/splinter/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
mod rules;

use biome_deserialize::StringSet;
use biome_deserialize_macros::{Merge, Partial};
use bpaf::Bpaf;
pub use rules::*;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, Deserialize, Eq, Partial, PartialEq, Serialize)]
#[partial(derive(Bpaf, Clone, Eq, Merge, PartialEq))]
#[partial(cfg_attr(feature = "schema", derive(schemars::JsonSchema)))]
#[partial(serde(rename_all = "camelCase", default, deny_unknown_fields))]
pub struct SplinterConfiguration {
/// if `false`, it disables the feature and the splinter won't be executed. `true` by default
#[partial(bpaf(hide))]
pub enabled: bool,

/// List of rules
#[partial(bpaf(pure(Default::default()), optional, hide))]
pub rules: Rules,

/// A list of Unix shell style patterns. The splinter will ignore files/folders that will
/// match these patterns.
#[partial(bpaf(hide))]
pub ignore: StringSet,

/// A list of Unix shell style patterns. The splinter will include files/folders that will
/// match these patterns.
#[partial(bpaf(hide))]
pub include: StringSet,
}

impl SplinterConfiguration {
pub const fn is_disabled(&self) -> bool {
!self.enabled
}
}

impl Default for SplinterConfiguration {
fn default() -> Self {
Self {
enabled: true,
rules: Default::default(),
ignore: Default::default(),
include: Default::default(),
}
}
}

impl PartialSplinterConfiguration {
pub const fn is_disabled(&self) -> bool {
matches!(self.enabled, Some(false))
}

pub fn get_rules(&self) -> Rules {
self.rules.clone().unwrap_or_default()
}
}
Loading