Add #[allow(clippy::all, clippy::pedantic)] for all macros generated code. #192

This commit is contained in:
Sunli 2020-06-28 14:28:53 +08:00
parent 6565e0aad7
commit 914b308ec2
8 changed files with 26 additions and 4 deletions

View File

@ -75,12 +75,14 @@ pub fn generate(enum_args: &args::Enum, input: &DeriveInput) -> Result<TokenStre
}
let expanded = quote! {
#[allow(clippy::all, clippy::pedantic)]
impl #crate_name::EnumType for #ident {
fn items() -> &'static [#crate_name::EnumItem<#ident>] {
&[#(#items),*]
}
}
#[allow(clippy::all, clippy::pedantic)]
impl #crate_name::Type for #ident {
fn type_name() -> ::std::borrow::Cow<'static, str> {
::std::borrow::Cow::Borrowed(#gql_typename)
@ -101,6 +103,7 @@ pub fn generate(enum_args: &args::Enum, input: &DeriveInput) -> Result<TokenStre
}
}
#[allow(clippy::all, clippy::pedantic)]
impl #crate_name::InputValueType for #ident {
fn parse(value: Option<#crate_name::Value>) -> #crate_name::InputValueResult<Self> {
#crate_name::EnumType::parse_enum(value.unwrap_or_default())

View File

@ -99,6 +99,7 @@ pub fn generate(object_args: &args::InputObject, input: &DeriveInput) -> Result<
}
let expanded = quote! {
#[allow(clippy::all, clippy::pedantic)]
impl #crate_name::Type for #ident {
fn type_name() -> ::std::borrow::Cow<'static, str> {
::std::borrow::Cow::Borrowed(#gql_typename)
@ -117,6 +118,7 @@ pub fn generate(object_args: &args::InputObject, input: &DeriveInput) -> Result<
}
}
#[allow(clippy::all, clippy::pedantic)]
impl #crate_name::InputValueType for #ident {
fn parse(value: Option<#crate_name::Value>) -> #crate_name::InputValueResult<Self> {
use #crate_name::Type;

View File

@ -76,6 +76,7 @@ pub fn generate(interface_args: &args::Interface, input: &DeriveInput) -> Result
}
type_into_impls.push(quote! {
#[allow(clippy::all, clippy::pedantic)]
impl #generics From<#p> for #ident #generics {
fn from(obj: #p) -> Self {
#ident::#enum_name(obj)
@ -263,10 +264,12 @@ pub fn generate(interface_args: &args::Interface, input: &DeriveInput) -> Result
let expanded = quote! {
#(#type_into_impls)*
#[allow(clippy::all, clippy::pedantic)]
impl #generics #ident #generics {
#(#methods)*
}
#[allow(clippy::all, clippy::pedantic)]
impl #generics #crate_name::Type for #ident #generics {
fn type_name() -> ::std::borrow::Cow<'static, str> {
::std::borrow::Cow::Borrowed(#gql_typename)
@ -300,6 +303,7 @@ pub fn generate(interface_args: &args::Interface, input: &DeriveInput) -> Result
}
}
#[allow(clippy::all, clippy::pedantic)]
#[#crate_name::async_trait::async_trait]
impl #generics #crate_name::ObjectType for #ident #generics {
async fn resolve_field(&self, ctx: &#crate_name::Context<'_>) -> #crate_name::Result<#crate_name::serde_json::Value> {
@ -321,6 +325,7 @@ pub fn generate(interface_args: &args::Interface, input: &DeriveInput) -> Result
}
}
#[allow(clippy::all, clippy::pedantic)]
#[#crate_name::async_trait::async_trait]
impl #generics #crate_name::OutputValueType for #ident #generics {
async fn resolve(&self, ctx: &#crate_name::ContextSelectionSet<'_>, _field: &#crate_name::Positioned<#crate_name::parser::query::Field>) -> #crate_name::Result<#crate_name::serde_json::Value> {

View File

@ -463,6 +463,7 @@ pub fn generate(object_args: &args::Object, item_impl: &mut ItemImpl) -> Result<
let expanded = quote! {
#item_impl
#[allow(clippy::all, clippy::pedantic)]
impl #generics #crate_name::Type for #self_ty #where_clause {
fn type_name() -> ::std::borrow::Cow<'static, str> {
::std::borrow::Cow::Borrowed(#gql_typename)
@ -487,7 +488,7 @@ pub fn generate(object_args: &args::Object, item_impl: &mut ItemImpl) -> Result<
}
}
#[allow(unused_braces, unused_parens)]
#[allow(clippy::all, clippy::pedantic)]
#[#crate_name::async_trait::async_trait]
impl#generics #crate_name::ObjectType for #self_ty #where_clause {
async fn resolve_field(&self, ctx: &#crate_name::Context<'_>) -> #crate_name::Result<#crate_name::serde_json::Value> {
@ -514,6 +515,7 @@ pub fn generate(object_args: &args::Object, item_impl: &mut ItemImpl) -> Result<
}
}
#[allow(clippy::all, clippy::pedantic)]
#[#crate_name::async_trait::async_trait]
impl #generics #crate_name::OutputValueType for #self_ty #where_clause {
async fn resolve(&self, ctx: &#crate_name::ContextSelectionSet<'_>, _field: &#crate_name::Positioned<#crate_name::parser::query::Field>) -> #crate_name::Result<#crate_name::serde_json::Value> {

View File

@ -31,6 +31,7 @@ pub fn generate(scalar_args: &args::Scalar, item_impl: &mut ItemImpl) -> Result<
let expanded = quote! {
#item_impl
#[allow(clippy::all, clippy::pedantic)]
impl #generic #crate_name::Type for #self_ty #where_clause {
fn type_name() -> ::std::borrow::Cow<'static, str> {
::std::borrow::Cow::Borrowed(#gql_typename)
@ -45,6 +46,7 @@ pub fn generate(scalar_args: &args::Scalar, item_impl: &mut ItemImpl) -> Result<
}
}
#[allow(clippy::all, clippy::pedantic)]
impl #generic #crate_name::InputValueType for #self_ty #where_clause {
fn parse(value: Option<#crate_name::Value>) -> #crate_name::InputValueResult<Self> {
<#self_ty as #crate_name::ScalarType>::parse(value.unwrap_or_default())
@ -55,7 +57,7 @@ pub fn generate(scalar_args: &args::Scalar, item_impl: &mut ItemImpl) -> Result<
}
}
#[allow(clippy::ptr_arg)]
#[allow(clippy::all, clippy::pedantic)]
#[#crate_name::async_trait::async_trait]
impl #generic #crate_name::OutputValueType for #self_ty #where_clause {
async fn resolve(

View File

@ -154,10 +154,12 @@ pub fn generate(object_args: &args::Object, input: &DeriveInput) -> Result<Token
};
let expanded = quote! {
#[allow(clippy::all, clippy::pedantic)]
impl #generics #ident #where_clause {
#(#getters)*
}
#[allow(clippy::all, clippy::pedantic)]
impl #generics #crate_name::Type for #ident #generics #where_clause {
fn type_name() -> ::std::borrow::Cow<'static, str> {
::std::borrow::Cow::Borrowed(#gql_typename)
@ -179,6 +181,7 @@ pub fn generate(object_args: &args::Object, input: &DeriveInput) -> Result<Token
}
}
#[allow(clippy::all, clippy::pedantic)]
#[#crate_name::async_trait::async_trait]
impl #generics #crate_name::ObjectType for #ident #generics #where_clause {
async fn resolve_field(&self, ctx: &#crate_name::Context<'_>) -> #crate_name::Result<#crate_name::serde_json::Value> {
@ -190,6 +193,7 @@ pub fn generate(object_args: &args::Object, input: &DeriveInput) -> Result<Token
}
}
#[allow(clippy::all, clippy::pedantic)]
#[#crate_name::async_trait::async_trait]
impl #generics #crate_name::OutputValueType for #ident #generics #where_clause {
async fn resolve(&self, ctx: &#crate_name::ContextSelectionSet<'_>, _field: &#crate_name::Positioned<#crate_name::parser::query::Field>) -> #crate_name::Result<#crate_name::serde_json::Value> {

View File

@ -310,6 +310,7 @@ pub fn generate(object_args: &args::Object, item_impl: &mut ItemImpl) -> Result<
let expanded = quote! {
#item_impl
#[allow(clippy::all, clippy::pedantic)]
impl #generics #crate_name::Type for #self_ty #where_clause {
fn type_name() -> ::std::borrow::Cow<'static, str> {
::std::borrow::Cow::Borrowed(#gql_typename)
@ -332,10 +333,9 @@ pub fn generate(object_args: &args::Object, item_impl: &mut ItemImpl) -> Result<
}
}
#[allow(clippy::all, clippy::pedantic)]
#[#crate_name::async_trait::async_trait]
impl #crate_name::SubscriptionType for #self_ty #where_clause {
#[allow(unused_variables)]
#[allow(bare_trait_objects)]
async fn create_field_stream(
&self,
idx: usize,

View File

@ -69,6 +69,7 @@ pub fn generate(union_args: &args::Interface, input: &DeriveInput) -> Result<Tok
enum_names.push(enum_name);
type_into_impls.push(quote! {
#[allow(clippy::all, clippy::pedantic)]
impl #generics From<#p> for #ident #generics {
fn from(obj: #p) -> Self {
#ident::#enum_name(obj)
@ -97,6 +98,7 @@ pub fn generate(union_args: &args::Interface, input: &DeriveInput) -> Result<Tok
let expanded = quote! {
#(#type_into_impls)*
#[allow(clippy::all, clippy::pedantic)]
impl #generics #crate_name::Type for #ident #generics {
fn type_name() -> ::std::borrow::Cow<'static, str> {
::std::borrow::Cow::Borrowed(#gql_typename)
@ -125,6 +127,7 @@ pub fn generate(union_args: &args::Interface, input: &DeriveInput) -> Result<Tok
}
}
#[allow(clippy::all, clippy::pedantic)]
#[#crate_name::async_trait::async_trait]
impl #generics #crate_name::ObjectType for #ident #generics {
async fn resolve_field(&self, ctx: &#crate_name::Context<'_>) -> #crate_name::Result<#crate_name::serde_json::Value> {
@ -145,6 +148,7 @@ pub fn generate(union_args: &args::Interface, input: &DeriveInput) -> Result<Tok
}
}
#[allow(clippy::all, clippy::pedantic)]
#[#crate_name::async_trait::async_trait]
impl #generics #crate_name::OutputValueType for #ident #generics {
async fn resolve(&self, ctx: &#crate_name::ContextSelectionSet<'_>, _field: &#crate_name::Positioned<#crate_name::parser::query::Field>) -> #crate_name::Result<#crate_name::serde_json::Value> {