Skip to content

Commit 3e88c13

Browse files
authored
Clippy suggestions (#65)
* add embark lints to config * add minimum supported version 1.88 due to `if let` chains * cargo clippy fixes
1 parent 8e0d1f9 commit 3e88c13

19 files changed

Lines changed: 539 additions & 501 deletions

.cargo/config.toml

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,83 @@
11
[alias]
2-
test_ip = "test --test ipv4_tests -- --ignored --test-threads=1"
2+
test_ip = "test --test ipv4_tests -- --ignored --test-threads=1"
3+
4+
[target.'cfg(all())']
5+
rustflags = [
6+
# BEGIN - Embark standard lints v6 for Rust 1.55+
7+
# do not change or add/remove here, but one can add exceptions after this section
8+
# for more info see: <https://github.com/EmbarkStudios/rust-ecosystem/issues/59>
9+
"-Dunsafe_code",
10+
"-Wclippy::all",
11+
"-Wclippy::await_holding_lock",
12+
"-Wclippy::char_lit_as_u8",
13+
"-Wclippy::checked_conversions",
14+
"-Wclippy::dbg_macro",
15+
"-Wclippy::debug_assert_with_mut_call",
16+
"-Wclippy::doc_markdown",
17+
"-Wclippy::empty_enum",
18+
"-Wclippy::enum_glob_use",
19+
"-Wclippy::exit",
20+
"-Wclippy::expl_impl_clone_on_copy",
21+
"-Wclippy::explicit_deref_methods",
22+
"-Wclippy::explicit_into_iter_loop",
23+
"-Wclippy::fallible_impl_from",
24+
"-Wclippy::filter_map_next",
25+
"-Wclippy::flat_map_option",
26+
"-Wclippy::float_cmp_const",
27+
"-Wclippy::fn_params_excessive_bools",
28+
"-Wclippy::from_iter_instead_of_collect",
29+
"-Wclippy::if_let_mutex",
30+
"-Wclippy::implicit_clone",
31+
"-Wclippy::imprecise_flops",
32+
# to be enabled at a later date
33+
# "-Wclippy::indexing_slicing",
34+
"-Wclippy::inefficient_to_string",
35+
"-Wclippy::invalid_upcast_comparisons",
36+
"-Wclippy::large_digit_groups",
37+
"-Wclippy::large_stack_arrays",
38+
"-Wclippy::large_types_passed_by_value",
39+
"-Wclippy::let_unit_value",
40+
"-Wclippy::linkedlist",
41+
"-Wclippy::lossy_float_literal",
42+
"-Wclippy::macro_use_imports",
43+
"-Wclippy::manual_ok_or",
44+
"-Wclippy::map_err_ignore",
45+
"-Wclippy::map_flatten",
46+
"-Wclippy::map_unwrap_or",
47+
"-Wclippy::match_same_arms",
48+
"-Wclippy::match_wild_err_arm",
49+
"-Wclippy::match_wildcard_for_single_variants",
50+
"-Wclippy::mem_forget",
51+
"-Wclippy::missing_enforced_import_renames",
52+
"-Wclippy::mut_mut",
53+
"-Wclippy::mutex_integer",
54+
"-Wclippy::needless_borrow",
55+
"-Wclippy::needless_continue",
56+
"-Wclippy::needless_for_each",
57+
"-Wclippy::option_option",
58+
"-Wclippy::path_buf_push_overwrite",
59+
"-Wclippy::ptr_as_ptr",
60+
"-Wclippy::rc_mutex",
61+
"-Wclippy::ref_option_ref",
62+
"-Wclippy::rest_pat_in_fully_bound_structs",
63+
"-Wclippy::same_functions_in_if_condition",
64+
"-Wclippy::semicolon_if_nothing_returned",
65+
"-Wclippy::single_match_else",
66+
"-Wclippy::string_add_assign",
67+
"-Wclippy::string_add",
68+
"-Wclippy::string_lit_as_bytes",
69+
"-Wclippy::string_to_string",
70+
"-Wclippy::todo",
71+
"-Wclippy::trait_duplication_in_bounds",
72+
"-Wclippy::unimplemented",
73+
"-Wclippy::unnested_or_patterns",
74+
"-Wclippy::unused_self",
75+
"-Wclippy::useless_transmute",
76+
"-Wclippy::verbose_file_reads",
77+
"-Wclippy::zero_sized_map_values",
78+
"-Wfuture_incompatible",
79+
"-Wnonstandard_style",
80+
"-Wrust_2018_idioms",
81+
"-Wunexpected_cfgs",
82+
# END - Embark standard lints v6 for Rust 1.55+
83+
]

.github/workflows/rust.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ jobs:
1818
- name: Build
1919
run: cargo build --verbose
2020

21+
- name: Clippy
22+
run: cargo clippy
23+
2124
- name: Run tests
2225
run: cargo test --verbose
2326

@@ -38,6 +41,9 @@ jobs:
3841
- name: Build
3942
run: cargo build --verbose
4043

44+
- name: Clippy
45+
run: cargo clippy
46+
4147
- name: Run tests
4248
run: cargo test --verbose
4349

@@ -49,6 +55,9 @@ jobs:
4955
- name: Build
5056
run: cargo build --verbose
5157

58+
- name: Clippy
59+
run: cargo clippy
60+
5261
- name: Run tests
5362
run: cargo test --verbose
5463

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name = "sacn"
33
description = "A Rust implementation of the ANSI E1.31 Streaming ACN protocol, tested against protocol version ANSI E1.31-2018."
44
version = "0.11.1"
55
edition = "2024"
6+
rust-version = "1.88"
67
readme = "README.md"
78
keywords = ["acn", "sacn", "dmx", "e131", "ansi"]
89
authors = ["Lukas Schmierer <lukas.schmierer@lschmierer.de>", "Paul Lancaster <paul@lancasterzone.com>"]

examples/demo_rcv/src/main.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
pub mod error;
2929
use error::errors::{DemoError, Result};
3030

31-
extern crate sacn;
32-
3331
use sacn::packet::ACN_SDT_MULTICAST_PORT;
3432
use sacn::receive::{DMXData, DiscoveredSacnSource, SacnReceiver};
3533

examples/demo_src/src/main.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030
pub mod error;
3131
use error::errors::Result;
3232

33-
extern crate sacn;
34-
3533
use sacn::packet::{ACN_SDT_MULTICAST_PORT, UNIVERSE_CHANNEL_CAPACITY};
3634
use sacn::source::SacnSource;
3735

examples/simple-receiver.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
//
88
// Simply listens on the given universe and shows the current data.
99

10-
extern crate crossterm;
11-
extern crate sacn;
12-
1310
use crossterm::style::Print;
1411
use crossterm::{cursor, execute, queue, terminal};
1512
use std::io::{self, Stdout, Write};

examples/sine-wave-sender.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
//
88
// Uses the sACN library to send a sine wave on all channels on universe 1 to localhost.
99

10-
extern crate sacn;
11-
1210
use sacn::packet::{ACN_SDT_MULTICAST_PORT, UNIVERSE_CHANNEL_CAPACITY};
1311
use sacn::source::SacnSource;
1412

src/error.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,30 +84,30 @@ pub mod errors {
8484
#[error("Limit for the number of supported sources has been reached: {0}")]
8585
SourcesExceededError(usize),
8686

87-
/// A source was discovered by a receiver with the announce_discovery_flag set to true.
87+
/// A source was discovered by a receiver with the `announce_discovery_flag` set to true.
8888
///
8989
/// # Arguments
9090
/// The name of the source discovered.
9191
#[error("Source discovered with announce_discovery_flag set to true: {0}")]
9292
SourceDiscovered(String),
9393

94-
/// Attempted to exceed the capacity of a single universe (packet::UNIVERSE_CHANNEL_CAPACITY).
94+
/// Attempted to exceed the capacity of a single universe (`packet::UNIVERSE_CHANNEL_CAPACITY`).
9595
///
9696
/// # Arguments
9797
/// Length of data provided.
9898
#[error("Attempted to exceed the capacity of a single universe, data len: {0}")]
9999
ExceedUniverseCapacity(usize),
100100

101-
/// Attempted to use illegal universe, outwith allowed range of [E131_MIN_MULTICAST_UNIVERSE, E131_MAX_MULTICAST_UNIVERSE]
102-
/// + E131_DISCOVERY_UNIVERSE inclusive
101+
/// Attempted to use illegal universe, outwith allowed range of [`E131_MIN_MULTICAST_UNIVERSE`, `E131_MAX_MULTICAST_UNIVERSE`]
102+
/// + `E131_DISCOVERY_UNIVERSE` inclusive
103103
///
104104
/// # Arguments
105105
/// u16: The provided universe.
106106
#[error("Attempted to use an illegal universe: {0}")]
107107
IllegalUniverse(u16),
108108

109-
/// Attempted to use illegal universe as the sync universe, outwith allowed range of [E131_MIN_MULTICAST_UNIVERSE, E131_MAX_MULTICAST_UNIVERSE]
110-
/// + E131_DISCOVERY_UNIVERSE inclusive
109+
/// Attempted to use illegal universe as the sync universe, outwith allowed range of [`E131_MIN_MULTICAST_UNIVERSE`, `E131_MAX_MULTICAST_UNIVERSE`]
110+
/// + `E131_DISCOVERY_UNIVERSE` inclusive
111111
///
112112
/// # Arguments
113113
/// u16: The provided synchronization universe.
@@ -160,7 +160,7 @@ pub mod errors {
160160
OutOfSequence(u8, u8, isize),
161161

162162
/// A source terminated a universe and this was detected when trying to receive data.
163-
/// This is only returned if the announce_stream_termination flag is set to true (default false).
163+
/// This is only returned if the `announce_stream_termination` flag is set to true (default false).
164164
///
165165
/// # Arguments
166166
/// Uuid: The CID of the source which sent the termination packet.
@@ -169,7 +169,7 @@ pub mod errors {
169169
#[error("Source terminated universe, source cid: {0}, universe: {1}")]
170170
UniverseTerminated(Uuid, u16),
171171

172-
/// A source universe timed out as no data was received on that universe within E131_NETWORK_DATA_LOSS_TIMEOUT as per ANSI E1.31-2018 Section 6.7.1.
172+
/// A source universe timed out as no data was received on that universe within `E131_NETWORK_DATA_LOSS_TIMEOUT` as per ANSI E1.31-2018 Section 6.7.1.
173173
///
174174
/// # Arguments
175175
/// uuid: The CID of the source which timed out.
@@ -208,7 +208,7 @@ pub mod errors {
208208
/// such as by creating a new source.
209209
///
210210
/// # Arguments
211-
/// String: A message providing further details (if any) as to why the SourceCorrupt error was returned.
211+
/// String: A message providing further details (if any) as to why the `SourceCorrupt` error was returned.
212212
#[error(
213213
"The sACN source has corrupted due to an internal panic! and should no longer be used, {0}"
214214
)]

src/lib.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -195,19 +195,6 @@ pub mod sacn_parse_pack_error;
195195
/// The errors used within the sACN crate, parse/pack errors are seperated out into sacn_parse_pack_error.
196196
pub mod error;
197197

198-
extern crate libc;
199-
/// The library is built on top of socket2 to provide the underlying UDP networking interface.
200-
extern crate socket2;
201-
202-
/// The core crate is used for string processing during packet parsing/packing as well as to provide access to the Hash trait.
203-
extern crate core;
204-
205-
/// The byteorder crate is used for marshalling data on/off the network in Network Byte Order.
206-
extern crate byteorder;
207-
208-
/// The uuid crate is used for working with/generating UUIDs which sACN uses as part of the cid field in the protocol.
209-
extern crate uuid;
210-
211198
/// The packet module handles the sACN packets including parsing/packing and sACN related constants.
212199
pub mod packet;
213200

0 commit comments

Comments
 (0)