Skip to content

Commit

Permalink
chore: address clippy complaints..
Browse files Browse the repository at this point in the history
.. brought by the new versions

Signed-off-by: Tiago Castro <[email protected]>
  • Loading branch information
tiagolobocastro committed Jun 27, 2024
1 parent 6379d04 commit 7a31e10
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 16 deletions.
2 changes: 1 addition & 1 deletion core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub mod im;
pub mod util;
#[cfg(feature = "v2")]
pub mod v2;
#[cfg(feature = "v3")]
// #[cfg(feature = "v3")]
pub mod v3;

pub use self::error::ValidationError;
Expand Down
3 changes: 2 additions & 1 deletion core/src/v2/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ pub enum DataTypeFormat {
Other,
}

#[allow(clippy::to_string_trait_impl)]
impl ToString for DataTypeFormat {
fn to_string(&self) -> String {
match self {
Expand Down Expand Up @@ -439,7 +440,7 @@ pub struct PathItem<P, R> {
impl<S> PathItem<Parameter<S>, Response<S>> {
/// Normalizes this operation map.
/// - Collects and removes parameters shared across operations
/// and adds them to the list global to this map.
/// and adds them to the list global to this map.
pub fn normalize(&mut self) {
// We're using `Option<BTreeSet>` over `BTreeSet` because we need to
// differentiate between the first operation that we use for initial
Expand Down
6 changes: 3 additions & 3 deletions core/src/v2/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,11 @@ impl_type_simple!(std::net::Ipv6Addr, DataType::String, DataTypeFormat::IpV6);
/// framework-specific macros:
///
/// - [`Apiv2Schema`](https://paperclip-rs.github.io/paperclip/paperclip_actix/derive.Apiv2Schema.html)
/// for schema objects.
/// for schema objects.
/// - [`Apiv2Security`](https://paperclip-rs.github.io/paperclip/paperclip_actix/derive.Apiv2Security.html)
/// for security scheme objects.
/// for security scheme objects.
/// - [`Apiv2Header`](https://paperclip-rs.github.io/paperclip/paperclip_actix/derive.Apiv2Header.html)
/// for header parameters objects.
/// for header parameters objects.
///
/// This is implemented for primitive types by default.
pub trait Apiv2Schema {
Expand Down
6 changes: 0 additions & 6 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ pub enum PaperClipError {
/// YAML coding errors.
#[error("YAML error: {}", _0)]
Yaml(serde_yaml::Error),
#[cfg(feature = "codegen-fmt")]
/// Errors from rustfmt.
#[error("Rustfmt formatting error: {}", _0)]
RustFmt(rustfmt_nightly::ErrorKind),
#[cfg(feature = "codegen")]
/// Errors in templating.
#[error("Templating error: {}", _0)]
Expand All @@ -73,7 +69,5 @@ impl_err_from!(PaperClipError::std::io::Error > Io);
impl_err_from!(PaperClipError::serde_json::Error > Json);
impl_err_from!(PaperClipError::serde_yaml::Error > Yaml);
impl_err_from!(PaperClipError::paperclip_core::ValidationError > Validation);
#[cfg(feature = "codegen-fmt")]
impl_err_from!(PaperClipError::rustfmt_nightly::ErrorKind > RustFmt);
#[cfg(feature = "codegen")]
impl_err_from!(PaperClipError::tinytemplate::error::Error > Templating);
4 changes: 2 additions & 2 deletions src/v2/codegen/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ impl<'a, 'b> SendableCodegen<'a, 'b> {
/// Handle field for a form data parameter.
fn handle_form_param(&mut self, field: StructField) {
let name = object::to_snake_case(field.name);
if let Some(CollectionFormat::Multi) = field.delimiting.get(0) {
if let Some(CollectionFormat::Multi) = field.delimiting.first() {
let _ = write!(
self.form,
"
Expand Down Expand Up @@ -988,7 +988,7 @@ impl<'a, 'b> SendableCodegen<'a, 'b> {
/// Handle field for an URL query parameter.
fn handle_query_param(&mut self, field: StructField) {
let name = object::to_snake_case(field.name);
if let Some(CollectionFormat::Multi) = field.delimiting.get(0) {
if let Some(CollectionFormat::Multi) = field.delimiting.first() {
self.multi_value_query.push(format!(
"
&self.{}param_{}.as_ref().map(|v| {{
Expand Down
2 changes: 1 addition & 1 deletion src/v2/codegen/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,7 @@ impl ApiObject {

// FIXME: Currently, we're implementing the first value as enum default.
// If "default" field exists, then we should use that instead.
if let Some(var) = self.variants().get(0) {
if let Some(var) = self.variants().first() {
writeln!(
f,
"impl Default for {name} {{
Expand Down
4 changes: 2 additions & 2 deletions src/v2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@
//! raw schema. During resolution, we:
//!
//! - walk through the nodes, find `$ref` fields and assign references to
//! the actual definitions.
//! the actual definitions.
//! - identify anonymous definitions in body parameters and response schemas
//! and add them to the known map of definitions.
//! and add them to the known map of definitions.
//!
//! ```rust,no_run
//! #[cfg(feature = "codegen")] {
Expand Down

0 comments on commit 7a31e10

Please sign in to comment.