Skip to content

Commit 23cb13a

Browse files
authored
Apply clippy suggestions from current stable (#31)
1 parent 66d718e commit 23cb13a

File tree

8 files changed

+29
-54
lines changed

8 files changed

+29
-54
lines changed

.cargo/config renamed to .cargo/config.toml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,11 @@
33
[build]
44

55
rustflags = [
6-
76
"-W", "missing_docs", # detects missing documentation for public members
8-
97
"-W", "trivial_casts", # detects trivial casts which could be removed
10-
118
"-W", "trivial_numeric_casts", # detects trivial casts of numeric types which could be removed
12-
139
"-W", "unsafe_code", # usage of `unsafe` code
14-
1510
"-W", "unused_qualifications", # detects unnecessarily qualified names
16-
1711
"-W", "unused_extern_crates", # extern crates that are never used
18-
1912
"-W", "unused_import_braces", # unnecessary braces around an imported item
20-
21-
]
13+
]

.github/workflows/rust.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,13 @@ env:
1111

1212
jobs:
1313
build:
14-
1514
runs-on: ubuntu-latest
16-
1715
steps:
1816
- uses: actions/checkout@v2
1917
- name: Build (all features)
20-
run: cargo clippy --verbose --all-targets --all-features --all -- -D warnings
18+
run: cargo clippy --verbose --all-targets --all-features --all -- -D warnings -A clippy::duplicated-attributes
2119
- name: Build (no features)
22-
run: cargo clippy --verbose --all-targets --no-default-features --all -- -D warnings
20+
run: cargo clippy --verbose --all-targets --no-default-features --all -- -D warnings -A clippy::duplicated-attributes
2321
- name: Run tests (all features)
2422
run: cargo test --verbose --all --all-features
2523
- name: Run tests (no features)

benches/stats.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ fn gauge_incr_decr_log(bench: &mut Bencher) {
9393
let logger = setup_logger();
9494
bench.iter(|| {
9595
xlog!(logger, FooIncrLog { foo: 42 });
96-
xlog!(logger, FooIncrLog { foo: 27 });
96+
xlog!(logger, FooDecrLog { foo: 27 });
9797
})
9898
}
9999

slog-extlog-derive/src/lib.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,17 @@
4040
//! One `StatTrigger` attribute should be added to the log for each statistic it should update.
4141
//!
4242
//! - `StatName` (mandatory) - The name of the statistic to change, as defined on the
43-
//! corresponding [`StatDefinition`](../slog_extlog/stats/struct.StatDefinition.html).
43+
//! corresponding [`StatDefinition`](../slog_extlog/stats/struct.StatDefinition.html).
4444
//! - `Action` (mandatory) - one of: `Incr`, `Decr`, and `SetVal`, depending on whether this
45-
//! change triggers an increment, decrement, or set to an explicit value.
45+
//! change triggers an increment, decrement, or set to an explicit value.
4646
//! - `Condition` (optional) - A condition, based on the log fields, for this stat to be changed.
47-
//! if not set, the stat is changed on every log. The value of this parameter is an
48-
//! expression that returns a Boolean, and can use `self` for the current log object.
47+
//! if not set, the stat is changed on every log. The value of this parameter is an
48+
//! expression that returns a Boolean, and can use `self` for the current log object.
4949
//! - `Value` or `ValueFrom` - The value to increment/decrement/set. One and only one
50-
//! of these must be provided. `Value` for a fixed number, `ValueFrom` for an arbitrary
51-
//! expression to find the value that may return self.
50+
//! of these must be provided. `Value` for a fixed number, `ValueFrom` for an arbitrary
51+
//! expression to find the value that may return self.
5252
//! - `FixedGroups (optional)` - A comma-separated list of fixed tags to add to this statistic
53-
//! for this trigger - see below.
53+
//! for this trigger - see below.
5454
//!
5555
//! ### Grouped (tagged) statistics)
5656
//! Some statistics may be grouped with *tags*. Tags can be defined in two ways.
@@ -515,12 +515,12 @@ fn impl_ext_loggable(ast: &syn::DeriveInput) -> proc_macro2::TokenStream {
515515
// (which isn't the `to_str` or `to_short_str` name unfortunately).
516516
let (level, text, id) = parse_log_details(log_details);
517517
let level = match level {
518-
slog::Level::Critical => "Critical",
519-
slog::Level::Error => "Error",
520-
slog::Level::Warning => "Warning",
521-
slog::Level::Info => "Info",
522-
slog::Level::Debug => "Debug",
523-
slog::Level::Trace => "Trace",
518+
Level::Critical => "Critical",
519+
Level::Error => "Error",
520+
Level::Warning => "Warning",
521+
Level::Info => "Info",
522+
Level::Debug => "Debug",
523+
Level::Trace => "Trace",
524524
};
525525
let level = syn::Ident::new(level, proc_macro2::Span::call_site());
526526

src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
//! * External logs can be defined using this crate, and then logged using
1616
//! a [`StatisticsLogger`]. They can also be used as triggers for statistics generation.
1717
//! * For internal, low-level logging, the usual slog macros (`info!`, `debug!`, `trace!` etc)
18-
//! can be used.
18+
//! can be used.
1919
//!
2020
//! Any object can be made into an external log by implementing [`ExtLoggable`]. In nearly all
2121
//! cases this trait should be automatically derived using the
@@ -42,6 +42,7 @@
4242
//! You can then call the [`slog_extlog::xlog!()`] macro, passing in the [`StatisticsLogger`] and
4343
//! an instance of your structure, and it will be logged according to the Logger's associated Drain
4444
//! as usual.
45+
//!
4546
//! Structure parameters will be added as key-value pairs, but with the bonus that you get
4647
//! type checking.
4748
//!
@@ -68,7 +69,7 @@
6869
//!
6970
//! - Create a static set of statistic definitions using the [`define_stats`] macro.
7071
//! - Add `StatTrigger` attributes to each external log that explains which statistics
71-
//! the log should update.
72+
//! the log should update.
7273
//!
7374
//! The automatic derivation code then takes care of updating the statistics as and when required.
7475
//!

src/stats.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,18 +87,18 @@ pub trait StatDefinition: fmt::Debug {
8787
///
8888
/// - `StatName` is the externally-facing metric name.
8989
/// - `Type` is the `StatType` of this statistic, for example `Counter`.
90-
/// Must be a valid subtype of that enum.
90+
/// Must be a valid subtype of that enum.
9191
/// - `Description` is a human readable description of the statistic. This will be logged as
92-
/// the log message,
92+
/// the log message,
9393
/// - The list of `tags` define field names to group the statistic by.
94-
/// A non-empty list indicates that this statistic should be split into groups,
95-
/// counting the stat separately for each different value of these fields that is seen.
96-
/// These might be a remote hostname, say, or a tag field.
94+
/// A non-empty list indicates that this statistic should be split into groups,
95+
/// counting the stat separately for each different value of these fields that is seen.
96+
/// These might be a remote hostname, say, or a tag field.
9797
/// - If multiple tags are provided, the stat is counted separately for all distinct
9898
/// combinations of tag values.
9999
/// - Use of this feature should be avoided for fields that can take very many values, such as
100-
/// a subscriber number, or for large numbers of tags - each tag name and seen value adds a
101-
/// performance dip and a small memory overhead that is never freed.
100+
/// a subscriber number, or for large numbers of tags - each tag name and seen value adds a
101+
/// performance dip and a small memory overhead that is never freed.
102102
/// - If the `Type` field is set to `BucketCounter`, then a `BucketMethod`, bucket label and bucket limits must
103103
/// also be provided like so:
104104
///

tests/stats_extlog.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#![cfg(feature = "interval_logging")]
21
//! Extlog tests for Stats tracker.
32
//!
3+
#![cfg(feature = "interval_logging")]
44

55
use slog::{info, o};
66
use slog_extlog::{define_stats, xlog};
@@ -180,8 +180,8 @@ fn log_external_grouped(logger: &StatisticsLogger, name: String, error: u8) {
180180
fn get_stat_logs(stat_name: &str, data: &mut Buffer) -> Vec<serde_json::Value> {
181181
logs_in_range("STATS-1", "STATS-2", data)
182182
.iter()
183-
.cloned()
184183
.filter(|l| l["name"] == stat_name)
184+
.cloned()
185185
.collect()
186186
}
187187

tests/stats_query.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -90,22 +90,6 @@ struct BucketCounterLog {
9090
bucket_value: f32,
9191
}
9292

93-
#[derive(ExtLoggable, Clone, Serialize)]
94-
#[LogDetails(
95-
Id = "5",
96-
Text = "cumulative test bucket counter stat log",
97-
Level = "Info"
98-
)]
99-
#[StatTrigger(
100-
StatName = "test_bucket_counter_cumul_freq",
101-
Action = "Incr",
102-
Value = "2"
103-
)]
104-
struct CumulBucketCounterLog {
105-
#[BucketBy(StatName = "test_bucket_counter_cumul_freq")]
106-
bucket_value: f32,
107-
}
108-
10993
#[derive(ExtLoggable, Clone, Serialize)]
11094
#[LogDetails(
11195
Id = "6",

0 commit comments

Comments
 (0)