From 22634ac06cfcb221954e1024cab1382169f464ba Mon Sep 17 00:00:00 2001 From: HalidOdat Date: Sat, 31 Jul 2021 16:21:20 +0200 Subject: [PATCH] Fix clippy errors --- boa/src/builtins/array/mod.rs | 2 +- boa/src/builtins/boolean/tests.rs | 20 ++++++++--------- boa/src/builtins/function/tests.rs | 6 ++--- boa/src/builtins/json/tests.rs | 13 +++++------ boa/src/builtins/mod.rs | 3 +++ boa/src/builtins/number/tests.rs | 36 +++++++++++++++--------------- boa/src/builtins/string/tests.rs | 4 ++-- boa/src/builtins/symbol/tests.rs | 2 +- boa/src/lib.rs | 5 ----- boa/src/syntax/mod.rs | 2 ++ boa/src/value/tests.rs | 26 +++++++++++---------- 11 files changed, 59 insertions(+), 60 deletions(-) diff --git a/boa/src/builtins/array/mod.rs b/boa/src/builtins/array/mod.rs index 570a691d277..17bf886bfa5 100644 --- a/boa/src/builtins/array/mod.rs +++ b/boa/src/builtins/array/mod.rs @@ -493,7 +493,7 @@ impl Array { // 5. For each element E of items, do for item in [Value::from(obj)].iter().chain(args.iter()) { // a. Let spreadable be ? IsConcatSpreadable(E). - let spreadable = Self::is_concat_spreadable(&item, context)?; + let spreadable = Self::is_concat_spreadable(item, context)?; // b. If spreadable is true, then if spreadable { // item is guaranteed to be an object since is_concat_spreadable checks it, diff --git a/boa/src/builtins/boolean/tests.rs b/boa/src/builtins/boolean/tests.rs index 20224b481c0..82a9b195116 100644 --- a/boa/src/builtins/boolean/tests.rs +++ b/boa/src/builtins/boolean/tests.rs @@ -13,8 +13,8 @@ fn construct_and_call() { let one = forward_val(&mut context, "one").unwrap(); let zero = forward_val(&mut context, "zero").unwrap(); - assert_eq!(one.is_object(), true); - assert_eq!(zero.is_boolean(), true); + assert!(one.is_object()); + assert!(zero.is_boolean()); } #[test] @@ -34,16 +34,16 @@ fn constructor_gives_true_instance() { let true_bool = forward_val(&mut context, "trueBool").expect("value expected"); // Values should all be objects - assert_eq!(true_val.is_object(), true); - assert_eq!(true_num.is_object(), true); - assert_eq!(true_string.is_object(), true); - assert_eq!(true_bool.is_object(), true); + assert!(true_val.is_object()); + assert!(true_num.is_object()); + assert!(true_string.is_object()); + assert!(true_bool.is_object()); // Values should all be truthy - assert_eq!(true_val.to_boolean(), true); - assert_eq!(true_num.to_boolean(), true); - assert_eq!(true_string.to_boolean(), true); - assert_eq!(true_bool.to_boolean(), true); + assert!(true_val.to_boolean()); + assert!(true_num.to_boolean()); + assert!(true_string.to_boolean()); + assert!(true_bool.to_boolean()); } #[test] diff --git a/boa/src/builtins/function/tests.rs b/boa/src/builtins/function/tests.rs index b130f5b1489..f991519b491 100644 --- a/boa/src/builtins/function/tests.rs +++ b/boa/src/builtins/function/tests.rs @@ -15,7 +15,7 @@ fn arguments_object() { eprintln!("{}", forward(&mut context, init)); let return_val = forward_val(&mut context, "val").expect("value expected"); - assert_eq!(return_val.is_integer(), true); + assert!(return_val.is_integer()); assert_eq!( return_val .to_i32(&mut context) @@ -35,7 +35,7 @@ fn self_mutating_function_when_calling() { "#; eprintln!("{}", forward(&mut context, func)); let y = forward_val(&mut context, "x.y").expect("value expected"); - assert_eq!(y.is_integer(), true); + assert!(y.is_integer()); assert_eq!( y.to_i32(&mut context) .expect("Could not convert value to i32"), @@ -54,7 +54,7 @@ fn self_mutating_function_when_constructing() { "#; eprintln!("{}", forward(&mut context, func)); let y = forward_val(&mut context, "x.y").expect("value expected"); - assert_eq!(y.is_integer(), true); + assert!(y.is_integer()); assert_eq!( y.to_i32(&mut context) .expect("Could not convert value to i32"), diff --git a/boa/src/builtins/json/tests.rs b/boa/src/builtins/json/tests.rs index e91e07c4a65..8d6351f3573 100644 --- a/boa/src/builtins/json/tests.rs +++ b/boa/src/builtins/json/tests.rs @@ -425,14 +425,11 @@ fn json_parse_sets_prototypes() { .into(); let global_array_prototype: Value = context.standard_objects().array_object().prototype().into(); - assert_eq!( - Value::same_value(&object_prototype, &global_object_prototype), - true - ); - assert_eq!( - Value::same_value(&array_prototype, &global_array_prototype), - true - ); + assert!(Value::same_value( + &object_prototype, + &global_object_prototype + )); + assert!(Value::same_value(&array_prototype, &global_array_prototype)); } #[test] diff --git a/boa/src/builtins/mod.rs b/boa/src/builtins/mod.rs index 94c2f150991..5e7014f551c 100644 --- a/boa/src/builtins/mod.rs +++ b/boa/src/builtins/mod.rs @@ -1,5 +1,8 @@ //! Builtins live here, such as Object, String, Math, etc. +// builtins module has a lot of built-in functions that need unnecessary_wraps +#![allow(clippy::unnecessary_wraps)] + pub mod array; pub mod bigint; pub mod boolean; diff --git a/boa/src/builtins/number/tests.rs b/boa/src/builtins/number/tests.rs index 634c527963c..69ae509ff7f 100644 --- a/boa/src/builtins/number/tests.rs +++ b/boa/src/builtins/number/tests.rs @@ -434,23 +434,23 @@ fn value_of() { #[test] fn equal() { - assert_eq!(Number::equal(0.0, 0.0), true); - assert_eq!(Number::equal(-0.0, 0.0), true); - assert_eq!(Number::equal(0.0, -0.0), true); - assert_eq!(Number::equal(f64::NAN, -0.0), false); - assert_eq!(Number::equal(0.0, f64::NAN), false); + assert!(Number::equal(0.0, 0.0)); + assert!(Number::equal(-0.0, 0.0)); + assert!(Number::equal(0.0, -0.0)); + assert!(!Number::equal(f64::NAN, -0.0)); + assert!(!Number::equal(0.0, f64::NAN)); - assert_eq!(Number::equal(1.0, 1.0), true); + assert!(Number::equal(1.0, 1.0)); } #[test] fn same_value() { - assert_eq!(Number::same_value(0.0, 0.0), true); - assert_eq!(Number::same_value(-0.0, 0.0), false); - assert_eq!(Number::same_value(0.0, -0.0), false); - assert_eq!(Number::same_value(f64::NAN, -0.0), false); - assert_eq!(Number::same_value(0.0, f64::NAN), false); - assert_eq!(Number::equal(1.0, 1.0), true); + assert!(Number::same_value(0.0, 0.0)); + assert!(!Number::same_value(-0.0, 0.0)); + assert!(!Number::same_value(0.0, -0.0)); + assert!(!Number::same_value(f64::NAN, -0.0)); + assert!(!Number::same_value(0.0, f64::NAN)); + assert!(Number::equal(1.0, 1.0)); } #[test] @@ -483,12 +483,12 @@ fn less_than() { #[test] fn same_value_zero() { - assert_eq!(Number::same_value_zero(0.0, 0.0), true); - assert_eq!(Number::same_value_zero(-0.0, 0.0), true); - assert_eq!(Number::same_value_zero(0.0, -0.0), true); - assert_eq!(Number::same_value_zero(f64::NAN, -0.0), false); - assert_eq!(Number::same_value_zero(0.0, f64::NAN), false); - assert_eq!(Number::equal(1.0, 1.0), true); + assert!(Number::same_value_zero(0.0, 0.0)); + assert!(Number::same_value_zero(-0.0, 0.0)); + assert!(Number::same_value_zero(0.0, -0.0)); + assert!(!Number::same_value_zero(f64::NAN, -0.0)); + assert!(!Number::same_value_zero(0.0, f64::NAN)); + assert!(Number::equal(1.0, 1.0)); } #[test] diff --git a/boa/src/builtins/string/tests.rs b/boa/src/builtins/string/tests.rs index d9da4b23e1f..fbd0c2a13c4 100644 --- a/boa/src/builtins/string/tests.rs +++ b/boa/src/builtins/string/tests.rs @@ -107,8 +107,8 @@ fn construct_and_call() { let hello = forward_val(&mut context, "hello").unwrap(); let world = forward_val(&mut context, "world").unwrap(); - assert_eq!(hello.is_object(), true); - assert_eq!(world.is_string(), true); + assert!(hello.is_object()); + assert!(world.is_string()); } #[test] diff --git a/boa/src/builtins/symbol/tests.rs b/boa/src/builtins/symbol/tests.rs index f311d29c5e7..db1d362fa86 100644 --- a/boa/src/builtins/symbol/tests.rs +++ b/boa/src/builtins/symbol/tests.rs @@ -8,7 +8,7 @@ fn call_symbol_and_check_return_type() { "#; eprintln!("{}", forward(&mut context, init)); let sym = forward_val(&mut context, "sym").unwrap(); - assert_eq!(sym.is_symbol(), true); + assert!(sym.is_symbol()); } #[test] diff --git a/boa/src/lib.rs b/boa/src/lib.rs index 689f569f418..93387b717d7 100644 --- a/boa/src/lib.rs +++ b/boa/src/lib.rs @@ -13,7 +13,6 @@ This is an experimental Javascript lexer, parser and compiler written in Rust. C html_favicon_url = "https://raw.githubusercontent.com/jasonwilliams/boa/master/assets/logo.svg" )] #![deny( - unused_qualifications, clippy::all, unused_qualifications, unused_import_braces, @@ -43,8 +42,6 @@ This is an experimental Javascript lexer, parser and compiler written in Rust. C )] pub mod bigint; -// builtins module has a lot of built-in functions that need unnecessary_wraps -#[allow(clippy::unnecessary_wraps)] pub mod builtins; pub mod class; pub mod context; @@ -57,8 +54,6 @@ pub mod property; pub mod realm; pub mod string; pub mod symbol; -// syntax module has a lot of acronyms -#[allow(clippy::upper_case_acronyms)] pub mod syntax; pub mod value; diff --git a/boa/src/syntax/mod.rs b/boa/src/syntax/mod.rs index 802f7a1d195..d08d4ea8d28 100644 --- a/boa/src/syntax/mod.rs +++ b/boa/src/syntax/mod.rs @@ -1,4 +1,6 @@ //! Syntactical analysis, such as Abstract Syntax Tree (AST), Parsing and Lexing +// syntax module has a lot of acronyms +#![allow(clippy::upper_case_acronyms)] pub mod ast; pub mod lexer; diff --git a/boa/src/value/tests.rs b/boa/src/value/tests.rs index ed0ef7da5af..18ac1e7a696 100644 --- a/boa/src/value/tests.rs +++ b/boa/src/value/tests.rs @@ -10,15 +10,15 @@ use std::hash::{Hash, Hasher}; fn is_object() { let context = Context::new(); let val = Value::new_object(&context); - assert_eq!(val.is_object(), true); + assert!(val.is_object()); } #[test] fn string_to_value() { let s = String::from("Hello"); let v = Value::from(s); - assert_eq!(v.is_string(), true); - assert_eq!(v.is_null(), false); + assert!(v.is_string()); + assert!(!v.is_null()); } #[test] @@ -46,19 +46,19 @@ fn get_set_field() { #[test] fn integer_is_true() { - assert_eq!(Value::from(1).to_boolean(), true); - assert_eq!(Value::from(0).to_boolean(), false); - assert_eq!(Value::from(-1).to_boolean(), true); + assert!(Value::from(1).to_boolean()); + assert!(!Value::from(0).to_boolean()); + assert!(Value::from(-1).to_boolean()); } #[test] fn number_is_true() { - assert_eq!(Value::from(1.0).to_boolean(), true); - assert_eq!(Value::from(0.1).to_boolean(), true); - assert_eq!(Value::from(0.0).to_boolean(), false); - assert_eq!(Value::from(-0.0).to_boolean(), false); - assert_eq!(Value::from(-1.0).to_boolean(), true); - assert_eq!(Value::nan().to_boolean(), false); + assert!(Value::from(1.0).to_boolean()); + assert!(Value::from(0.1).to_boolean()); + assert!(!Value::from(0.0).to_boolean()); + assert!(!Value::from(-0.0).to_boolean()); + assert!(Value::from(-1.0).to_boolean()); + assert!(!Value::nan().to_boolean()); } // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Equality_comparisons_and_sameness @@ -757,6 +757,8 @@ mod cyclic_conversions { } mod abstract_relational_comparison { + #![allow(clippy::bool_assert_comparison)] + use super::*; macro_rules! check_comparison { ($context:ident, $string:expr => $expect:expr) => {