chore: fix clippy
Signed-off-by: Dmitry Dygalo <dmitry@dygalo.dev>
This commit is contained in:
parent
52cf5683d6
commit
c7ca4119ba
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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<BigValidatorsMap> {
|
|||
impl<M: PropertiesValidatorsMap> Validate for AdditionalPropertiesWithPatternsNotEmptyValidator<M> {
|
||||
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<M: PropertiesValidatorsMap> 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<M: PropertiesValidatorsMap> 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<M: PropertiesValidatorsMap> 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<M: PropertiesValidatorsMap> 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<M: PropertiesValidatorsMap> 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);
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -145,7 +145,7 @@ pub(crate) fn convert_regex(pattern: &str) -> Result<fancy_regex::Regex, fancy_r
|
|||
fancy_regex::Regex::new(&out)
|
||||
}
|
||||
|
||||
#[allow(clippy::integer_arithmetic)]
|
||||
#[allow(clippy::arithmetic_side_effects)]
|
||||
fn replace_control_group(captures: ®ex::Captures) -> String {
|
||||
// There will be no overflow, because the minimum value is 65 (char 'A')
|
||||
((captures
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<Self::Item> {
|
||||
while self.idx <= 7 {
|
||||
let bit_value = 1 << self.idx;
|
||||
|
|
|
@ -87,7 +87,7 @@ impl SchemaNode {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) fn validators(&self) -> impl Iterator<Item = &BoxedValidator> + ExactSizeIterator {
|
||||
pub(crate) fn validators(&self) -> impl ExactSizeIterator<Item = &BoxedValidator> {
|
||||
match &self.validators {
|
||||
NodeValidators::Boolean { validator } => {
|
||||
if let Some(v) = validator {
|
||||
|
|
Loading…
Reference in New Issue