diff --git a/Cargo.toml b/Cargo.toml index 5bd9ce7..b52a2e9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,3 +28,74 @@ opentelemetry-datadog = { version = "0.10.0", features = ["reqwest-client"] } opentelemetry_sdk = "0.22.1" regex = "1.10.3" smoothy = "0.4.4" + +[lints.rust] +missing_docs = "deny" + +[lints.rustdoc] +broken_intra_doc_links = "deny" +private_intra_doc_links = "deny" +private_doc_tests = "warn" +invalid_codeblock_attributes = "deny" +invalid_html_tags = "deny" +invalid_rust_codeblocks = "deny" +bare_urls = "deny" +unescaped_backticks = "deny" +redundant_explicit_links = "deny" + +[lints.clippy] +# enable more lint groups +pedantic = { level = "deny", priority = -1 } +nursery = { level = "deny", priority = -1 } +# enable extra restriction lints +as_conversions = "deny" +as_underscore = "deny" +clone_on_ref_ptr = "deny" +dbg_macro = "deny" +deref_by_slicing = "deny" +else_if_without_else = "deny" +empty_drop = "deny" +empty_structs_with_brackets = "deny" +error_impl_error = "deny" +expect_used = "deny" +panic = "deny" +todo = "deny" +try_err = "deny" +unimplemented = "deny" +unreachable = "deny" +unwrap_in_result = "deny" +unwrap_used = "deny" +format_push_string = "deny" +if_then_some_else_none = "deny" +indexing_slicing = "deny" +integer_division = "deny" +let_underscore_must_use = "deny" +let_underscore_untyped = "deny" +mem_forget = "deny" +missing_assert_message = "deny" +mod_module_files = "deny" +mixed_read_write_in_expression = "deny" +multiple_inherent_impl = "deny" +needless_raw_strings = "deny" +print_stderr = "deny" +print_stdout = "deny" +pub_without_shorthand = "deny" +same_name_method = "deny" +semicolon_outside_block = "deny" +shadow_reuse = "deny" +string_add = "deny" +string_slice = "deny" +string_to_string = "deny" +unnecessary_self_imports = "deny" +unneeded_field_pattern = "deny" +wildcard_enum_match_arm = "deny" +missing_errors_doc = "deny" +missing_panics_doc = "deny" +ignored_unit_patterns = "deny" +doc_markdown = "deny" +needless_pass_by_value = "deny" +redundant_pub_crate = "deny" +# allow some lints +module_name_repetitions = "allow" +tests_outside_test_module = "allow" + diff --git a/clippy.toml b/clippy.toml new file mode 100644 index 0000000..0358cdb --- /dev/null +++ b/clippy.toml @@ -0,0 +1,2 @@ +allow-unwrap-in-tests = true +allow-expect-in-tests = true diff --git a/src/formatting.rs b/src/formatting.rs index f8821b7..aae925e 100644 --- a/src/formatting.rs +++ b/src/formatting.rs @@ -4,6 +4,7 @@ use crate::{ }; use chrono::{DateTime, Utc}; use serde_json::{Map, Value}; +use std::fmt::Write; use tracing::Level; /// All the data required to create a Datadog-compatible log @@ -33,7 +34,7 @@ impl DatadogLog { if field.name != "message" { let value = field.value.trim_matches('\"'); - message.push_str(&format!(" {}={}", field.name, value)); + write!(message, " {}={}", field.name, value).expect("Failed to write to message"); log.insert(format!("fields.{}", &field.name), value.into()); } } diff --git a/src/lib.rs b/src/lib.rs index c1b94e5..ada8e36 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,36 +1,4 @@ #![doc = include_str!("../README.md")] -#![deny( - rust_2018_idioms, - unused_must_use, - clippy::nursery, - clippy::pedantic, - clippy::perf, - clippy::cargo, - clippy::correctness, - clippy::dbg_macro, - clippy::else_if_without_else, - clippy::empty_drop, - clippy::empty_structs_with_brackets, - clippy::expect_used, - clippy::if_then_some_else_none, - clippy::indexing_slicing, - clippy::integer_division, - clippy::multiple_inherent_impl, - clippy::panic, - clippy::print_stderr, - clippy::print_stdout, - clippy::same_name_method, - clippy::string_to_string, - clippy::todo, - clippy::try_err, - clippy::unimplemented, - clippy::unnecessary_self_imports, - clippy::unreachable, - clippy::unwrap_used, - clippy::wildcard_enum_match_arm, - missing_docs -)] -#![allow(clippy::module_name_repetitions)] // Disable certain lints in tests #![cfg_attr( test, @@ -38,7 +6,8 @@ clippy::pedantic, clippy::as_conversions, clippy::indexing_slicing, - clippy::unwrap_used + clippy::unwrap_used, + clippy::unwrap_in_result ) )] diff --git a/tests/otel.rs b/tests/otel.rs index 3f15e3a..15865ee 100644 --- a/tests/otel.rs +++ b/tests/otel.rs @@ -38,13 +38,13 @@ fn works_with_otel_stack() { #[instrument(fields(hello = "world"))] fn some_test(value: &str) { info!(ola = "salve", value, "Bla {value}"); - some_test1() + some_test1(); } #[instrument(fields(world = "world"))] fn some_test1() { debug!(ola = "salve", "Hello"); - some_test2() + some_test2(); } #[instrument()] diff --git a/tests/simple.rs b/tests/simple.rs index 71a145a..fc535ba 100644 --- a/tests/simple.rs +++ b/tests/simple.rs @@ -15,13 +15,13 @@ fn works() { #[instrument(fields(hello = "world"))] fn some_test(value: &str) { info!(ola = "salve", value, "Bla {value}"); - some_test1() + some_test1(); } #[instrument(fields(world = "world"))] fn some_test1() { debug!(ola = "salve", "Hello"); - some_test2() + some_test2(); } #[instrument()]