Commit 287c4548 authored by Ben Boeckel's avatar Ben Boeckel Committed by Kitware Robot
Browse files

Merge topic 'clippy-warning-cause-failure'

05eb7e2d clippy: fail CI on warnings
0f7f552c test/types: refactor out sha checking for MRs
3973eabc test/types: split large functions
2394aa11 test/types: avoid Some(foo.into()) by unwrapping the other side
0dd88aa5 test/types: make datetime construction simpler
7716ef8a test/types: add trailing commas
a284f664 test/types: refactor out an unwrap call
79844774

 test/types: clarify some Option related asserts
...
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !171
parents 27f93fba 05eb7e2d
......@@ -24,8 +24,7 @@ before_script:
# gone wrong here.
- .gitlab/ci/sccache.sh && export RUSTC_WRAPPER=$PWD/.gitlab/sccache
- rustup component add clippy
# - cargo clippy --frozen --tests --all --verbose -- -D warnings
- cargo clippy --frozen --tests --all --verbose
- cargo clippy --frozen --tests --all --verbose -- -D warnings
- ".gitlab/sccache --show-stats || :"
.cargo_build: &cargo_build
......
......@@ -1668,9 +1668,7 @@ impl Gitlab {
return Err(GitlabError::from_gitlab(v));
}
debug!(target: "gitlab",
"received data: {:?}",
v);
debug!(target: "gitlab", "received data: {:?}", v);
serde_json::from_value::<T>(v).map_err(GitlabError::data_type::<T>)
}
......
......@@ -24,7 +24,7 @@ pub enum GitlabHook {
/// A system hook.
System(SystemHook),
/// A web hook from a specific project.
Web(WebHook),
Web(Box<WebHook>),
}
impl<'de> Deserialize<'de> for GitlabHook {
......@@ -37,7 +37,7 @@ impl<'de> Deserialize<'de> for GitlabHook {
// Look for `object_kind` first because some web hooks also have `event_name` which would
// cause a false match here.
let hook_res = if val.pointer("/object_kind").is_some() {
serde_json::from_value(val).map(GitlabHook::Web)
serde_json::from_value(val).map(|hook| GitlabHook::Web(Box::new(hook)))
} else if val.pointer("/event_name").is_some() {
serde_json::from_value(val).map(GitlabHook::System)
} else {
......
......@@ -4,7 +4,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![warn(missing_docs)]
// TODO: Document API entities.
// #![warn(missing_docs)]
//! A library for communicating with Gitlab instances.
......
......@@ -369,7 +369,7 @@ pub enum SystemHook {
/// A group membership hook.
GroupMember(GroupMemberSystemHook),
/// A push hook.
Push(PushSystemHook),
Push(Box<PushSystemHook>),
}
impl<'de> Deserialize<'de> for SystemHook {
......@@ -412,7 +412,9 @@ impl<'de> Deserialize<'de> for SystemHook {
serde_json::from_value(val).map(SystemHook::GroupMember)
},
"push" | "tag_push" => serde_json::from_value(val).map(SystemHook::Push),
"push" | "tag_push" => {
serde_json::from_value(val).map(|hook| SystemHook::Push(Box::new(hook)))
},
_ => {
return Err(D::Error::custom(format!(
......
This diff is collapsed.
......@@ -13,6 +13,7 @@
//! upstream.
use std::fmt::{self, Display, Formatter};
use std::str::FromStr;
use crates::chrono::{DateTime, NaiveDate, Utc};
use crates::serde::de::{DeserializeOwned, Error, Unexpected};
......@@ -1220,8 +1221,17 @@ impl LabelColor {
LabelColor(format!("#{:02X}{:02X}{:02X}", r, g, b))
}
/// Get the value from a LabelColor
pub fn value(self) -> String {
self.0
}
}
impl FromStr for LabelColor {
type Err = ();
/// Creates a LabelColor from standard HTML values
pub fn from_str(stdcolor: &str) -> LabelColor {
fn from_str(stdcolor: &str) -> Result<Self, Self::Err> {
let hex = match stdcolor {
"white" => "FFFFFF",
"silver" => "C0C0C0",
......@@ -1242,12 +1252,7 @@ impl LabelColor {
_ => "808080",
};
LabelColor(format!("#{}", hex))
}
/// Get the value from a LabelColor
pub fn value(self) -> String {
self.0
Ok(LabelColor(format!("#{}", hex)))
}
}
......@@ -1523,7 +1528,7 @@ pub struct ExternalIssue {
#[derive(Debug, Clone)]
pub enum IssueReference {
/// A reference to an issue on the same Gitlab host.
Internal(Issue),
Internal(Box<Issue>),
/// An external issue reference.
External(ExternalIssue),
}
......@@ -1545,7 +1550,7 @@ impl<'de> Deserialize<'de> for IssueReference {
let val = <Value as Deserialize>::deserialize(deserializer)?;
serde_json::from_value::<Issue>(val.clone())
.map(IssueReference::Internal)
.map(|issue| IssueReference::Internal(Box::new(issue)))
.or_else(|_| serde_json::from_value::<ExternalIssue>(val).map(IssueReference::External))
.map_err(|err| D::Error::custom(format!("invalid issue reference: {:?}", err)))
}
......
......@@ -315,8 +315,11 @@ impl MergeRequestParams {
} else if let Some(as_bool) = val.as_bool() {
as_bool
} else {
error!(target: "gitlab",
"unknown value for force_remove_source_branch: {}", val);
error!(
target: "gitlab",
"unknown value for force_remove_source_branch: {}",
val,
);
false
}
})
......@@ -717,17 +720,17 @@ pub struct WikiPageHook {
#[derive(Debug, Clone)]
pub enum WebHook {
/// A push hook.
Push(PushHook),
Push(Box<PushHook>),
/// An issue hook.
Issue(IssueHook),
Issue(Box<IssueHook>),
/// A merge request hook.
MergeRequest(MergeRequestHook),
MergeRequest(Box<MergeRequestHook>),
/// A note hook.
Note(NoteHook),
Note(Box<NoteHook>),
/// A build hook.
Build(BuildHook),
Build(Box<BuildHook>),
/// A wiki page hook.
WikiPage(WikiPageHook),
WikiPage(Box<WikiPageHook>),
}
impl<'de> Deserialize<'de> for WebHook {
......@@ -752,15 +755,19 @@ impl<'de> Deserialize<'de> for WebHook {
};
let hook_res = match object_kind.as_ref() {
"push" | "tag_push" => serde_json::from_value(val).map(WebHook::Push),
"push" | "tag_push" => {
serde_json::from_value(val).map(|hook| WebHook::Push(Box::new(hook)))
},
"issue" => serde_json::from_value(val).map(WebHook::Issue),
"issue" => serde_json::from_value(val).map(|hook| WebHook::Issue(Box::new(hook))),
"merge_request" => serde_json::from_value(val).map(WebHook::MergeRequest),
"merge_request" => {
serde_json::from_value(val).map(|hook| WebHook::MergeRequest(Box::new(hook)))
},
"note" => serde_json::from_value(val).map(WebHook::Note),
"note" => serde_json::from_value(val).map(|hook| WebHook::Note(Box::new(hook))),
"build" => serde_json::from_value(val).map(WebHook::Build),
"build" => serde_json::from_value(val).map(|hook| WebHook::Build(Box::new(hook))),
_ => {
return Err(D::Error::invalid_value(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment