Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix clippy #458

Merged
merged 1 commit into from
Mar 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion jsonschema/src/compilation/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
18 changes: 9 additions & 9 deletions jsonschema/src/keywords/additional_properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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) {
Expand All @@ -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
Expand Down Expand Up @@ -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`
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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`
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion jsonschema/src/keywords/enum_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion jsonschema/src/keywords/one_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion jsonschema/src/keywords/pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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: &regex::Captures) -> String {
// There will be no overflow, because the minimum value is 65 (char 'A')
((captures
Expand Down
2 changes: 1 addition & 1 deletion jsonschema/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion jsonschema/src/primitive_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion jsonschema/src/schema_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading