Skip to content

Commit 8d648ce

Browse files
author
Nikita Baksalyar
committed
chore/ci: update clippy and fix CI issues
1 parent 105abec commit 8d648ce

File tree

17 files changed

+60
-72
lines changed

17 files changed

+60
-72
lines changed

.travis.yml

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,26 @@ os:
99
language: rust
1010
rust:
1111
- stable
12-
- nightly
12+
- nightly-2016-12-19
1313
sudo: false
1414
branches:
1515
only:
1616
- master
1717
- dev
1818
cache:
1919
cargo: true
20+
2021
before_script:
2122
- (which cargo-install-update && cargo install-update cargo-update) || cargo install cargo-update
22-
- (which rustfmt && cargo install-update rustfmt) || cargo install rustfmt
2323
- (which cargo-prune && cargo install-update cargo-prune) || cargo install cargo-prune
24+
- if [ "${TRAVIS_RUST_VERSION}" = stable ]; then
25+
(which rustfmt && cargo install-update rustfmt) || cargo install rustfmt;
26+
elif [ "${TRAVIS_OS_NAME}" = linux ]; then
27+
clippy_vers=0.0.104;
28+
if ! cargo clippy --version | grep -q $clippy_vers; then
29+
cargo install clippy --vers=$clippy_vers --force;
30+
fi
31+
fi
2432
script:
2533
- if [ "${TRAVIS_RUST_VERSION}" = stable ]; then
2634
(
@@ -53,16 +61,16 @@ script:
5361
cd ../safe_authenticator &&
5462
cargo test --verbose --release --features "$Features";
5563
);
56-
else
64+
elif [ "${TRAVIS_OS_NAME}" = linux ]; then
5765
(
5866
set -x;
59-
curl -sSL -o run_clippy.sh https://github.com/maidsafe/QA/raw/master/bash_scripts/travis/run_clippy.sh &&
67+
cargo clippy && cargo clippy --profile=test
6068

61-
cd ffi_utils && unset Features && bash ../run_clippy.sh && export Features="use-mock-routing testing" &&
62-
cd ../safe_core && bash ../run_clippy.sh &&
63-
cd ../safe_app && bash ../run_clippy.sh &&
64-
cd ../safe_authenticator && bash ../run_clippy.sh;
65-
);
69+
cd ffi_utils && unset Features && cargo clippy && cargo clippy --profile=test && export Features="use-mock-routing testing" &&
70+
cd ../safe_core && cargo clippy && cargo clippy --profile=test --features="$Features" &&
71+
cd ../safe_app && cargo clippy && cargo clippy --profile=test --features="$Features" &&
72+
cd ../safe_authenticator && cargo clippy && cargo clippy --profile=test --features="$Features";
73+
)
6674
fi
6775
before_cache:
6876
- cargo prune

ffi_utils/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ repository = "https://github.com/maidsafe/safe_client_libs"
1010
version = "0.1.0"
1111

1212
[dependencies]
13-
clippy = { version = "=0.0.99", optional = true }
1413
log = "~0.3.6"
1514
# TODO rand is only used by tests but putting it as dev-dependency fails to compile with
1615
# cargo rustc --release --features clippy --verbose -- --test -Zno-trans

ffi_utils/src/ffi_repr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl ReprC for [u8; 32] {
6565
type Error = ();
6666

6767
#[allow(unsafe_code)]
68-
#[cfg_attr(feature="clippy", allow(not_unsafe_ptr_arg_deref))]
68+
#[cfg_attr(feature="cargo-clippy", allow(not_unsafe_ptr_arg_deref))]
6969
fn from_repr_c_cloned(c_repr: *const [u8; 32]) -> Result<[u8; 32], ()> {
7070
unsafe { Ok(*c_repr) }
7171
}

ffi_utils/src/lib.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,9 @@
4141
#![allow(box_pointers, fat_ptr_transmutes, missing_copy_implementations,
4242
missing_debug_implementations, variant_size_differences)]
4343

44-
#![cfg_attr(feature="clippy", feature(plugin))]
45-
#![cfg_attr(feature="clippy", plugin(clippy))]
46-
#![cfg_attr(feature="clippy", deny(clippy, unicode_not_nfc, wrong_pub_self_convention,
47-
option_unwrap_used))]
48-
#![cfg_attr(feature="clippy", allow(use_debug, too_many_arguments))]
44+
#![cfg_attr(feature="cargo-clippy", deny(clippy, unicode_not_nfc, wrong_pub_self_convention,
45+
option_unwrap_used))]
46+
#![cfg_attr(feature="cargo-clippy", allow(use_debug, too_many_arguments))]
4947

5048
#[macro_use]
5149
extern crate log;

ffi_utils/src/macros.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ macro_rules! ffi_result_code {
3232
#[macro_export]
3333
macro_rules! ffi_error_code {
3434
($err:expr) => {{
35-
#[cfg_attr(feature = "clippy", allow(useless_attribute))]
35+
#[cfg_attr(feature = "cargo-clippy", allow(useless_attribute))]
3636
#[allow(unused)]
3737
use $crate::ErrorCode;
3838

@@ -53,7 +53,7 @@ macro_rules! try_cb {
5353
match $result {
5454
Ok(value) => value,
5555
Err(err) => {
56-
#[cfg_attr(feature = "clippy", allow(useless_attribute))]
56+
#[cfg_attr(feature = "cargo-clippy", allow(useless_attribute))]
5757
#[allow(unused)]
5858
use $crate::callback::{Callback, CallbackArgs};
5959
$cb.call($user_data.into(), ffi_error_code!(err), CallbackArgs::default());

safe_app/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ repository = "https://github.com/maidsafe/safe_client_libs"
1010
version = "0.1.0"
1111

1212
[dependencies]
13-
clippy = { version = "=0.0.99", optional = true }
1413
ffi_utils = { path = "../ffi_utils", version = "~0.1.0" }
1514
futures = "~0.1.6"
1615
log = "~0.3.6"
@@ -28,6 +27,9 @@ time = "~0.1.35"
2827
tokio-core = "~0.1.1"
2928
unwrap = "~1.1.0"
3029

30+
[dev-dependencies]
31+
safe_authenticator = { path = "../safe_authenticator", version = "~0.1.0" }
32+
3133
[features]
3234
use-mock-routing = ["safe_core/use-mock-routing"]
3335
testing = ["safe_authenticator", "safe_authenticator/testing", "safe_core/testing"]

safe_app/src/ffi/ipc.rs

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,13 @@
2222
//! App-related IPC utilities.
2323
2424
use errors::AppError;
25-
use ffi_utils::{ReprC, catch_unwind_cb, catch_unwind_error_code, from_c_str};
25+
use ffi_utils::{ReprC, catch_unwind_cb, from_c_str};
2626
use safe_core::ipc::{self, AuthReq, ContainersReq, IpcError, IpcMsg, IpcReq, IpcResp};
2727
use safe_core::ipc::req::ffi::AuthReq as FfiAuthReq;
2828
use safe_core::ipc::req::ffi::ContainersReq as FfiContainersReq;
2929
use safe_core::ipc::resp::ffi::AuthGranted as FfiAuthGranted;
3030
use std::ffi::CString;
3131
use std::os::raw::{c_char, c_void};
32-
use std::ptr;
3332

3433
/// Encode `AuthReq`.
3534
#[no_mangle]
@@ -39,9 +38,8 @@ pub unsafe extern "C" fn encode_auth_req(req: *const FfiAuthReq,
3938
i32,
4039
u32,
4140
*const c_char)) {
42-
let req_id = ipc::gen_req_id();
43-
44-
let error_code = catch_unwind_error_code(|| -> Result<_, AppError> {
41+
catch_unwind_cb(user_data, o_cb, || -> Result<_, AppError> {
42+
let req_id = ipc::gen_req_id();
4543
let req = AuthReq::from_repr_c_cloned(req)?;
4644

4745
let msg = IpcMsg::Req {
@@ -55,11 +53,7 @@ pub unsafe extern "C" fn encode_auth_req(req: *const FfiAuthReq,
5553
o_cb(user_data, 0, req_id, encoded.as_ptr());
5654

5755
Ok(())
58-
});
59-
60-
if error_code != 0 {
61-
o_cb(user_data, error_code, req_id, ptr::null_mut());
62-
}
56+
})
6357
}
6458

6559
/// Encode `ContainersReq`.
@@ -70,9 +64,8 @@ pub unsafe extern "C" fn encode_containers_req(req: *const FfiContainersReq,
7064
i32,
7165
u32,
7266
*const c_char)) {
73-
let req_id = ipc::gen_req_id();
74-
75-
let error_code = catch_unwind_error_code(|| -> Result<_, AppError> {
67+
catch_unwind_cb(user_data, o_cb, || -> Result<_, AppError> {
68+
let req_id = ipc::gen_req_id();
7669
let req = ContainersReq::from_repr_c_cloned(req)?;
7770

7871
let msg = IpcMsg::Req {
@@ -86,11 +79,7 @@ pub unsafe extern "C" fn encode_containers_req(req: *const FfiContainersReq,
8679
o_cb(user_data, 0, req_id, encoded.as_ptr());
8780

8881
Ok(())
89-
});
90-
91-
if error_code != 0 {
92-
o_cb(user_data, error_code, req_id, ptr::null_mut());
93-
}
82+
})
9483
}
9584

9685
/// Decode IPC message.

safe_app/src/lib.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,9 @@
4141
#![allow(box_pointers, fat_ptr_transmutes, missing_copy_implementations,
4242
missing_debug_implementations, variant_size_differences)]
4343

44-
#![cfg_attr(feature="clippy", feature(plugin))]
45-
#![cfg_attr(feature="clippy", plugin(clippy))]
46-
#![cfg_attr(feature="clippy", deny(clippy, unicode_not_nfc, wrong_pub_self_convention,
47-
option_unwrap_used))]
48-
#![cfg_attr(feature="clippy", allow(use_debug, too_many_arguments))]
44+
#![cfg_attr(feature="cargo-clippy", deny(clippy, unicode_not_nfc, wrong_pub_self_convention,
45+
option_unwrap_used))]
46+
#![cfg_attr(feature="cargo-clippy", allow(use_debug, too_many_arguments))]
4947

5048
#[macro_use]
5149
extern crate ffi_utils;
@@ -59,7 +57,7 @@ extern crate rand;
5957
extern crate routing;
6058
extern crate rustc_serialize;
6159
extern crate rust_sodium;
62-
#[cfg(feature = "testing")]
60+
#[cfg(any(test, feature="testing"))]
6361
extern crate safe_authenticator;
6462
#[macro_use]
6563
extern crate safe_core;
@@ -73,7 +71,7 @@ pub mod object_cache;
7371

7472
mod errors;
7573
/// Utility functions to test apps functionality
76-
#[cfg(any(test, feature = "testing"))]
74+
#[cfg(any(test, feature="testing"))]
7775
pub mod test_utils;
7876

7977
pub use self::errors::*;
@@ -93,7 +91,7 @@ use std::collections::{BTreeSet, HashMap};
9391
use std::rc::Rc;
9492
use std::sync::Mutex;
9593
use std::sync::mpsc as std_mpsc;
96-
#[cfg(feature = "testing")]
94+
#[cfg(feature="testing")]
9795
pub use test_utils::{test_create_app, test_create_app_with_access};
9896
use tokio_core::reactor::{Core, Handle};
9997

safe_app/src/test_utils.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ pub fn run<F, I, T>(app: &App, f: F) -> T
8383

8484
/// Create registered app.
8585
pub fn create_app() -> App {
86-
let authenticator = authenticator::create_account_and_login();
86+
let auth = authenticator::create_account_and_login();
8787

8888
let app_info = gen_app_exchange_info();
8989
let app_id = app_info.id.clone();
9090

91-
let auth_granted = unwrap!(authenticator::register_app(&authenticator,
91+
let auth_granted = unwrap!(authenticator::register_app(&auth,
9292
&AuthReq {
9393
app: app_info,
9494
app_container: false,
@@ -102,12 +102,12 @@ pub fn create_app() -> App {
102102
/// If `create_containers` is true, also create all the containers specified in
103103
/// the `access_info` and set their permissions accordingly.
104104
pub fn create_app_with_access(access_info: HashMap<String, BTreeSet<Permission>>) -> App {
105-
let authenticator = authenticator::create_account_and_login();
105+
let auth = authenticator::create_account_and_login();
106106

107107
let app_info = gen_app_exchange_info();
108108
let app_id = app_info.id.clone();
109109

110-
let auth_granted = unwrap!(authenticator::register_app(&authenticator,
110+
let auth_granted = unwrap!(authenticator::register_app(&auth,
111111
&AuthReq {
112112
app: app_info,
113113
app_container: true,
@@ -118,9 +118,9 @@ pub fn create_app_with_access(access_info: HashMap<String, BTreeSet<Permission>>
118118
}
119119

120120
/// Creates a random app instance for testing
121-
#[cfg(feature = "testing")]
122121
#[no_mangle]
123122
#[allow(unsafe_code)]
123+
#[cfg_attr(feature="cargo-clippy", allow(not_unsafe_ptr_arg_deref))]
124124
pub extern "C" fn test_create_app(o_app: *mut *mut App) -> i32 {
125125
catch_unwind_error_code(|| -> Result<(), AppError> {
126126
let app = create_app();
@@ -132,9 +132,9 @@ pub extern "C" fn test_create_app(o_app: *mut *mut App) -> i32 {
132132
}
133133

134134
/// Create a random app instance for testing, with access to containers
135-
#[cfg(feature = "testing")]
136-
#[allow(unsafe_code)]
137135
#[no_mangle]
136+
#[allow(unsafe_code)]
137+
#[cfg_attr(feature="cargo-clippy", allow(not_unsafe_ptr_arg_deref))]
138138
pub extern "C" fn test_create_app_with_access(access_info: *const ffi::ContainerPermissions,
139139
access_info_len: usize,
140140
o_app: *mut *mut App)

safe_authenticator/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ repository = "https://github.com/maidsafe/safe_client_libs"
1010
version = "0.1.0"
1111

1212
[dependencies]
13-
clippy = { version = "=0.0.99", optional = true }
1413
ffi_utils = { path = "../ffi_utils", version = "~0.1.0" }
1514
futures = "~0.1.6"
1615
log = "~0.3.6"

safe_authenticator/src/ipc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ pub fn decode_ipc_msg(client: &Client,
111111
},
112112
app_id2)?;
113113

114-
return Ok(Err((err_code, resp)));
114+
Ok(Err((err_code, resp)))
115115
}
116116
AppState::NotAuthenticated |
117117
AppState::Revoked => {
@@ -152,7 +152,7 @@ pub fn decode_ipc_msg(client: &Client,
152152
};
153153
let resp = encode_response(&resp, app_id2)?;
154154

155-
return Ok(Err((err_code, resp)));
155+
Ok(Err((err_code, resp)))
156156
}
157157
}
158158
})
@@ -199,7 +199,7 @@ pub unsafe extern "C" fn auth_decode_ipc_msg(auth: *const Authenticator,
199199
}
200200
Ok(IpcMsg::Resp { .. }) |
201201
Ok(IpcMsg::Revoked { .. }) |
202-
Ok(IpcMsg::Err { .. }) => {
202+
Ok(IpcMsg::Err(..)) => {
203203
o_err(user_data.0,
204204
ffi_error_code!(AuthError::Unexpected("Unexpected msg \
205205
type"

safe_authenticator/src/lib.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,9 @@
4141
#![allow(box_pointers, fat_ptr_transmutes, missing_copy_implementations,
4242
missing_debug_implementations, variant_size_differences)]
4343

44-
#![cfg_attr(feature="clippy", feature(plugin))]
45-
#![cfg_attr(feature="clippy", plugin(clippy))]
46-
#![cfg_attr(feature="clippy", deny(clippy, unicode_not_nfc, wrong_pub_self_convention,
44+
#![cfg_attr(feature="cargo-clippy", deny(clippy, unicode_not_nfc, wrong_pub_self_convention,
4745
option_unwrap_used))]
48-
#![cfg_attr(feature="clippy", allow(use_debug, too_many_arguments))]
46+
#![cfg_attr(feature="cargo-clippy", allow(use_debug, too_many_arguments))]
4947

5048
#[macro_use]
5149
extern crate ffi_utils;
@@ -73,7 +71,7 @@ mod errors;
7371
mod access_container;
7472

7573
/// Provides utilities to test the authenticator functionality
76-
#[cfg(any(test, feature = "testing"))]
74+
#[cfg(any(test, feature="testing"))]
7775
pub mod test_utils;
7876
#[cfg(test)]
7977
mod tests;

safe_core/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ repository = "https://github.com/maidsafe/safe_client_libs"
1010
version = "0.22.0"
1111

1212
[dependencies]
13-
clippy = { version = "=0.0.99", optional = true }
1413
ffi_utils = { path = "../ffi_utils", version = "~0.1.0" }
1514
futures = "~0.1.6"
1615
lazy_static = "~0.2.1"

safe_core/src/ipc/req/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ impl ReprC for AuthReq {
130130
/// After calling this function, the subobjects memory is owned by the
131131
/// resulting object.
132132
#[allow(unsafe_code)]
133-
#[cfg_attr(feature="clippy", allow(not_unsafe_ptr_arg_deref))]
133+
#[cfg_attr(feature="cargo-clippy", allow(not_unsafe_ptr_arg_deref))]
134134
fn from_repr_c_cloned(repr_c: *const ffi::AuthReq) -> Result<Self, IpcError> {
135135
unsafe {
136136
Ok(AuthReq {
@@ -180,7 +180,7 @@ impl ReprC for ContainersReq {
180180
/// After calling this functions, the subobjects memory is owned by the
181181
/// resulting object.
182182
#[allow(unsafe_code)]
183-
#[cfg_attr(feature="clippy", allow(not_unsafe_ptr_arg_deref))]
183+
#[cfg_attr(feature="cargo-clippy", allow(not_unsafe_ptr_arg_deref))]
184184
fn from_repr_c_cloned(repr_c: *const ffi::ContainersReq) -> Result<Self, IpcError> {
185185
unsafe {
186186
Ok(ContainersReq {
@@ -233,7 +233,7 @@ impl ReprC for AppExchangeInfo {
233233
/// After calling this function, the raw pointer is owned by the resulting
234234
/// object.
235235
#[allow(unsafe_code)]
236-
#[cfg_attr(feature="clippy", allow(not_unsafe_ptr_arg_deref))]
236+
#[cfg_attr(feature="cargo-clippy", allow(not_unsafe_ptr_arg_deref))]
237237
fn from_repr_c_cloned(raw: *const ffi::AppExchangeInfo) -> Result<Self, IpcError> {
238238
unsafe {
239239
Ok(AppExchangeInfo {

safe_core/src/lib.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,9 @@
4242
#![allow(box_pointers, fat_ptr_transmutes, missing_copy_implementations,
4343
missing_debug_implementations, variant_size_differences)]
4444

45-
#![cfg_attr(feature="clippy", feature(plugin))]
46-
#![cfg_attr(feature="clippy", plugin(clippy))]
47-
#![cfg_attr(feature="clippy", deny(clippy, unicode_not_nfc, wrong_pub_self_convention,
48-
option_unwrap_used))]
49-
#![cfg_attr(feature="clippy", allow(use_debug, too_many_arguments))]
45+
#![cfg_attr(feature="cargo-clippy", deny(clippy, unicode_not_nfc, wrong_pub_self_convention,
46+
option_unwrap_used))]
47+
#![cfg_attr(feature="cargo-clippy", allow(use_debug, too_many_arguments))]
5048

5149
extern crate ffi_utils;
5250
extern crate futures;

safe_core/src/nfs/file.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ impl ReprC for File {
126126

127127
/// Convert to the native rust equivalent by cloning the internal data, preserving self.
128128
#[allow(unsafe_code)]
129-
#[cfg_attr(feature="clippy", allow(not_unsafe_ptr_arg_deref))]
129+
#[cfg_attr(feature="cargo-clippy", allow(not_unsafe_ptr_arg_deref))]
130130
fn from_repr_c_cloned(repr_c: *const FfiFile) -> Result<File, NfsError> {
131131
let user_metadata = unsafe {
132132
slice::from_raw_parts((*repr_c).user_metadata_ptr, (*repr_c).user_metadata_len)

0 commit comments

Comments
 (0)