Move to using clippy (#1142)

* Clippy fixes

* Finish converting to use clippy

* fix warnings in new master

* fix windows

* fix windows

Co-authored-by: Artem Vorotnikov <artem@vorotnikov.me>
This commit is contained in:
Jonathan Turner
2019-12-31 20:36:08 +13:00
committed by GitHub
parent 8093612cac
commit 72838cc083
93 changed files with 754 additions and 852 deletions

View File

@@ -69,7 +69,7 @@ impl PrettyDebug for ColumnPath {
impl HasFallibleSpan for ColumnPath {
fn maybe_span(&self) -> Option<Span> {
if self.members.len() == 0 {
if self.members.is_empty() {
None
} else {
Some(span_for_spanned_list(self.members.iter().map(|m| m.span)))
@@ -98,7 +98,7 @@ pub fn did_you_mean(obj_source: &Value, field_tried: &PathMember) -> Option<Vec<
let mut possible_matches: Vec<_> = possibilities
.into_iter()
.map(|x| {
let word = x.clone();
let word = x;
let distance = natural::distance::levenshtein_distance(&word, &field_tried);
(distance, word)

View File

@@ -15,6 +15,7 @@ pub struct Dictionary {
pub entries: IndexMap<String, Value>,
}
#[allow(clippy::derive_hash_xor_eq)]
impl Hash for Dictionary {
fn hash<H: Hasher>(&self, state: &mut H) {
let mut entries = self.entries.clone();
@@ -105,7 +106,7 @@ impl From<IndexMap<String, Value>> for Dictionary {
}
impl Dictionary {
pub fn get_data(&self, desc: &String) -> MaybeOwned<'_, Value> {
pub fn get_data(&self, desc: &str) -> MaybeOwned<'_, Value> {
match self.entries.get(desc) {
Some(v) => MaybeOwned::Borrowed(v),
None => MaybeOwned::Owned(

View File

@@ -108,7 +108,7 @@ pub fn format_primitive(primitive: &Primitive, field_name: Option<&String>) -> S
match byte.get_unit() {
byte_unit::ByteUnit::B => format!("{} B ", byte.get_value()),
_ => byte.format(1).to_string(),
_ => byte.format(1),
}
}
Primitive::Duration(sec) => format_duration(*sec),
@@ -150,7 +150,7 @@ pub fn format_primitive(primitive: &Primitive, field_name: Option<&String>) -> S
}
.to_owned(),
Primitive::Binary(_) => "<binary>".to_owned(),
Primitive::Date(d) => d.humanize().to_string(),
Primitive::Date(d) => d.humanize(),
}
}

View File

@@ -10,14 +10,14 @@ pub enum RangeInclusion {
}
impl RangeInclusion {
pub fn debug_left_bracket(&self) -> DebugDocBuilder {
pub fn debug_left_bracket(self) -> DebugDocBuilder {
b::delimiter(match self {
RangeInclusion::Exclusive => "(",
RangeInclusion::Inclusive => "[",
})
}
pub fn debug_right_bracket(&self) -> DebugDocBuilder {
pub fn debug_right_bracket(self) -> DebugDocBuilder {
b::delimiter(match self {
RangeInclusion::Exclusive => ")",
RangeInclusion::Inclusive => "]",

View File

@@ -9,7 +9,7 @@ where
serde::Serialize::serialize(
&big_decimal
.to_f64()
.ok_or(serde::ser::Error::custom("expected a f64-sized bignum"))?,
.ok_or_else(|| serde::ser::Error::custom("expected a f64-sized bignum"))?,
serializer,
)
}
@@ -20,5 +20,5 @@ where
{
let x: f64 = serde::Deserialize::deserialize(deserializer)?;
Ok(BigDecimal::from_f64(x)
.ok_or(serde::de::Error::custom("expected a f64-sized bigdecimal"))?)
.ok_or_else(|| serde::de::Error::custom("expected a f64-sized bigdecimal"))?)
}

View File

@@ -9,7 +9,7 @@ where
serde::Serialize::serialize(
&big_int
.to_i64()
.ok_or(serde::ser::Error::custom("expected a i64-sized bignum"))?,
.ok_or_else(|| serde::ser::Error::custom("expected a i64-sized bignum"))?,
serializer,
)
}
@@ -19,5 +19,6 @@ where
D: serde::Deserializer<'de>,
{
let x: i64 = serde::Deserialize::deserialize(deserializer)?;
Ok(BigInt::from_i64(x).ok_or(serde::de::Error::custom("expected a i64-sized bignum"))?)
Ok(BigInt::from_i64(x)
.ok_or_else(|| serde::de::Error::custom("expected a i64-sized bignum"))?)
}