diff --git a/jsonschema/src/compilation/options.rs b/jsonschema/src/compilation/options.rs index 0edb0e86..d020e595 100644 --- a/jsonschema/src/compilation/options.rs +++ b/jsonschema/src/compilation/options.rs @@ -558,7 +558,7 @@ impl CompilationOptions { /// The example above is taken from the Swagger 2.0 JSON schema. #[inline] pub fn with_meta_schemas(&mut self) -> &mut Self { - self.store.extend(META_SCHEMAS.clone().into_iter()); + self.store.extend(META_SCHEMAS.clone()); self } diff --git a/jsonschema/src/keywords/additional_properties.rs b/jsonschema/src/keywords/additional_properties.rs index d8b9bb0f..cfca638f 100644 --- a/jsonschema/src/keywords/additional_properties.rs +++ b/jsonschema/src/keywords/additional_properties.rs @@ -124,7 +124,7 @@ impl Validate for AdditionalPropertiesValidator { if let Value::Object(item) = instance { let mut matched_props = Vec::with_capacity(item.len()); let mut output = BasicOutput::default(); - for (name, value) in item.iter() { + for (name, value) in item { let path = instance_path.push(name.to_string()); output += self.node.apply_rooted(value, &path); matched_props.push(name.clone()); @@ -507,7 +507,7 @@ impl AdditionalPropertiesWithPatternsValidator { impl Validate for AdditionalPropertiesWithPatternsValidator { fn is_valid(&self, instance: &Value) -> bool { if let Value::Object(item) = instance { - for (property, value) in item.iter() { + for (property, value) in item { let mut has_match = false; for (re, node) in &self.patterns { if re.is_match(property).unwrap_or(false) { @@ -530,7 +530,7 @@ impl Validate for AdditionalPropertiesWithPatternsValidator { ) -> ErrorIterator<'instance> { if let Value::Object(item) = instance { let mut errors = vec![]; - for (property, value) in item.iter() { + for (property, value) in item { let mut has_match = false; errors.extend( self.patterns @@ -824,7 +824,7 @@ impl AdditionalPropertiesWithPatternsNotEmptyValidator { impl Validate for AdditionalPropertiesWithPatternsNotEmptyValidator { fn is_valid(&self, instance: &Value) -> bool { if let Value::Object(item) = instance { - for (property, value) in item.iter() { + for (property, value) in item { if let Some(node) = self.properties.get_validator(property) { if is_valid!(node, value) { // Valid for `properties`, check `patternProperties` @@ -865,7 +865,7 @@ impl Validate for AdditionalPropertiesWithPatternsNo ) -> ErrorIterator<'instance> { if let Value::Object(item) = instance { let mut errors = vec![]; - for (property, value) in item.iter() { + for (property, value) in item { if let Some((name, node)) = self.properties.get_key_validator(property) { errors.extend(validate!(node, value, instance_path, name)); errors.extend( @@ -904,7 +904,7 @@ impl Validate for AdditionalPropertiesWithPatternsNo if let Value::Object(item) = instance { let mut output = BasicOutput::default(); let mut additional_matches = Vec::with_capacity(item.len()); - for (property, value) in item.iter() { + for (property, value) in item { let path = instance_path.push(property.clone()); if let Some((_name, node)) = self.properties.get_key_validator(property) { output += node.apply_rooted(value, &path); @@ -1017,7 +1017,7 @@ impl Validate fn is_valid(&self, instance: &Value) -> bool { if let Value::Object(item) = instance { // No properties are allowed, except ones defined in `properties` or `patternProperties` - for (property, value) in item.iter() { + for (property, value) in item { if let Some(node) = self.properties.get_validator(property) { if is_valid!(node, value) { // Valid for `properties`, check `patternProperties` @@ -1048,7 +1048,7 @@ impl Validate let mut errors = vec![]; let mut unexpected = vec![]; // No properties are allowed, except ones defined in `properties` or `patternProperties` - for (property, value) in item.iter() { + for (property, value) in item { if let Some((name, node)) = self.properties.get_key_validator(property) { errors.extend(validate!(node, value, instance_path, name)); errors.extend( @@ -1096,7 +1096,7 @@ impl Validate let mut output = BasicOutput::default(); let mut unexpected = vec![]; // No properties are allowed, except ones defined in `properties` or `patternProperties` - for (property, value) in item.iter() { + for (property, value) in item { let path = instance_path.push(property.clone()); if let Some((_name, node)) = self.properties.get_key_validator(property) { output += node.apply_rooted(value, &path); diff --git a/jsonschema/src/keywords/enum_.rs b/jsonschema/src/keywords/enum_.rs index 836a953a..7bfde7a0 100644 --- a/jsonschema/src/keywords/enum_.rs +++ b/jsonschema/src/keywords/enum_.rs @@ -25,7 +25,7 @@ impl EnumValidator { schema_path: JSONPointer, ) -> CompilationResult<'a> { let mut types = PrimitiveTypesBitMap::new(); - for item in items.iter() { + for item in items { types |= PrimitiveType::from(item); } Ok(Box::new(EnumValidator { diff --git a/jsonschema/src/keywords/one_of.rs b/jsonschema/src/keywords/one_of.rs index 140e996b..e97455a9 100644 --- a/jsonschema/src/keywords/one_of.rs +++ b/jsonschema/src/keywords/one_of.rs @@ -54,7 +54,7 @@ impl OneOfValidator { first_valid_idx } - #[allow(clippy::integer_arithmetic)] + #[allow(clippy::arithmetic_side_effects)] fn are_others_valid(&self, instance: &Value, idx: usize) -> bool { // `idx + 1` will not overflow, because the maximum possible value there is `usize::MAX - 1` // For example we have `usize::MAX` schemas and only the last one is valid, then diff --git a/jsonschema/src/keywords/pattern.rs b/jsonschema/src/keywords/pattern.rs index de11ef8e..50a51ad9 100644 --- a/jsonschema/src/keywords/pattern.rs +++ b/jsonschema/src/keywords/pattern.rs @@ -145,7 +145,7 @@ pub(crate) fn convert_regex(pattern: &str) -> Result String { // There will be no overflow, because the minimum value is 65 (char 'A') ((captures diff --git a/jsonschema/src/lib.rs b/jsonschema/src/lib.rs index e43b98bb..4dda3f19 100644 --- a/jsonschema/src/lib.rs +++ b/jsonschema/src/lib.rs @@ -82,7 +82,7 @@ clippy::upper_case_acronyms, clippy::needless_collect )] -#![cfg_attr(not(test), allow(clippy::integer_arithmetic, clippy::unwrap_used))] +#![cfg_attr(not(test), allow(clippy::arithmetic_side_effects, clippy::unwrap_used))] mod compilation; mod content_encoding; mod content_media_type; diff --git a/jsonschema/src/primitive_type.rs b/jsonschema/src/primitive_type.rs index 06fed2cb..eeb76123 100644 --- a/jsonschema/src/primitive_type.rs +++ b/jsonschema/src/primitive_type.rs @@ -142,7 +142,7 @@ pub struct PrimitiveTypesBitMapIterator { } impl Iterator for PrimitiveTypesBitMapIterator { type Item = PrimitiveType; - #[allow(clippy::integer_arithmetic)] + #[allow(clippy::arithmetic_side_effects)] fn next(&mut self) -> Option { while self.idx <= 7 { let bit_value = 1 << self.idx; diff --git a/jsonschema/src/schema_node.rs b/jsonschema/src/schema_node.rs index b21b9f8c..806d4c8c 100644 --- a/jsonschema/src/schema_node.rs +++ b/jsonschema/src/schema_node.rs @@ -87,7 +87,7 @@ impl SchemaNode { } } - pub(crate) fn validators(&self) -> impl Iterator + ExactSizeIterator { + pub(crate) fn validators(&self) -> impl ExactSizeIterator { match &self.validators { NodeValidators::Boolean { validator } => { if let Some(v) = validator {