Skip to content

Commit 40d39a8

Browse files
authored
fix(ci): clippy complaints for the 1.46.0 release (#63)
I'm not sure how CI passed previously, it didn't report any errors with linting but opening another PR resulted in lint failures.
1 parent 9d455a6 commit 40d39a8

18 files changed

+40
-17
lines changed

cli/src/reporter.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,26 @@ arg_enum! {
3030

3131
#[derive(Debug)]
3232
pub enum DumpAstError {
33-
PGQueryError(PGQueryError),
34-
IoError(std::io::Error),
35-
JsonError(serde_json::error::Error),
33+
PGQuery(PGQueryError),
34+
Io(std::io::Error),
35+
Json(serde_json::error::Error),
3636
}
3737

3838
impl std::convert::From<PGQueryError> for DumpAstError {
3939
fn from(e: PGQueryError) -> Self {
40-
Self::PGQueryError(e)
40+
Self::PGQuery(e)
4141
}
4242
}
4343

4444
impl std::convert::From<std::io::Error> for DumpAstError {
4545
fn from(e: std::io::Error) -> Self {
46-
Self::IoError(e)
46+
Self::Io(e)
4747
}
4848
}
4949

5050
impl std::convert::From<serde_json::error::Error> for DumpAstError {
5151
fn from(e: serde_json::error::Error) -> Self {
52-
Self::JsonError(e)
52+
Self::Json(e)
5353
}
5454
}
5555

linter/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(clippy::shadow_unrelated)]
2+
#![allow(clippy::missing_errors_doc)]
13
pub mod errors;
24
pub mod rules;
35
pub mod violations;
@@ -221,7 +223,7 @@ pub fn check_sql(
221223
mod test_rules {
222224
use super::*;
223225

224-
/// Ensure we handle both serializing and deserializing RuleViolationKind
226+
/// Ensure we handle both serializing and deserializing `RuleViolationKind`
225227
#[test]
226228
fn test_parsing_rule_kind() {
227229
let rule_names = RULES.iter().map(|r| r.name.clone());
@@ -243,7 +245,7 @@ mod test_rules {
243245

244246
let res = check_sql(sql, &["prefer-robust-stmts".into()]).expect("valid parsing of SQL");
245247
let mut prev_span_start = -1;
246-
for violation in res.iter() {
248+
for violation in &res {
247249
assert!(violation.span.start > prev_span_start);
248250
prev_span_start = violation.span.start;
249251
}

linter/src/rules/adding_field_with_default.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use squawk_parser::ast::{
33
AlterTableCmds, AlterTableDef, ColumnDefConstraint, ConstrType, RootStmt, Stmt,
44
};
55

6+
#[must_use]
67
pub fn adding_field_with_default(tree: &[RootStmt]) -> Vec<RuleViolation> {
78
let mut errs = vec![];
89
for RootStmt::RawStmt(raw_stmt) in tree {

linter/src/rules/adding_not_null_field.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use squawk_parser::ast::{
33
AlterTableCmds, AlterTableDef, AlterTableType, ColumnDefConstraint, ConstrType, RootStmt, Stmt,
44
};
55

6+
#[must_use]
67
pub fn adding_not_nullable_field(tree: &[RootStmt]) -> Vec<RuleViolation> {
78
let mut errs = vec![];
89
for RootStmt::RawStmt(raw_stmt) in tree {

linter/src/rules/bad_drop_database.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use crate::violations::{RuleViolation, RuleViolationKind};
22
use squawk_parser::ast::{RootStmt, Stmt};
33

44
/// Brad's Rule aka ban dropping database statements.
5+
#[must_use]
56
pub fn ban_drop_database(tree: &[RootStmt]) -> Vec<RuleViolation> {
67
let mut errs = vec![];
78
for RootStmt::RawStmt(raw_stmt) in tree {

linter/src/rules/ban_char_field.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::violations::{RuleViolation, RuleViolationKind};
22
use squawk_parser::ast::{ColumnDefTypeName, QualifiedName, RootStmt, Stmt, TableElt};
33

4+
#[must_use]
45
pub fn ban_char_type(tree: &[RootStmt]) -> Vec<RuleViolation> {
56
let mut errs = vec![];
67
for RootStmt::RawStmt(raw_stmt) in tree {

linter/src/rules/changing_column_type.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::violations::{RuleViolation, RuleViolationKind};
22
use squawk_parser::ast::{AlterTableCmds, AlterTableType, RootStmt, Stmt};
33

4+
#[must_use]
45
pub fn changing_column_type(tree: &[RootStmt]) -> Vec<RuleViolation> {
56
let mut errs = vec![];
67
for RootStmt::RawStmt(raw_stmt) in tree {

linter/src/rules/constraint_missing_not_valid.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use crate::rules::utils::tables_created_in_transaction;
22
use crate::violations::{RuleViolation, RuleViolationKind};
33
use squawk_parser::ast::{AlterTableCmds, AlterTableDef, RelationKind, RootStmt, Stmt};
44

5+
#[must_use]
56
pub fn constraint_missing_not_valid(tree: &[RootStmt]) -> Vec<RuleViolation> {
67
let mut errs = vec![];
78
let tables_created = tables_created_in_transaction(tree);

linter/src/rules/disallow_unique_constraint.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use crate::rules::utils::tables_created_in_transaction;
22
use crate::violations::{RuleViolation, RuleViolationKind};
33
use squawk_parser::ast::{AlterTableCmds, AlterTableDef, ConstrType, RelationKind, RootStmt, Stmt};
44

5+
#[must_use]
56
pub fn disallow_unique_constraint(tree: &[RootStmt]) -> Vec<RuleViolation> {
67
let tables_created = tables_created_in_transaction(tree);
78
let mut errs = vec![];

linter/src/rules/prefer_robust_stmts.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use squawk_parser::ast::{AlterTableCmds, RootStmt, Stmt, TransactionStmtKind};
77
/// when we CREATE INDEX CONCURRENTLY, we should try and make those migrations
88
/// more robust by using guards like `IF NOT EXISTS`. So if the migration fails
99
/// halfway through, it can be rerun without human intervention.
10+
#[must_use]
1011
pub fn prefer_robust_stmts(tree: &[RootStmt]) -> Vec<RuleViolation> {
1112
let mut errs = vec![];
1213
let mut inside_transaction = false;

linter/src/rules/prefer_text_field.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use squawk_parser::ast::{ColumnDefTypeName, QualifiedName, RootStmt, Stmt, Table
44
/// It's easier to update the check constraint on a text field than a varchar()
55
/// size since the check constraint can use NOT VALID with a separate VALIDATE
66
/// call.
7+
#[must_use]
78
pub fn prefer_text_field(tree: &[RootStmt]) -> Vec<RuleViolation> {
89
let mut errs = vec![];
910
for RootStmt::RawStmt(raw_stmt) in tree {

linter/src/rules/renaming_column.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::violations::{RuleViolation, RuleViolationKind};
22
use squawk_parser::ast::{ObjectType, RootStmt, Stmt};
33

4+
#[must_use]
45
pub fn renaming_column(tree: &[RootStmt]) -> Vec<RuleViolation> {
56
let mut errs = vec![];
67
for RootStmt::RawStmt(raw_stmt) in tree {

linter/src/rules/renaming_table.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::violations::{RuleViolation, RuleViolationKind};
22
use squawk_parser::ast::{ObjectType, RootStmt, Stmt};
33

4+
#[must_use]
45
pub fn renaming_table(tree: &[RootStmt]) -> Vec<RuleViolation> {
56
let mut errs = vec![];
67
for RootStmt::RawStmt(raw_stmt) in tree {

linter/src/rules/require_concurrent_index_creation.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use crate::rules::utils::tables_created_in_transaction;
22
use crate::violations::{RuleViolation, RuleViolationKind};
33
use squawk_parser::ast::{RelationKind, RootStmt, Stmt};
44

5+
#[must_use]
56
pub fn require_concurrent_index_creation(tree: &[RootStmt]) -> Vec<RuleViolation> {
67
let tables_created = tables_created_in_transaction(tree);
78
let mut errs = vec![];

linter/src/violations.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ pub struct RuleViolation {
7979
}
8080

8181
impl RuleViolation {
82+
#[must_use]
8283
pub fn new(
8384
kind: RuleViolationKind,
8485
node: &RawStmt,

parser/src/ast.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -494,16 +494,16 @@ pub enum QualifiedName {
494494
}
495495

496496
///
497-
/// TypeName - specifies a type in definitions
497+
/// `TypeName` - specifies a type in definitions
498498
///
499-
/// For TypeName structures generated internally, it is often easier to
500-
/// specify the type by OID than by name. If "names" is NIL then the
501-
/// actual type OID is given by typeOid, otherwise typeOid is unused.
502-
/// Similarly, if "typmods" is NIL then the actual typmod is expected to
499+
/// For `TypeName` structures generated internally, it is often easier to
500+
/// specify the type by OID than by name. If `names` is NIL then the
501+
/// actual type OID is given by `type_oid`, otherwise `type_oid` is unused.
502+
/// Similarly, if `typmods` is NIL then the actual typmod is expected to
503503
/// be prespecified in typemod, otherwise typemod is unused.
504504
///
505-
/// If pct_type is true, then names is actually a field name and we look up
506-
/// the type of that field. Otherwise (the normal case), names is a type
505+
/// If `pct_type` is true, then `names` is actually a field name and we look up
506+
/// the type of that field. Otherwise (the normal case), `names` is a type
507507
/// name possibly qualified with schema and database name.
508508
///
509509
#[derive(Debug, Deserialize, Serialize)]
@@ -734,7 +734,7 @@ pub enum RootStmt {
734734
}
735735

736736
/// case for each node type found in Postgres' parsenodes.h
737-
/// https://github.com/lfittl/libpg_query/blob/6b1c3a582d38701593c5cadd260445737b9f7043/src/postgres/include/nodes/parsenodes.h
737+
/// <https://github.com/lfittl/libpg_query/blob/6b1c3a582d38701593c5cadd260445737b9f7043/src/postgres/include/nodes/parsenodes.h>
738738
#[allow(clippy::large_enum_variant)]
739739
#[derive(Debug, Deserialize, Serialize)]
740740
pub enum Stmt {

parser/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
#[allow(clippy::module_name_repetitions)]
2+
#[allow(clippy::pub_enum_variant_names)]
3+
#[allow(clippy::struct_excessive_bools)]
14
pub mod ast;
5+
#[allow(clippy::module_name_repetitions)]
26
pub mod error;
7+
#[allow(clippy::module_name_repetitions)]
8+
#[allow(clippy::shadow_unrelated)]
9+
#[allow(clippy::doc_markdown)]
10+
#[allow(clippy::missing_errors_doc)]
311
pub mod parse;

parser/src/parse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ fn c_ptr_to_string(str_ptr: *mut ::std::os::raw::c_char) -> Option<String> {
1212
unsafe { CStr::from_ptr(str_ptr) }
1313
.to_str()
1414
.ok()
15-
.map(|s| s.to_owned())
15+
.map(ToOwned::to_owned)
1616
}
1717
}
1818

0 commit comments

Comments
 (0)