resolve all clippy lints
This commit is contained in:
parent
72f62ce711
commit
b64ad5b1f3
@ -73,6 +73,7 @@ impl For {
|
||||
Ok(stmts)
|
||||
}
|
||||
|
||||
#[allow(clippy::range_plus_one)]
|
||||
pub fn iter(&self) -> ForIterator {
|
||||
if self.from < self.to {
|
||||
ForIterator::Forward(self.from..(self.to + self.through))
|
||||
|
@ -172,6 +172,7 @@ impl AtRule {
|
||||
body.push(toks.next().unwrap());
|
||||
devour_whitespace(toks);
|
||||
let mut styles = Vec::new();
|
||||
#[allow(clippy::unnecessary_filter_map)]
|
||||
let raw_stmts = eat_stmts_at_root(
|
||||
&mut body.into_iter().peekmore(),
|
||||
scope,
|
||||
|
@ -86,6 +86,7 @@ fn type_of(mut args: CallArgs, scope: &Scope, super_selector: &Selector) -> Sass
|
||||
|
||||
fn unitless(mut args: CallArgs, scope: &Scope, super_selector: &Selector) -> SassResult<Value> {
|
||||
args.max_args(1)?;
|
||||
#[allow(clippy::match_same_arms)]
|
||||
Ok(match arg!(args, scope, super_selector, 0, "number") {
|
||||
Value::Dimension(_, Unit::None) => Value::True,
|
||||
Value::Dimension(_, _) => Value::False,
|
||||
|
@ -346,6 +346,7 @@ fn str_insert(mut args: CallArgs, scope: &Scope, super_selector: &Selector) -> S
|
||||
}
|
||||
|
||||
#[cfg(feature = "random")]
|
||||
#[allow(clippy::needless_pass_by_value)]
|
||||
fn unique_id(args: CallArgs, _: &Scope, _: &Selector) -> SassResult<Value> {
|
||||
args.max_args(0)?;
|
||||
let mut rng = thread_rng();
|
||||
|
@ -154,6 +154,7 @@ impl Default for Identifier {
|
||||
}
|
||||
|
||||
impl Identifier {
|
||||
#[allow(clippy::missing_const_for_fn)]
|
||||
pub fn into_inner(self) -> String {
|
||||
self.0
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ pub(crate) fn import(
|
||||
if path.is_absolute() {
|
||||
todo!("absolute import")
|
||||
}
|
||||
let path_buf = ctx.parent().unwrap_or(Path::new("")).join(path);
|
||||
let path_buf = ctx.parent().unwrap_or_else(|| Path::new("")).join(path);
|
||||
// "todo: will panic if path ended in `..`"
|
||||
let name = path_buf.file_name().unwrap();
|
||||
if path_buf.extension() == Some(OsStr::new(".css")) {
|
||||
|
14
src/lib.rs
14
src/lib.rs
@ -50,9 +50,6 @@ grass input.scss
|
||||
// this is too pedantic for now -- the library is changing too quickly for
|
||||
// good docs to be written
|
||||
clippy::missing_errors_doc,
|
||||
// this incorrectly results in errors for types that derive `Debug`
|
||||
// https://github.com/rust-lang/rust-clippy/issues/4980
|
||||
// clippy::let_underscore_must_use,
|
||||
// this is too pedantic -- it results in some names being less explicit
|
||||
// than they should
|
||||
clippy::module_name_repetitions,
|
||||
@ -61,6 +58,7 @@ grass input.scss
|
||||
// filter isn't fallible
|
||||
clippy::filter_map,
|
||||
clippy::else_if_without_else,
|
||||
clippy::new_ret_no_self,
|
||||
|
||||
// temporarily allowed while under heavy development.
|
||||
// eventually these allows should be refactored away
|
||||
@ -74,9 +72,15 @@ grass input.scss
|
||||
clippy::cast_possible_truncation,
|
||||
clippy::single_match_else,
|
||||
clippy::indexing_slicing,
|
||||
// clippy::match_same_arms,
|
||||
// clippy::or_fun_call,
|
||||
clippy::redundant_pub_crate,
|
||||
|
||||
clippy::string_add,
|
||||
clippy::get_unwrap,
|
||||
clippy::unit_arg,
|
||||
clippy::wrong_self_convention,
|
||||
clippy::items_after_statements,
|
||||
clippy::shadow_reuse,
|
||||
clippy::shadow_unrelated,
|
||||
)]
|
||||
#![cfg_attr(feature = "nightly", feature(track_caller))]
|
||||
#![cfg_attr(feature = "profiling", inline(never))]
|
||||
|
@ -378,6 +378,7 @@ impl<'a> StyleSheetParser<'a> {
|
||||
node: Stmt::Style(s),
|
||||
span,
|
||||
}),
|
||||
#[allow(clippy::match_same_arms)]
|
||||
Expr::AtRule(a) => match a {
|
||||
AtRule::For(f) => stmts.extend(f.ruleset_eval(scope, super_selector, None)?),
|
||||
AtRule::While(w) => {
|
||||
|
@ -214,7 +214,7 @@ impl From<i64> for Number {
|
||||
}
|
||||
}
|
||||
|
||||
// todo: implement std::convertTryFrom instead
|
||||
#[allow(clippy::fallible_impl_from)]
|
||||
impl From<f64> for Number {
|
||||
fn from(b: f64) -> Self {
|
||||
Number::Big(BigRational::from_float(b).unwrap())
|
||||
|
@ -77,7 +77,7 @@ impl Value {
|
||||
}
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
},
|
||||
s => s == other.eval(span)?.node,
|
||||
})
|
||||
.span(span))
|
||||
@ -151,7 +151,7 @@ impl Value {
|
||||
}
|
||||
}
|
||||
_ => true,
|
||||
}
|
||||
},
|
||||
s => s != other.eval(span)?.node,
|
||||
})
|
||||
.span(span))
|
||||
@ -487,11 +487,7 @@ impl Value {
|
||||
)
|
||||
}
|
||||
}
|
||||
Self::List(..) => Value::String(
|
||||
format!("{}{}-{}", num, unit, other.to_css_string(span)?),
|
||||
QuoteKind::None,
|
||||
),
|
||||
Self::String(..) => Value::String(
|
||||
Self::List(..) | Self::String(..) => Value::String(
|
||||
format!("{}{}-{}", num, unit, other.to_css_string(span)?),
|
||||
QuoteKind::None,
|
||||
),
|
||||
|
@ -431,7 +431,7 @@ fn single_value<I: Iterator<Item = Token>>(
|
||||
})
|
||||
}
|
||||
|
||||
fn parse_i64(s: String) -> i64 {
|
||||
fn parse_i64(s: &str) -> i64 {
|
||||
s.as_bytes()
|
||||
.iter()
|
||||
.fold(0, |total, this| total * 10 + i64::from(this - b'0'))
|
||||
@ -741,7 +741,7 @@ impl Value {
|
||||
|
||||
let n = if val.dec_len == 0 {
|
||||
if val.num.len() <= 18 && val.times_ten.is_empty() {
|
||||
let n = Rational64::new_raw(parse_i64(val.num), 1);
|
||||
let n = Rational64::new_raw(parse_i64(&val.num), 1);
|
||||
return Some(Ok(IntermediateValue::Value(Value::Dimension(
|
||||
Number::new_machine(n),
|
||||
unit,
|
||||
@ -751,7 +751,7 @@ impl Value {
|
||||
BigRational::new_raw(val.num.parse::<BigInt>().unwrap(), BigInt::one())
|
||||
} else {
|
||||
if val.num.len() <= 18 && val.times_ten.is_empty() {
|
||||
let n = Rational64::new(parse_i64(val.num), pow(10, val.dec_len));
|
||||
let n = Rational64::new(parse_i64(&val.num), pow(10, val.dec_len));
|
||||
return Some(Ok(IntermediateValue::Value(Value::Dimension(
|
||||
Number::new_machine(n),
|
||||
unit,
|
||||
@ -884,9 +884,10 @@ impl Value {
|
||||
IntermediateValue::Comma.span(span)
|
||||
}
|
||||
q @ '>' | q @ '<' => {
|
||||
let mut span = toks.next().unwrap().pos();
|
||||
let mut span = toks.next().unwrap().pos;
|
||||
#[allow(clippy::eval_order_dependence)]
|
||||
IntermediateValue::Op(if let Some(Token { kind: '=', .. }) = toks.peek() {
|
||||
span = span.merge(toks.next().unwrap().pos());
|
||||
span = span.merge(toks.next().unwrap().pos);
|
||||
match q {
|
||||
'>' => Op::GreaterThanEqual,
|
||||
'<' => Op::LessThanEqual,
|
||||
|
Loading…
x
Reference in New Issue
Block a user