This is an automated email from the ASF dual-hosted git repository.

Kriskras99 pushed a commit to branch chore/fix_lints
in repository https://gitbox.apache.org/repos/asf/avro-rs.git

commit 7a1359375e4e0b8f0df92b2fe4b0509ca6cb7987
Author: Kriskras99 <[email protected]>
AuthorDate: Fri Jun 19 20:36:26 2026 +0200

    chore: Fix some lints and move tests into a `#[cfg(tests)] mod tests` module
---
 Cargo.toml                             |   1 +
 avro/examples/generate_interop_data.rs |   5 +-
 avro/examples/test_interop_data.rs     |   5 +-
 avro/src/decode.rs                     |  30 +++-----
 avro/src/encode.rs                     |   5 +-
 avro/src/schema/mod.rs                 |  12 +--
 avro/src/schema/parser.rs              |   2 +-
 avro/src/serde/de.rs                   |   4 +-
 avro/src/writer/datum.rs               |   4 +-
 avro/tests/append_to_existing.rs       |   2 +-
 avro/tests/shared.rs                   |   2 +-
 avro_derive/src/case.rs                | 131 ++++++++++++++++++---------------
 12 files changed, 102 insertions(+), 101 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml
index 3a56928..9f3097f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -68,3 +68,4 @@ clippy.manual_assert = "warn"
 clippy.enum_glob_use = "warn"
 clippy.needless_pass_by_value = "warn"
 clippy.single_match_else = "warn"
+clippy.uninlined_format_args = "warn"
diff --git a/avro/examples/generate_interop_data.rs 
b/avro/examples/generate_interop_data.rs
index 519b35a..4ae430d 100644
--- a/avro/examples/generate_interop_data.rs
+++ b/avro/examples/generate_interop_data.rs
@@ -78,8 +78,7 @@ fn create_datum(schema: &Schema) -> Record<'_> {
 fn main() -> Result<(), Box<dyn Error>> {
     let interop_root_folder: String = std::env::var("INTEROP_ROOT_FOLDER")?;
     let schema_str = std::fs::read_to_string(format!(
-        "{}/share/test/schemas/interop.avsc",
-        &interop_root_folder
+        "{interop_root_folder}/share/test/schemas/interop.avsc",
     ))
     .expect("Unable to read the interop Avro schema");
     let schema = Schema::parse_str(schema_str.as_str())?;
@@ -94,7 +93,7 @@ fn main() -> Result<(), Box<dyn Error>> {
             format!("_{codec_name}")
         };
 
-        let file_name = format!("{}/rust{suffix}.avro", &data_folder);
+        let file_name = format!("{data_folder}/rust{suffix}.avro");
         let output_file = std::fs::File::create(&file_name)?;
 
         let mut writer = Writer::with_codec(&schema, 
BufWriter::new(output_file), codec)?;
diff --git a/avro/examples/test_interop_data.rs 
b/avro/examples/test_interop_data.rs
index 7833b4f..ff1e500 100644
--- a/avro/examples/test_interop_data.rs
+++ b/avro/examples/test_interop_data.rs
@@ -42,7 +42,7 @@ fn main() -> Result<(), Box<dyn Error>> {
             let ext = path.extension().and_then(OsStr::to_str).unwrap();
 
             if ext == "avro" {
-                println!("Checking {:?}", &path);
+                println!("Checking {path:?}");
                 let content = std::fs::File::open(&path)?;
                 let reader = Reader::new(BufReader::new(&content))?;
 
@@ -51,8 +51,7 @@ fn main() -> Result<(), Box<dyn Error>> {
                 for value in reader {
                     if let Err(e) = value {
                         errors.push(format!(
-                            "There is a problem with reading of '{:?}', \n 
{:?}\n",
-                            &path, e
+                            "There is a problem with reading of '{path:?}', \n 
{e:?}\n"
                         ));
                     }
                 }
diff --git a/avro/src/decode.rs b/avro/src/decode.rs
index cab6797..c4eabf3 100644
--- a/avro/src/decode.rs
+++ b/avro/src/decode.rs
@@ -506,8 +506,7 @@ mod tests {
         assert_eq!(
             outer_value1,
             decode(&schema, &mut bytes).expect(&format!(
-                "Failed to decode using recursive definitions with schema:\n 
{:?}\n",
-                &schema
+                "Failed to decode using recursive definitions with schema:\n 
{schema:?}\n"
             ))
         );
 
@@ -521,8 +520,7 @@ mod tests {
         assert_eq!(
             outer_value2,
             decode(&schema, &mut bytes).expect(&format!(
-                "Failed to decode using recursive definitions with schema:\n 
{:?}\n",
-                &schema
+                "Failed to decode using recursive definitions with schema:\n 
{schema:?}\n"
             ))
         );
 
@@ -571,8 +569,7 @@ mod tests {
         assert_eq!(
             outer_value,
             decode(&schema, &mut bytes).expect(&format!(
-                "Failed to decode using recursive definitions with schema:\n 
{:?}\n",
-                &schema
+                "Failed to decode using recursive definitions with schema:\n 
{schema:?}\n"
             ))
         );
 
@@ -624,8 +621,7 @@ mod tests {
         assert_eq!(
             outer_value,
             decode(&schema, &mut bytes).expect(&format!(
-                "Failed to decode using recursive definitions with schema:\n 
{:?}\n",
-                &schema
+                "Failed to decode using recursive definitions with schema:\n 
{schema:?}\n"
             ))
         );
 
@@ -716,8 +712,7 @@ mod tests {
         assert_eq!(
             outer_record_variation_1,
             decode(&schema, &mut bytes).expect(&format!(
-                "Failed to Decode with recursively defined namespace with 
schema:\n {:?}\n",
-                &schema
+                "Failed to Decode with recursively defined namespace with 
schema:\n {schema:?}\n"
             ))
         );
 
@@ -728,8 +723,7 @@ mod tests {
         assert_eq!(
             outer_record_variation_2,
             decode(&schema, &mut bytes).expect(&format!(
-                "Failed to Decode with recursively defined namespace with 
schema:\n {:?}\n",
-                &schema
+                "Failed to Decode with recursively defined namespace with 
schema:\n {schema:?}\n"
             ))
         );
 
@@ -740,8 +734,7 @@ mod tests {
         assert_eq!(
             outer_record_variation_3,
             decode(&schema, &mut bytes).expect(&format!(
-                "Failed to Decode with recursively defined namespace with 
schema:\n {:?}\n",
-                &schema
+                "Failed to Decode with recursively defined namespace with 
schema:\n {schema:?}\n"
             ))
         );
 
@@ -833,8 +826,7 @@ mod tests {
         assert_eq!(
             outer_record_variation_1,
             decode(&schema, &mut bytes).expect(&format!(
-                "Failed to Decode with recursively defined namespace with 
schema:\n {:?}\n",
-                &schema
+                "Failed to Decode with recursively defined namespace with 
schema:\n {schema:?}\n"
             ))
         );
 
@@ -845,8 +837,7 @@ mod tests {
         assert_eq!(
             outer_record_variation_2,
             decode(&schema, &mut bytes).expect(&format!(
-                "Failed to Decode with recursively defined namespace with 
schema:\n {:?}\n",
-                &schema
+                "Failed to Decode with recursively defined namespace with 
schema:\n {schema:?}\n"
             ))
         );
 
@@ -857,8 +848,7 @@ mod tests {
         assert_eq!(
             outer_record_variation_3,
             decode(&schema, &mut bytes).expect(&format!(
-                "Failed to Decode with recursively defined namespace with 
schema:\n {:?}\n",
-                &schema
+                "Failed to Decode with recursively defined namespace with 
schema:\n {schema:?}\n"
             ))
         );
 
diff --git a/avro/src/encode.rs b/avro/src/encode.rs
index 2c7eb9f..357bdaa 100644
--- a/avro/src/encode.rs
+++ b/avro/src/encode.rs
@@ -381,10 +381,7 @@ pub(crate) mod tests {
     use uuid::Uuid;
 
     pub(crate) fn success(value: &Value, schema: &Schema) -> String {
-        format!(
-            "Value: {:?}\n should encode with schema:\n{:?}",
-            &value, &schema
-        )
+        format!("Value: {value:?}\n should encode with schema:\n{schema:?}")
     }
 
     #[test]
diff --git a/avro/src/schema/mod.rs b/avro/src/schema/mod.rs
index 5985f0e..c7a9cb9 100644
--- a/avro/src/schema/mod.rs
+++ b/avro/src/schema/mod.rs
@@ -4848,13 +4848,13 @@ mod tests {
                             }) => {
                                 assert!(attributes.is_empty());
                             }
-                            _ => panic!("Expected ArraySchema. got: {}", 
&fields[0].schema),
+                            _ => panic!("Expected ArraySchema. got: {}", 
fields[0].schema),
                         }
                     }
-                    _ => panic!("Expected RecordSchema. got: {}", &items),
+                    _ => panic!("Expected RecordSchema. got: {items}"),
                 }
             }
-            _ => panic!("Expected ArraySchema. got: {}", &schema1),
+            _ => panic!("Expected ArraySchema. got: {schema1}"),
         }
         let canonical_form1 = schema1.canonical_form();
         let schema2 = Schema::parse_str(&canonical_form1)?;
@@ -4918,13 +4918,13 @@ mod tests {
                             }) => {
                                 assert!(attributes.is_empty());
                             }
-                            _ => panic!("Expected MapSchema. got: {}", 
&fields[0].schema),
+                            _ => panic!("Expected MapSchema. got: {}", 
fields[0].schema),
                         }
                     }
-                    _ => panic!("Expected RecordSchema. got: {}", &items),
+                    _ => panic!("Expected RecordSchema. got: {items}"),
                 }
             }
-            _ => panic!("Expected ArraySchema. got: {}", &schema1),
+            _ => panic!("Expected ArraySchema. got: {schema1}"),
         }
         let canonical_form1 = schema1.canonical_form();
         let schema2 = Schema::parse_str(&canonical_form1)?;
diff --git a/avro/src/schema/parser.rs b/avro/src/schema/parser.rs
index 678d646..2310e08 100644
--- a/avro/src/schema/parser.rs
+++ b/avro/src/schema/parser.rs
@@ -558,7 +558,7 @@ impl Parser {
 
         self.register_resolving_schema(&fully_qualified_name, &aliases);
 
-        debug!("Going to parse record schema: {:?}", &fully_qualified_name);
+        debug!("Going to parse record schema: {fully_qualified_name:?}");
 
         let fields: Vec<RecordField> = fields_opt
             .and_then(|fields| fields.as_array())
diff --git a/avro/src/serde/de.rs b/avro/src/serde/de.rs
index d4a8792..20e3beb 100644
--- a/avro/src/serde/de.rs
+++ b/avro/src/serde/de.rs
@@ -760,7 +760,7 @@ impl<'de> de::Deserializer<'de> for Deserializer<'de> {
             Value::Record(fields) => 
visitor.visit_map(RecordDeserializer::new(fields)),
             _ => Err(de::Error::custom(format_args!(
                 "Expected a record or a map. Got: {:?}",
-                &self.input
+                self.input
             ))),
         }
     }
@@ -1877,7 +1877,7 @@ mod tests {
 
     #[test]
     fn avro_rs_414_deserialize_char_from_bytes() -> TestResult {
-        let value = Value::Bytes([b'a'].to_vec());
+        let value = Value::Bytes(b"a".to_vec());
         let result = from_value::<char>(&value)?;
         assert_eq!(result, 'a');
 
diff --git a/avro/src/writer/datum.rs b/avro/src/writer/datum.rs
index cdb322a..30804ff 100644
--- a/avro/src/writer/datum.rs
+++ b/avro/src/writer/datum.rs
@@ -279,7 +279,7 @@ mod tests {
         let mut expected = Vec::new();
         zig_i64(27, &mut expected)?;
         zig_i64(3, &mut expected)?;
-        expected.extend([b'f', b'o', b'o']);
+        expected.extend(b"foo");
 
         let written = GenericDatumWriter::builder(&schema)
             .build()?
@@ -308,7 +308,7 @@ mod tests {
         let mut expected = Vec::new();
         zig_i64(27, &mut expected)?;
         zig_i64(3, &mut expected)?;
-        expected.extend([b'f', b'o', b'o']);
+        expected.extend(b"foo");
 
         let bytes = GenericDatumWriter::builder(&schema)
             .build()?
diff --git a/avro/tests/append_to_existing.rs b/avro/tests/append_to_existing.rs
index 571c05c..4e2f79b 100644
--- a/avro/tests/append_to_existing.rs
+++ b/avro/tests/append_to_existing.rs
@@ -102,7 +102,7 @@ fn check(value: &AvroResult<Value>, expected: i32) {
         Ok(value) => match value {
             Value::Record(fields) => match &fields[0] {
                 (_, Value::Int(actual)) => assert_eq!(&expected, actual),
-                _ => panic!("The field value type must be an Int: {:?}!", 
&fields[0]),
+                _ => panic!("The field value type must be an Int: {:?}!", 
fields[0]),
             },
             _ => panic!("The value type must be a Record: {value:?}!"),
         },
diff --git a/avro/tests/shared.rs b/avro/tests/shared.rs
index 37bec84..022f147 100644
--- a/avro/tests/shared.rs
+++ b/avro/tests/shared.rs
@@ -41,7 +41,7 @@ fn test_schema() -> TestResult {
     for f in directory {
         let entry: DirEntry = match f {
             Ok(entry) => entry,
-            Err(e) => core::panic!("Can't get file {}", e),
+            Err(e) => core::panic!("Can't get file {e}"),
         };
         log::debug!("{:?}", entry.file_name());
         if let Ok(ft) = entry.file_type()
diff --git a/avro_derive/src/case.rs b/avro_derive/src/case.rs
index 9f8eff9..7612f59 100644
--- a/avro_derive/src/case.rs
+++ b/avro_derive/src/case.rs
@@ -159,65 +159,80 @@ impl Display for ParseError {
     }
 }
 
-#[test]
-fn rename_variants() {
-    for &(original, lower, upper, camel, snake, screaming, kebab, 
screaming_kebab) in &[
-        (
-            "Outcome", "outcome", "OUTCOME", "outcome", "outcome", "OUTCOME", 
"outcome", "OUTCOME",
-        ),
-        (
-            "VeryTasty",
-            "verytasty",
-            "VERYTASTY",
-            "veryTasty",
-            "very_tasty",
-            "VERY_TASTY",
-            "very-tasty",
-            "VERY-TASTY",
-        ),
-        ("A", "a", "A", "a", "a", "A", "a", "A"),
-        ("Z42", "z42", "Z42", "z42", "z42", "Z42", "z42", "Z42"),
-    ] {
-        assert_eq!(None.apply_to_variant(original), original);
-        assert_eq!(LowerCase.apply_to_variant(original), lower);
-        assert_eq!(UpperCase.apply_to_variant(original), upper);
-        assert_eq!(PascalCase.apply_to_variant(original), original);
-        assert_eq!(CamelCase.apply_to_variant(original), camel);
-        assert_eq!(SnakeCase.apply_to_variant(original), snake);
-        assert_eq!(ScreamingSnakeCase.apply_to_variant(original), screaming);
-        assert_eq!(KebabCase.apply_to_variant(original), kebab);
-        assert_eq!(
-            ScreamingKebabCase.apply_to_variant(original),
-            screaming_kebab
-        );
+#[cfg(test)]
+mod tests {
+    use crate::case::RenameRule::{
+        CamelCase, KebabCase, LowerCase, PascalCase, ScreamingKebabCase, 
ScreamingSnakeCase,
+        SnakeCase, UpperCase,
+    };
+
+    #[test]
+    fn rename_variants() {
+        for &(original, lower, upper, camel, snake, screaming, kebab, 
screaming_kebab) in &[
+            (
+                "Outcome", "outcome", "OUTCOME", "outcome", "outcome", 
"OUTCOME", "outcome",
+                "OUTCOME",
+            ),
+            (
+                "VeryTasty",
+                "verytasty",
+                "VERYTASTY",
+                "veryTasty",
+                "very_tasty",
+                "VERY_TASTY",
+                "very-tasty",
+                "VERY-TASTY",
+            ),
+            ("A", "a", "A", "a", "a", "A", "a", "A"),
+            ("Z42", "z42", "Z42", "z42", "z42", "Z42", "z42", "Z42"),
+        ] {
+            assert_eq!(
+                crate::case::RenameRule::None.apply_to_variant(original),
+                original
+            );
+            assert_eq!(LowerCase.apply_to_variant(original), lower);
+            assert_eq!(UpperCase.apply_to_variant(original), upper);
+            assert_eq!(PascalCase.apply_to_variant(original), original);
+            assert_eq!(CamelCase.apply_to_variant(original), camel);
+            assert_eq!(SnakeCase.apply_to_variant(original), snake);
+            assert_eq!(ScreamingSnakeCase.apply_to_variant(original), 
screaming);
+            assert_eq!(KebabCase.apply_to_variant(original), kebab);
+            assert_eq!(
+                ScreamingKebabCase.apply_to_variant(original),
+                screaming_kebab
+            );
+        }
     }
-}
 
-#[test]
-fn rename_fields() {
-    for &(original, upper, pascal, camel, screaming, kebab, screaming_kebab) 
in &[
-        (
-            "outcome", "OUTCOME", "Outcome", "outcome", "OUTCOME", "outcome", 
"OUTCOME",
-        ),
-        (
-            "very_tasty",
-            "VERY_TASTY",
-            "VeryTasty",
-            "veryTasty",
-            "VERY_TASTY",
-            "very-tasty",
-            "VERY-TASTY",
-        ),
-        ("a", "A", "A", "a", "A", "a", "A"),
-        ("z42", "Z42", "Z42", "z42", "Z42", "z42", "Z42"),
-    ] {
-        assert_eq!(None.apply_to_field(original), original);
-        assert_eq!(UpperCase.apply_to_field(original), upper);
-        assert_eq!(PascalCase.apply_to_field(original), pascal);
-        assert_eq!(CamelCase.apply_to_field(original), camel);
-        assert_eq!(SnakeCase.apply_to_field(original), original);
-        assert_eq!(ScreamingSnakeCase.apply_to_field(original), screaming);
-        assert_eq!(KebabCase.apply_to_field(original), kebab);
-        assert_eq!(ScreamingKebabCase.apply_to_field(original), 
screaming_kebab);
+    #[test]
+    fn rename_fields() {
+        for &(original, upper, pascal, camel, screaming, kebab, 
screaming_kebab) in &[
+            (
+                "outcome", "OUTCOME", "Outcome", "outcome", "OUTCOME", 
"outcome", "OUTCOME",
+            ),
+            (
+                "very_tasty",
+                "VERY_TASTY",
+                "VeryTasty",
+                "veryTasty",
+                "VERY_TASTY",
+                "very-tasty",
+                "VERY-TASTY",
+            ),
+            ("a", "A", "A", "a", "A", "a", "A"),
+            ("z42", "Z42", "Z42", "z42", "Z42", "z42", "Z42"),
+        ] {
+            assert_eq!(
+                crate::case::RenameRule::None.apply_to_field(original),
+                original
+            );
+            assert_eq!(UpperCase.apply_to_field(original), upper);
+            assert_eq!(PascalCase.apply_to_field(original), pascal);
+            assert_eq!(CamelCase.apply_to_field(original), camel);
+            assert_eq!(SnakeCase.apply_to_field(original), original);
+            assert_eq!(ScreamingSnakeCase.apply_to_field(original), screaming);
+            assert_eq!(KebabCase.apply_to_field(original), kebab);
+            assert_eq!(ScreamingKebabCase.apply_to_field(original), 
screaming_kebab);
+        }
     }
 }

Reply via email to