This commit is contained in:
Connor Skees 2022-09-02 17:00:07 -04:00
parent 78f482c9bb
commit d349591926
12 changed files with 19 additions and 57 deletions

View File

@ -173,6 +173,7 @@ impl CallArgs {
let len = self.len();
if len > max {
let mut err = String::with_capacity(50);
#[allow(clippy::format_push_string)]
err.push_str(&format!("Only {} argument", max));
if max != 1 {
err.push('s');

View File

@ -172,7 +172,7 @@ pub(crate) fn unvendor(name: &str) -> &str {
return name;
}
if bytes.get(0_usize) != Some(&b'-') || bytes.get(1_usize) == Some(&b'-') {
if bytes.first() != Some(&b'-') || bytes.get(1_usize) == Some(&b'-') {
return name;
}

View File

@ -24,9 +24,7 @@ impl InternedString {
}
pub fn resolve_ref<'a>(self) -> &'a str {
unsafe {
STRINGS.with(|interner| &(*(interner.as_ptr()).as_ref().unwrap().resolve(&self.0)))
}
unsafe { STRINGS.with(|interner| interner.as_ptr().as_ref().unwrap().resolve(&self.0)) }
}
}

View File

@ -23,76 +23,38 @@ grass input.scss
```
*/
#![warn(
clippy::all,
clippy::restriction,
clippy::pedantic,
clippy::nursery,
clippy::cargo
)]
#![warn(clippy::all, clippy::pedantic, clippy::nursery, clippy::cargo)]
#![deny(missing_debug_implementations)]
#![allow(
// explicit return makes some things look ugly
clippy::implicit_return,
clippy::use_self,
clippy::missing_docs_in_private_items,
clippy::unreachable,
// this disallows binding as well, e.g. `v => ...`
clippy::wildcard_enum_match_arm,
clippy::module_name_repetitions,
// it is sometimes useful to break up `impl`s
clippy::multiple_inherent_impl,
// filter isn't fallible
clippy::manual_filter_map,
clippy::else_if_without_else,
clippy::new_ret_no_self,
renamed_and_removed_lints,
clippy::unknown_clippy_lints,
clippy::single_match,
clippy::float_arithmetic,
clippy::unimplemented,
clippy::pattern_type_mismatch,
clippy::blanket_clippy_restriction_lints,
clippy::option_if_let_else,
clippy::panic_in_result_fn,
clippy::unwrap_in_result,
clippy::map_err_ignore,
clippy::default_numeric_fallback,
clippy::if_then_some_else_none,
clippy::string_slice,
clippy::separated_literal_suffix,
clippy::non_ascii_literal,
clippy::same_name_method,
clippy::undocumented_unsafe_blocks,
clippy::exhaustive_structs,
clippy::single_char_lifetime_names,
clippy::branches_sharing_code,
clippy::derive_partial_eq_without_eq,
// temporarily allowed while under heavy development.
// eventually these allows should be refactored away
// to no longer be necessary
clippy::as_conversions,
clippy::todo,
clippy::too_many_lines,
clippy::panic,
clippy::unwrap_used,
clippy::unwrap_used,
clippy::cast_possible_truncation,
clippy::single_match_else,
clippy::indexing_slicing,
clippy::redundant_pub_crate,
// the api is changing too often to allot this
clippy::missing_errors_doc,
clippy::missing_const_for_fn,
clippy::multiple_crate_versions,
clippy::integer_arithmetic,
clippy::string_add,
clippy::get_unwrap,
clippy::wrong_self_convention,
clippy::items_after_statements,
clippy::shadow_reuse,
clippy::shadow_unrelated,
// this is only available on nightly
clippy::unnested_or_patterns,
)]

View File

@ -10,7 +10,7 @@ use grass::{from_path, from_string, Options, OutputStyle};
// TODO remove this
arg_enum! {
#[derive(PartialEq, Debug)]
#[derive(Eq, PartialEq, Debug)]
pub enum Style {
Expanded,
Compressed,
@ -18,7 +18,7 @@ arg_enum! {
}
arg_enum! {
#[derive(PartialEq, Debug)]
#[derive(Eq, PartialEq, Debug)]
pub enum SourceMapUrls {
Relative,
Absolute,

View File

@ -404,9 +404,10 @@ trait Formatter {
}
#[derive(Debug, Default)]
struct CompressedFormatter {}
struct CompressedFormatter;
impl Formatter for CompressedFormatter {
#[allow(clippy::only_used_in_recursion)]
fn write_css(&mut self, buf: &mut Vec<u8>, css: Css, map: &CodeMap) -> SassResult<()> {
for block in css.blocks {
match block {
@ -593,6 +594,7 @@ pub(crate) enum AtRuleContext {
}
impl Formatter for ExpandedFormatter {
#[allow(clippy::only_used_in_recursion)]
fn write_css(&mut self, buf: &mut Vec<u8>, css: Css, map: &CodeMap) -> SassResult<()> {
let padding = " ".repeat(self.nesting);
self.nesting += 1;

View File

@ -118,11 +118,11 @@ impl<'a, 'b> Parser<'a, 'b> {
}
let c = std::char::from_u32(value).ok_or(("Invalid Unicode code point.", span))?;
if (identifier_start && is_name_start(c) && !c.is_digit(10))
if (identifier_start && is_name_start(c) && !c.is_ascii_digit())
|| (!identifier_start && is_name(c))
{
Ok(c.to_string())
} else if value <= 0x1F || value == 0x7F || (identifier_start && c.is_digit(10)) {
} else if value <= 0x1F || value == 0x7F || (identifier_start && c.is_ascii_digit()) {
let mut buf = String::with_capacity(4);
buf.push('\\');
if value > 0xF {

View File

@ -1330,6 +1330,7 @@ impl<'a, 'b: 'a, 'c> IntermediateValueIterator<'a, 'b, 'c> {
Ok(())
}
#[allow(clippy::only_used_in_recursion)]
fn single_value(&mut self, in_paren: bool) -> SassResult<Spanned<HigherIntermediateValue>> {
let next = self
.next()

View File

@ -274,10 +274,7 @@ fn flatten_vertically<A: std::fmt::Debug>(iterable: Vec<Vec<A>>) -> Vec<A> {
result.push(queue.pop_front().unwrap());
}
queues = queues
.into_iter()
.filter(|queue| !queue.is_empty())
.collect();
queues.retain(|queue| !queue.is_empty());
}
result

View File

@ -196,7 +196,7 @@ impl Mul<Unit> for Unit {
Unit::Mul(u) => match rhs {
Unit::Mul(u2) => {
let mut unit1 = *u;
unit1.extend_from_slice(&*u2);
unit1.extend_from_slice(&u2);
Unit::Mul(Box::new(unit1))
}
Unit::Div(..) => todo!(),
@ -210,7 +210,7 @@ impl Mul<Unit> for Unit {
_ => match rhs {
Unit::Mul(u2) => {
let mut unit1 = vec![self];
unit1.extend_from_slice(&*u2);
unit1.extend_from_slice(&u2);
Unit::Mul(Box::new(unit1))
}
Unit::Div(..) => todo!(),

View File

@ -570,6 +570,7 @@ impl Value {
.0)
}
#[allow(clippy::only_used_in_recursion)]
fn selector_string(self, span: Span) -> SassResult<Option<String>> {
Ok(Some(match self {
Value::String(text, ..) => text,

View File

@ -141,8 +141,8 @@ impl Number {
#[allow(clippy::cast_precision_loss)]
pub fn as_float(self) -> Option<f64> {
Some(match self {
Number::Small(n) => ((*n.numer() as f64) / (*n.denom() as f64)),
Number::Big(n) => ((n.numer().to_f64()?) / (n.denom().to_f64()?)),
Number::Small(n) => (*n.numer() as f64) / (*n.denom() as f64),
Number::Big(n) => (n.numer().to_f64()?) / (n.denom().to_f64()?),
})
}