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
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ See [the README's dev section](./README.md#dev) for development information.

## Adding new rules

When adding a new rule, the `s/new-rule` script will create stubs for your rule in Rust and in Documentation site.
When adding a new rule, running `cargo xtask new-rule` will create stubs for your rule in the Rust crate and in Documentation site.

```bash
s/new-rule 'prefer big serial'
cargo xtask new-rule 'prefer big serial'
```
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,10 @@ $ nix develop

### Adding a New Rule

When adding a new rule, the `s/new-rule` script will create stubs for your rule in Rust and in Documentation site.
When adding a new rule, running `cargo xtask new-rule` will create stubs for your rule in the Rust crate and in Documentation site.

```bash
s/new-rule 'prefer big serial'
cargo xtask new-rule 'prefer big serial'
```

### Releasing a New Version
Expand Down
9 changes: 5 additions & 4 deletions crates/squawk_linter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ use rules::renaming_table;
use rules::require_concurrent_index_creation;
use rules::require_concurrent_index_deletion;
use rules::transaction_nesting;
// xtask:new-lint:rule-import
// xtask:new-rule:rule-import

#[derive(Debug, PartialEq, Clone, Copy, Serialize, Hash, Eq, Deserialize, Sequence)]
pub enum Rule {
Expand Down Expand Up @@ -108,7 +108,7 @@ pub enum Rule {
BanCreateDomainWithConstraint,
#[serde(rename = "ban-alter-domain-with-add-constraint")]
BanAlterDomainWithAddConstraint,
// xtask:new-lint:error-name
// xtask:new-rule:error-name
}

impl TryFrom<&str> for Rule {
Expand Down Expand Up @@ -145,7 +145,7 @@ impl TryFrom<&str> for Rule {
}
"ban-create-domain-with-constraint" => Ok(Rule::BanCreateDomainWithConstraint),
"ban-alter-domain-with-add-constraint" => Ok(Rule::BanAlterDomainWithAddConstraint),
// xtask:new-lint:str-name
// xtask:new-rule:str-name
_ => Err(format!("Unknown violation name: {}", s)),
}
}
Expand Down Expand Up @@ -202,6 +202,7 @@ impl fmt::Display for Rule {
Rule::BanCreateDomainWithConstraint => "ban-create-domain-with-constraint",
Rule::UnusedIgnore => "unused-ignore",
Rule::BanAlterDomainWithAddConstraint => "ban-alter-domain-with-add-constraint",
// xtask:new-rule:variant-to-name
};
write!(f, "{}", val)
}
Expand Down Expand Up @@ -344,7 +345,7 @@ impl Linter {
if self.rules.contains(&Rule::TransactionNesting) {
transaction_nesting(self, &file);
}
// xtask:new-lint:rule-call
// xtask:new-rule:rule-call

// locate any ignores in the file
find_ignores(self, &file.syntax_node());
Expand Down
4 changes: 2 additions & 2 deletions crates/squawk_linter/src/rules/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub(crate) mod renaming_table;
pub(crate) mod require_concurrent_index_creation;
pub(crate) mod require_concurrent_index_deletion;
pub(crate) mod transaction_nesting;
// xtask:new-lint:mod-decl
// xtask:new-rule:mod-decl

pub(crate) use adding_field_with_default::adding_field_with_default;
pub(crate) use adding_foreign_key_constraint::adding_foreign_key_constraint;
Expand Down Expand Up @@ -54,4 +54,4 @@ pub(crate) use renaming_table::renaming_table;
pub(crate) use require_concurrent_index_creation::require_concurrent_index_creation;
pub(crate) use require_concurrent_index_deletion::require_concurrent_index_deletion;
pub(crate) use transaction_nesting::transaction_nesting;
// xtask:new-lint:export
// xtask:new-rule:export
10 changes: 5 additions & 5 deletions crates/xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ use anyhow::Result;
// see: https://github.com/matklad/cargo-xtask
use clap::{arg, Args, Parser, Subcommand};
use generate_keywords::generate_keywords;
use new_lint::new_lint;
use new_rule::new_lint;
use sync_kwlist::sync_kwlist;

mod generate_keywords;
mod new_lint;
mod new_rule;
mod path_util;
mod sync_kwlist;

Expand All @@ -17,11 +17,11 @@ enum TaskName {
#[command(long_about = "Fetch the latest version of kwlist.h from Postgres")]
SyncKwlist,
#[command(long_about = "Create a new linter rule")]
NewLint(NewLintArgs),
NewRule(NewRuleArgs),
}

#[derive(Args, Debug)]
struct NewLintArgs {
struct NewRuleArgs {
#[arg(required = true)]
name: String,
}
Expand All @@ -39,6 +39,6 @@ fn main() -> Result<()> {
match args.task {
TaskName::GenerateKeywords => generate_keywords(),
TaskName::SyncKwlist => sync_kwlist(),
TaskName::NewLint(args) => new_lint(args),
TaskName::NewRule(args) => new_lint(args),
}
}
202 changes: 0 additions & 202 deletions crates/xtask/src/new_lint.rs

This file was deleted.

Loading
Loading