Skip to content

Commit

Permalink
chore: add explicit naming to layout rules
Browse files Browse the repository at this point in the history
  • Loading branch information
gvozdvmozgu authored and benfdking committed Mar 1, 2024
1 parent 5c9ab56 commit 2dd32d9
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 0 deletions.
4 changes: 4 additions & 0 deletions crates/lib/src/rules/layout/LT02.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ use crate::utils::reflow::sequence::ReflowSequence;
pub struct RuleLT02 {}

impl Rule for RuleLT02 {
fn name(&self) -> &'static str {
"layout.indent"
}

fn crawl_behaviour(&self) -> Crawler {
RootOnlyCrawler::default().into()
}
Expand Down
4 changes: 4 additions & 0 deletions crates/lib/src/rules/layout/LT03.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ use crate::utils::reflow::sequence::ReflowSequence;
pub struct RuleLT03 {}

impl Rule for RuleLT03 {
fn name(&self) -> &'static str {
"layout.operators"
}

fn crawl_behaviour(&self) -> Crawler {
SegmentSeekerCrawler::new(HashSet::from(["binary_operator", "comparison_operator"])).into()
}
Expand Down
4 changes: 4 additions & 0 deletions crates/lib/src/rules/layout/LT04.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ pub struct RuleLT04 {
}

impl Rule for RuleLT04 {
fn name(&self) -> &'static str {
"layout.commas"
}

fn crawl_behaviour(&self) -> Crawler {
SegmentSeekerCrawler::new(HashSet::from(["comma".into()])).into()
}
Expand Down
4 changes: 4 additions & 0 deletions crates/lib/src/rules/layout/LT05.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ pub struct RuleLT05 {
}

impl Rule for RuleLT05 {
fn name(&self) -> &'static str {
"layout.long_lines"
}

fn crawl_behaviour(&self) -> Crawler {
RootOnlyCrawler::default().into()
}
Expand Down
4 changes: 4 additions & 0 deletions crates/lib/src/rules/layout/LT06.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ use crate::utils::functional::context::FunctionalContext;
pub struct RuleLT06 {}

impl Rule for RuleLT06 {
fn name(&self) -> &'static str {
"layout.functions"
}

fn description(&self) -> &'static str {
"Function name not immediately followed by parenthesis."
}
Expand Down
4 changes: 4 additions & 0 deletions crates/lib/src/rules/layout/LT07.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ use crate::utils::functional::context::FunctionalContext;
pub struct RuleLT07 {}

impl Rule for RuleLT07 {
fn name(&self) -> &'static str {
"layout.cte_bracket"
}

fn crawl_behaviour(&self) -> Crawler {
SegmentSeekerCrawler::new(HashSet::from(["with_compound_statement"])).into()
}
Expand Down
4 changes: 4 additions & 0 deletions crates/lib/src/rules/layout/LT08.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ use crate::core::rules::crawlers::{Crawler, SegmentSeekerCrawler};
pub struct RuleLT08 {}

impl Rule for RuleLT08 {
fn name(&self) -> &'static str {
"layout.cte_newline"
}

fn crawl_behaviour(&self) -> Crawler {
SegmentSeekerCrawler::new(HashSet::from(["with_compound_statement"])).into()
}
Expand Down
4 changes: 4 additions & 0 deletions crates/lib/src/rules/layout/LT10.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ use crate::utils::functional::context::FunctionalContext;
pub struct RuleLT10 {}

impl Rule for RuleLT10 {
fn name(&self) -> &'static str {
"layout.select_modifiers"
}

fn crawl_behaviour(&self) -> Crawler {
SegmentSeekerCrawler::new(HashSet::from(["select_clause"])).into()
}
Expand Down
4 changes: 4 additions & 0 deletions crates/lib/src/rules/layout/LT11.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ use crate::utils::reflow::sequence::ReflowSequence;
pub struct RuleLT11;

impl Rule for RuleLT11 {
fn name(&self) -> &'static str {
"layout.set_operators"
}

fn crawl_behaviour(&self) -> Crawler {
SegmentSeekerCrawler::new(HashSet::from(["set_operator"])).into()
}
Expand Down
4 changes: 4 additions & 0 deletions crates/lib/src/rules/layout/LT13.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ use crate::utils::functional::segments::Segments;
pub struct RuleLT13 {}

impl Rule for RuleLT13 {
fn name(&self) -> &'static str {
"layout.start_of_file"
}

fn description(&self) -> &'static str {
"Files must not begin with newlines or whitespace."
}
Expand Down

0 comments on commit 2dd32d9

Please sign in to comment.