chore: Appease clippy

This commit is contained in:
Mike Welsh 2021-01-18 19:32:52 -08:00
parent c2b768c453
commit da1e2801a2
15 changed files with 30 additions and 40 deletions

View File

@ -148,9 +148,7 @@ fn distance<'gc>(
.coerce_to_object(activation);
let b = args.get(1).unwrap_or(&Value::Undefined);
let delta = a.call_method("subtract", &[b.to_owned()], activation)?;
Ok(delta
.coerce_to_object(activation)
.get("length", activation)?)
delta.coerce_to_object(activation).get("length", activation)
}
fn polar<'gc>(
@ -176,14 +174,14 @@ fn interpolate<'gc>(
args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
if args.len() < 3 {
return Ok(point_to_object((NAN, NAN), activation)?);
return point_to_object((NAN, NAN), activation);
}
let a = value_to_point(args.get(0).unwrap().to_owned(), activation)?;
let b = value_to_point(args.get(1).unwrap().to_owned(), activation)?;
let f = args.get(2).unwrap().coerce_to_f64(activation)?;
let result = (b.0 - (b.0 - a.0) * f, b.1 - (b.1 - a.1) * f);
Ok(point_to_object(result, activation)?)
point_to_object(result, activation)
}
fn to_string<'gc>(

View File

@ -269,8 +269,7 @@ impl BitmapData {
pub fn flood_fill(&mut self, x: u32, y: u32, replace_color: Color) {
let expected_color = self.get_pixel_raw(x, y).unwrap_or_else(|| 0.into());
let mut pending = Vec::new();
pending.push((x, y));
let mut pending = vec![(x, y)];
while !pending.is_empty() {
if let Some((x, y)) = pending.pop() {

View File

@ -126,11 +126,7 @@ macro_rules! test_method {
let function = object.get($name, activation)?;
$(
#[allow(unused_mut)]
let mut args: Vec<Value> = Vec::new();
$(
args.push($arg.into());
)*
let args: Vec<Value> = vec![$($arg.into()),*];
assert_eq!(function.call($name, activation, object, None, &args)?, $out.into(), "{:?} => {:?} in swf {}", args, $out, version);
)*

View File

@ -272,7 +272,7 @@ impl<'gc> Value<'gc> {
}
/// ECMA-262 2nd edition s. 11.9.3 Abstract equality comparison algorithm
#[allow(clippy::unknown_clippy_lints, clippy::unnested_or_patterns)]
#[allow(clippy::unnested_or_patterns)]
pub fn abstract_eq(
&self,
other: Value<'gc>,

View File

@ -34,9 +34,8 @@ fn to_string<'gc>(
this: Option<Object<'gc>>,
_: &[Value<'gc>],
) -> Result<Value<'gc>, Error> {
Ok(this
.map(|t| t.to_string(activation.context.gc_context))
.unwrap_or(Ok(Value::Undefined))?)
this.map(|t| t.to_string(activation.context.gc_context))
.unwrap_or(Ok(Value::Undefined))
}
/// Implements `Object.prototype.toLocaleString`
@ -45,9 +44,8 @@ fn to_locale_string<'gc>(
this: Option<Object<'gc>>,
_: &[Value<'gc>],
) -> Result<Value<'gc>, Error> {
Ok(this
.map(|t| t.to_locale_string(activation.context.gc_context))
.unwrap_or(Ok(Value::Undefined))?)
this.map(|t| t.to_locale_string(activation.context.gc_context))
.unwrap_or(Ok(Value::Undefined))
}
/// Implements `Object.prototype.valueOf`
@ -56,9 +54,8 @@ fn value_of<'gc>(
this: Option<Object<'gc>>,
_: &[Value<'gc>],
) -> Result<Value<'gc>, Error> {
Ok(this
.map(|t| t.value_of(activation.context.gc_context))
.unwrap_or(Ok(Value::Undefined))?)
this.map(|t| t.value_of(activation.context.gc_context))
.unwrap_or(Ok(Value::Undefined))
}
/// `Object.prototype.hasOwnProperty`

View File

@ -263,7 +263,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
}
if let Some(proto) = self.proto() {
return Ok(proto.resolve_multiname(multiname)?);
return proto.resolve_multiname(multiname);
}
Ok(None)

View File

@ -583,11 +583,7 @@ impl<'gc> Value<'gc> {
_ => unreachable!(),
};
Ok(PrimitiveObject::from_primitive(
self.clone(),
proto,
activation.context.gc_context,
)?)
PrimitiveObject::from_primitive(self.clone(), proto, activation.context.gc_context)
}
/// Determine if two values are abstractly equal to each other.

View File

@ -1,6 +1,5 @@
use num_enum::{IntoPrimitive, TryFromPrimitive};
#[allow(clippy::enum_variant_names)]
#[derive(Debug)]
pub enum PlayerEvent {
KeyDown { key_code: KeyCode },

View File

@ -1,8 +1,8 @@
#![allow(
clippy::manual_range_contains,
clippy::unneeded_field_pattern,
clippy::same_item_push,
renamed_and_removed_lints,
clippy::unknown_clippy_lints,
clippy::manual_range_contains,
clippy::same_item_push,
clippy::unnecessary_wraps
)]

View File

@ -1,5 +1,3 @@
#![allow(clippy::unneeded_field_pattern)]
mod audio;
mod custom_event;
mod executor;

View File

@ -1,5 +1,3 @@
#![allow(clippy::useless_attribute)]
#[derive(Debug, PartialEq, Clone, Copy, FromPrimitive)]
pub enum OpCode {
Add = 0xA0,

View File

@ -6,7 +6,7 @@
//!
//! This library consists of a `read` module for decoding SWF data, and a `write` library for
//! writing SWF data.
#![allow(clippy::unusual_byte_groupings, clippy::unknown_clippy_lints)]
#![allow(clippy::unusual_byte_groupings)]
extern crate byteorder;
#[cfg(feature = "flate2")]

View File

@ -1,7 +1,8 @@
#![allow(
renamed_and_removed_lints,
clippy::unknown_clippy_lints,
clippy::float_cmp,
clippy::inconsistent_digit_grouping,
clippy::unknown_clippy_lints,
clippy::unreadable_literal
)]

View File

@ -1,4 +1,8 @@
#![allow(clippy::suspicious_operation_groupings)]
#![allow(
renamed_and_removed_lints,
clippy::unknown_clippy_lints,
clippy::suspicious_operation_groupings
)]
use crate::Twips;

View File

@ -1,4 +1,8 @@
#![allow(clippy::same_item_push, clippy::unknown_clippy_lints)]
#![allow(
renamed_and_removed_lints,
clippy::same_item_push,
clippy::unknown_clippy_lints
)]
//! Ruffle web frontend.
mod audio;