Skip to content

Commit

Permalink
lint: add lint for rendudant clones
Browse files Browse the repository at this point in the history
  • Loading branch information
GoranBrkuljan committed Dec 28, 2024
1 parent 0d71325 commit fcf11fa
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 13 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ members = [
"charybdis-macros",
"charybdis-parser",
]

[workspace.lints.clippy]
redundant_clone = "deny"
5 changes: 4 additions & 1 deletion charybdis-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@ quote = "1.0.36"
[dev-dependencies]
charybdis = "0.7.2"
scylla = "0.15.1"
chrono = "0.4.38"
chrono = "0.4.38"

[lints]
workspace = true
3 changes: 3 additions & 0 deletions charybdis-migrate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ path = "src/lib.rs"
[[bin]]
name = "migrate"
path = "src/migrate.rs"

[lints]
workspace = true
2 changes: 1 addition & 1 deletion charybdis-migrate/src/model/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ impl<'a> ModelRunner<'a> {
return None;
}

Some(alter_table_options.to_string())
Some(alter_table_options)
} else {
None
}
Expand Down
3 changes: 3 additions & 0 deletions charybdis-parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ walkdir = "2.5.0"
darling = "0.20.8"
strum = "0.26"
strum_macros = "0.26"

[lints]
workspace = true
2 changes: 1 addition & 1 deletion charybdis-parser/src/fields.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl<'a> Field<'a> {

Field {
name: ident.to_string(),
ident: ident.clone(),
ident,
ty: field.ty.clone(),
ty_path: match &field.ty {
Type::Path(type_path) => type_path.clone(),
Expand Down
13 changes: 4 additions & 9 deletions charybdis-parser/src/schema/code_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,29 +80,24 @@ impl CodeSchema {
let schema_objects: Vec<SchemaObject> = parser::parse_charybdis_model_def(ast, ModelMacro::MaterializedView);

schema_objects.into_iter().for_each(|schema_object| {
let table_name = schema_object.table_name.clone();

self.materialized_views.insert(table_name, schema_object);
self.materialized_views
.insert(schema_object.table_name.clone(), schema_object);
});
}

pub fn populate_udts(&mut self, ast: &syn::File) {
let schema_objects: Vec<SchemaObject> = parser::parse_charybdis_model_def(ast, ModelMacro::Udt);

schema_objects.into_iter().for_each(|schema_object| {
let type_name = schema_object.type_name.to_lowercase().clone();

self.udts.insert(type_name, schema_object);
self.udts.insert(schema_object.type_name.to_lowercase(), schema_object);
});
}

pub fn populate_tables(&mut self, ast: &syn::File) {
let schema_object: Vec<SchemaObject> = parser::parse_charybdis_model_def(ast, ModelMacro::Table);

schema_object.into_iter().for_each(|schema_object| {
let table_name = schema_object.table_name.clone();

self.tables.insert(table_name, schema_object);
self.tables.insert(schema_object.table_name.clone(), schema_object);
});
}
}
2 changes: 1 addition & 1 deletion charybdis-parser/src/schema/db_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ impl DbSchema {
&mut self,
view_name: &String,
session: &Session,
) -> Result<(), DbSchemaParserError> {
) -> Result<(), crate::errors::DbSchemaParserError> {
let cql = r#"
SELECT column_name
FROM system_schema.columns
Expand Down
3 changes: 3 additions & 0 deletions charybdis/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ migrate = ["charybdis-migrate"]

[dev-dependencies]
tokio = "1.42.0"

[lints]
workspace = true

0 comments on commit fcf11fa

Please sign in to comment.