Skip to content

Commit 19d1a6b

Browse files
committed
build: Enable clippy
1 parent 35a3c9d commit 19d1a6b

File tree

4 files changed

+18
-29
lines changed

4 files changed

+18
-29
lines changed

.travis.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ env: # Needed for allow_failures
1616

1717
matrix:
1818
include:
19+
- env: SUITE=format-check
20+
install: rustup component add rustfmt-preview
21+
- env: SUITE=lint
22+
install: rustup component add clippy-preview
23+
rust: nightly
1924
- env: SUITE=check
2025
rust: "1.26.0"
2126
- env: SUITE=cargotest
@@ -26,14 +31,6 @@ matrix:
2631
env: SUITE=checkall
2732
- os: osx
2833
env: SUITE=cargotestall
29-
- env: SUITE=format-check
30-
install: rustup component add rustfmt-preview
31-
- env: SUITE=lint
32-
rust: nightly
33-
install: cargo install --force clippy
34-
allow_failures:
35-
- env: SUITE=lint
36-
rust: nightly
3734

3835
notifications:
3936
webhooks:

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,5 @@ format-check:
7777
.PHONY: format-check
7878

7979
lint:
80-
@cargo +nightly clippy --all-features -- -D clippy
80+
@cargo +nightly clippy --all-features --tests -- -D clippy
8181
.PHONY: lint

src/client.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ impl Client {
317317
/// If the DSN on the options is set to `None` the client will be entirely
318318
/// disabled.
319319
pub fn with_options(options: ClientOptions) -> Client {
320+
#[cfg_attr(feature = "cargo-clippy", allow(question_mark))]
320321
let transport = if options.dsn.is_none() {
321322
None
322323
} else {

src/hub.rs

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,23 @@
1-
#[allow(unused)]
1+
#![allow(unused)]
2+
23
use std::cell::{Cell, UnsafeCell};
34
use std::iter;
4-
#[allow(unused)]
5-
use std::sync::{Arc, Mutex, RwLock, RwLockReadGuard, RwLockWriteGuard, TryLockError};
6-
#[allow(unused)]
5+
use std::sync::atomic::{AtomicBool, Ordering};
6+
use std::sync::{Arc, Mutex, RwLock, TryLockError};
77
use std::thread;
88
use std::time::Duration;
99

1010
#[cfg(feature = "with_client_implementation")]
1111
use fragile::SemiSticky;
1212

13-
#[allow(unused)]
14-
use std::sync::atomic::{AtomicBool, Ordering};
15-
1613
#[cfg(feature = "with_client_implementation")]
1714
use client::Client;
1815
use protocol::{Breadcrumb, Event, Level};
1916
use scope::{Scope, ScopeGuard};
20-
21-
#[cfg(feature = "with_client_implementation")]
22-
use utils::current_thread;
23-
2417
#[cfg(feature = "with_client_implementation")]
2518
use scope::{Stack, StackLayerToken};
19+
#[cfg(feature = "with_client_implementation")]
20+
use utils::current_thread;
2621

2722
use uuid::Uuid;
2823

@@ -53,7 +48,7 @@ impl IntoBreadcrumbs for Breadcrumb {
5348
type Output = iter::Once<Breadcrumb>;
5449

5550
fn into_breadcrumbs(self) -> Self::Output {
56-
return iter::once(self);
51+
iter::once(self)
5752
}
5853
}
5954

@@ -94,6 +89,7 @@ pub(crate) enum PendingProcessor {
9489

9590
#[cfg(feature = "with_client_implementation")]
9691
impl<F: 'static + FnOnce() -> Box<Fn(&mut Event) + Send + Sync>> EventProcessorFactoryFn for F {
92+
#[cfg_attr(feature = "cargo-clippy", allow(boxed_local))]
9793
fn call(self: Box<Self>) -> Box<Fn(&mut Event) + Send + Sync> {
9894
let this: Self = *self;
9995
this()
@@ -254,7 +250,6 @@ impl Hub {
254250
/// This is useful for integrations that want to do efficiently nothing if there is no
255251
/// client bound. Additionally this internally ensures that the client can be safely
256252
/// synchronized. This prevents accidental recursive calls into the client.
257-
#[allow(unused_variables)]
258253
pub fn with_active<F, R>(f: F) -> R
259254
where
260255
F: FnOnce(&Arc<Hub>) -> R,
@@ -273,6 +268,7 @@ impl Hub {
273268

274269
/// Binds a hub to the current thread for the duration of the call.
275270
#[cfg(feature = "with_client_implementation")]
271+
#[cfg_attr(feature = "cargo-clippy", allow(needless_pass_by_value))]
276272
pub fn run<F: FnOnce() -> R, R>(hub: Arc<Hub>, f: F) -> R {
277273
hub.flush_pending_processors();
278274
let mut restore_process_hub = false;
@@ -305,7 +301,7 @@ impl Hub {
305301
// this is for the case where we just switched the hub. This
306302
// means we need to catch the panic, restore the
307303
// old context and resume the panic if needed.
308-
let rv = panic::catch_unwind(panic::AssertUnwindSafe(|| f()));
304+
let rv = panic::catch_unwind(panic::AssertUnwindSafe(f));
309305
THREAD_HUB.with(|ctx| unsafe { *ctx.get() = old_hub });
310306
if restore_process_hub {
311307
USE_PROCESS_HUB.with(|x| x.set(true));
@@ -321,7 +317,6 @@ impl Hub {
321317
/// Sends the event to the current client with the current scope.
322318
///
323319
/// In case no client is bound this does nothing instead.
324-
#[allow(unused_variables)]
325320
pub fn capture_event(&self, event: Event<'static>) -> Uuid {
326321
self.flush_pending_processors();
327322
with_client_impl! {{
@@ -337,7 +332,6 @@ impl Hub {
337332
}
338333

339334
/// Captures an arbitrary message.
340-
#[allow(unused_variables)]
341335
pub fn capture_message(&self, msg: &str, level: Level) -> Uuid {
342336
self.flush_pending_processors();
343337
with_client_impl! {{
@@ -364,7 +358,6 @@ impl Hub {
364358
}
365359

366360
/// Drains the currently pending events.
367-
#[allow(unused_variables)]
368361
pub fn drain_events(&self, timeout: Option<Duration>) {
369362
with_client_impl! {{
370363
if let Some(ref client) = self.client() {
@@ -407,7 +400,6 @@ impl Hub {
407400
}
408401

409402
/// Invokes a function that can modify the current scope.
410-
#[allow(unused_variables)]
411403
pub fn configure_scope<F, R>(&self, f: F) -> R
412404
where
413405
R: Default,
@@ -428,7 +420,6 @@ impl Hub {
428420
///
429421
/// This is equivalent to the global [`sentry::add_breadcrumb`](fn.add_breadcrumb.html) but
430422
/// sends the breadcrumb into the hub instead.
431-
#[allow(unused_variables)]
432423
pub fn add_breadcrumb<B: IntoBreadcrumbs>(&self, breadcrumb: B) {
433424
with_client_impl! {{
434425
self.inner.with_mut(|stack| {
@@ -522,7 +513,7 @@ impl Hub {
522513
self.inner.has_pending_processors.store(any_left, Ordering::Release);
523514
if !new_processors.is_empty() {
524515
self.configure_scope(|scope| {
525-
for func in new_processors.into_iter() {
516+
for func in new_processors {
526517
scope.event_processors = scope.event_processors.push_back(func);
527518
}
528519
});

0 commit comments

Comments
 (0)