Fix Clippy warnings (#980)
This commit is contained in:
parent
6bb34b9b64
commit
b9257ef7d4
21 changed files with 36 additions and 38 deletions
|
@ -1,7 +1,4 @@
|
||||||
use juniper::{
|
use juniper::{graphql_object, GraphQLEnum};
|
||||||
graphql_object, graphql_value, EmptyMutation, EmptySubscription, GraphQLEnum, GraphQLError,
|
|
||||||
RootNode, Value,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[derive(GraphQLEnum)]
|
#[derive(GraphQLEnum)]
|
||||||
enum UserKind {
|
enum UserKind {
|
||||||
|
|
|
@ -87,7 +87,7 @@ where
|
||||||
|
|
||||||
/// The argument's name
|
/// The argument's name
|
||||||
pub fn name(&'a self) -> &str {
|
pub fn name(&'a self) -> &str {
|
||||||
&self.name
|
self.name
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The value of the argument
|
/// The value of the argument
|
||||||
|
@ -289,7 +289,7 @@ where
|
||||||
fragments,
|
fragments,
|
||||||
);
|
);
|
||||||
assert!(s.is_none());
|
assert!(s.is_none());
|
||||||
if let Some(ref c) = inline.item.type_condition.as_ref().map(|t| t.item) {
|
if let Some(c) = inline.item.type_condition.as_ref().map(|t| t.item) {
|
||||||
if let Some(p) = parent.children.last_mut() {
|
if let Some(p) = parent.children.last_mut() {
|
||||||
p.applies_for = Applies::OnlyType(c);
|
p.applies_for = Applies::OnlyType(c);
|
||||||
}
|
}
|
||||||
|
@ -308,7 +308,7 @@ where
|
||||||
.children
|
.children
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|c| match c.applies_for {
|
.filter_map(|c| match c.applies_for {
|
||||||
Applies::OnlyType(ref t) if *t == type_name => {
|
Applies::OnlyType(t) if t == type_name => {
|
||||||
Some(c.inner.for_explicit_type(type_name))
|
Some(c.inner.for_explicit_type(type_name))
|
||||||
}
|
}
|
||||||
Applies::All => Some(c.inner.for_explicit_type(type_name)),
|
Applies::All => Some(c.inner.for_explicit_type(type_name)),
|
||||||
|
|
|
@ -689,7 +689,7 @@ where
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if let Some(p) = found_field {
|
if let Some(p) = found_field {
|
||||||
LookAheadSelection::build_from_selection(&p, self.variables, self.fragments)
|
LookAheadSelection::build_from_selection(p, self.variables, self.fragments)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ where
|
||||||
{
|
{
|
||||||
// TODO: Remove in 0.17 `juniper` version.
|
// TODO: Remove in 0.17 `juniper` version.
|
||||||
/// Returns the `operation_name` associated with this request.
|
/// Returns the `operation_name` associated with this request.
|
||||||
#[deprecated(since = "0.16", note = "Use the direct field access instead.")]
|
#[deprecated(since = "0.16.0", note = "Use the direct field access instead.")]
|
||||||
pub fn operation_name(&self) -> Option<&str> {
|
pub fn operation_name(&self) -> Option<&str> {
|
||||||
self.operation_name.as_deref()
|
self.operation_name.as_deref()
|
||||||
}
|
}
|
||||||
|
|
|
@ -335,7 +335,7 @@ where
|
||||||
let operation = get_operation(&document, operation_name)?;
|
let operation = get_operation(&document, operation_name)?;
|
||||||
|
|
||||||
{
|
{
|
||||||
let errors = validate_input_values(&variables, operation, &root_node.schema);
|
let errors = validate_input_values(variables, operation, &root_node.schema);
|
||||||
|
|
||||||
if !errors.is_empty() {
|
if !errors.is_empty() {
|
||||||
return Err(GraphQLError::ValidationError(errors));
|
return Err(GraphQLError::ValidationError(errors));
|
||||||
|
|
|
@ -59,6 +59,7 @@ impl<T> Spanning<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
|
#[allow(clippy::self_named_constructors)]
|
||||||
pub fn spanning(v: Vec<Spanning<T>>) -> Option<Spanning<Vec<Spanning<T>>>> {
|
pub fn spanning(v: Vec<Spanning<T>>) -> Option<Spanning<Vec<Spanning<T>>>> {
|
||||||
if let (Some(start), Some(end)) = (v.first().map(|s| s.start), v.last().map(|s| s.end)) {
|
if let (Some(start), Some(end)) = (v.first().map(|s| s.start), v.last().map(|s| s.end)) {
|
||||||
Some(Spanning {
|
Some(Spanning {
|
||||||
|
|
|
@ -399,7 +399,7 @@ impl<'a, S> MetaType<'a, S> {
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|n| schema.concrete_type_by_name(n))
|
.filter_map(|n| schema.concrete_type_by_name(n))
|
||||||
.filter_map(|t| t.fields(schema))
|
.filter_map(|t| t.fields(schema))
|
||||||
.flat_map(|f| f)
|
.flatten()
|
||||||
.collect(),
|
.collect(),
|
||||||
),
|
),
|
||||||
_ => None,
|
_ => None,
|
||||||
|
|
|
@ -256,7 +256,7 @@ impl GraphQLParserTranslator {
|
||||||
.map(|a| {
|
.map(|a| {
|
||||||
a.iter()
|
a.iter()
|
||||||
.filter(|x| !x.is_builtin())
|
.filter(|x| !x.is_builtin())
|
||||||
.map(|x| GraphQLParserTranslator::translate_argument(&x))
|
.map(|x| GraphQLParserTranslator::translate_argument(x))
|
||||||
.collect()
|
.collect()
|
||||||
})
|
})
|
||||||
.unwrap_or_else(Vec::new);
|
.unwrap_or_else(Vec::new);
|
||||||
|
@ -300,7 +300,7 @@ fn generate_directives<'a, T>(status: &DeprecationStatus) -> Vec<ExternalDirecti
|
||||||
where
|
where
|
||||||
T: Text<'a>,
|
T: Text<'a>,
|
||||||
{
|
{
|
||||||
if let Some(d) = deprecation_to_directive(&status) {
|
if let Some(d) = deprecation_to_directive(status) {
|
||||||
vec![d]
|
vec![d]
|
||||||
} else {
|
} else {
|
||||||
vec![]
|
vec![]
|
||||||
|
|
|
@ -361,6 +361,7 @@ impl Database {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_character(&self, id: &str) -> Option<CharacterValue> {
|
pub fn get_character(&self, id: &str) -> Option<CharacterValue> {
|
||||||
|
#[allow(clippy::manual_map)]
|
||||||
if let Some(h) = self.humans.get(id) {
|
if let Some(h) = self.humans.get(id) {
|
||||||
Some(h.clone().into())
|
Some(h.clone().into())
|
||||||
} else if let Some(d) = self.droids.get(id) {
|
} else if let Some(d) = self.droids.get(id) {
|
||||||
|
|
|
@ -241,7 +241,7 @@ where
|
||||||
let exec_vars = executor.variables();
|
let exec_vars = executor.variables();
|
||||||
|
|
||||||
let sub_exec = executor.field_sub_executor(
|
let sub_exec = executor.field_sub_executor(
|
||||||
&response_name,
|
response_name,
|
||||||
f.name.item,
|
f.name.item,
|
||||||
*start_pos,
|
*start_pos,
|
||||||
f.selection_set.as_ref().map(|v| &v[..]),
|
f.selection_set.as_ref().map(|v| &v[..]),
|
||||||
|
@ -309,7 +309,7 @@ where
|
||||||
let type_name = instance.type_name(info);
|
let type_name = instance.type_name(info);
|
||||||
if executor
|
if executor
|
||||||
.schema()
|
.schema()
|
||||||
.is_named_subtype(&concrete_type_name, &fragment.type_condition.item)
|
.is_named_subtype(&concrete_type_name, fragment.type_condition.item)
|
||||||
|| Some(fragment.type_condition.item) == type_name
|
|| Some(fragment.type_condition.item) == type_name
|
||||||
{
|
{
|
||||||
let sub_result = instance
|
let sub_result = instance
|
||||||
|
@ -355,7 +355,7 @@ where
|
||||||
let concrete_type_name = instance.concrete_type_name(sub_exec.context(), info);
|
let concrete_type_name = instance.concrete_type_name(sub_exec.context(), info);
|
||||||
if executor
|
if executor
|
||||||
.schema()
|
.schema()
|
||||||
.is_named_subtype(&concrete_type_name, &type_condition.item)
|
.is_named_subtype(&concrete_type_name, type_condition.item)
|
||||||
{
|
{
|
||||||
let sub_result = instance
|
let sub_result = instance
|
||||||
.resolve_into_type_async(
|
.resolve_into_type_async(
|
||||||
|
|
|
@ -520,7 +520,7 @@ where
|
||||||
let type_name = instance.type_name(info);
|
let type_name = instance.type_name(info);
|
||||||
if executor
|
if executor
|
||||||
.schema()
|
.schema()
|
||||||
.is_named_subtype(&concrete_type_name, &fragment.type_condition.item)
|
.is_named_subtype(&concrete_type_name, fragment.type_condition.item)
|
||||||
|| Some(fragment.type_condition.item) == type_name
|
|| Some(fragment.type_condition.item) == type_name
|
||||||
{
|
{
|
||||||
let sub_result = instance.resolve_into_type(
|
let sub_result = instance.resolve_into_type(
|
||||||
|
@ -558,7 +558,7 @@ where
|
||||||
let concrete_type_name = instance.concrete_type_name(sub_exec.context(), info);
|
let concrete_type_name = instance.concrete_type_name(sub_exec.context(), info);
|
||||||
if executor
|
if executor
|
||||||
.schema()
|
.schema()
|
||||||
.is_named_subtype(&concrete_type_name, &type_condition.item)
|
.is_named_subtype(&concrete_type_name, type_condition.item)
|
||||||
{
|
{
|
||||||
let sub_result = instance.resolve_into_type(
|
let sub_result = instance.resolve_into_type(
|
||||||
info,
|
info,
|
||||||
|
|
|
@ -287,7 +287,7 @@ where
|
||||||
start: ref start_pos,
|
start: ref start_pos,
|
||||||
..
|
..
|
||||||
}) => {
|
}) => {
|
||||||
if is_excluded(&f.directives, &executor.variables()) {
|
if is_excluded(&f.directives, executor.variables()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,7 +327,7 @@ where
|
||||||
f.arguments.as_ref().map(|m| {
|
f.arguments.as_ref().map(|m| {
|
||||||
m.item
|
m.item
|
||||||
.iter()
|
.iter()
|
||||||
.map(|&(ref k, ref v)| (k.item, v.item.clone().into_const(&exec_vars)))
|
.map(|&(ref k, ref v)| (k.item, v.item.clone().into_const(exec_vars)))
|
||||||
.collect()
|
.collect()
|
||||||
}),
|
}),
|
||||||
&meta_field.arguments,
|
&meta_field.arguments,
|
||||||
|
@ -361,7 +361,7 @@ where
|
||||||
start: ref start_pos,
|
start: ref start_pos,
|
||||||
..
|
..
|
||||||
}) => {
|
}) => {
|
||||||
if is_excluded(&spread.directives, &executor.variables()) {
|
if is_excluded(&spread.directives, executor.variables()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -400,7 +400,7 @@ where
|
||||||
start: ref start_pos,
|
start: ref start_pos,
|
||||||
..
|
..
|
||||||
}) => {
|
}) => {
|
||||||
if is_excluded(&fragment.directives, &executor.variables()) {
|
if is_excluded(&fragment.directives, executor.variables()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -239,7 +239,7 @@ where
|
||||||
match *value {
|
match *value {
|
||||||
// TODO: avoid this bad duplicate as_str() call. (value system refactor)
|
// TODO: avoid this bad duplicate as_str() call. (value system refactor)
|
||||||
InputValue::Scalar(ref scalar) if scalar.as_str().is_some() => {
|
InputValue::Scalar(ref scalar) if scalar.as_str().is_some() => {
|
||||||
if let Some(ref name) = scalar.as_str() {
|
if let Some(name) = scalar.as_str() {
|
||||||
if !meta.values.iter().any(|ev| ev.name == *name) {
|
if !meta.values.iter().any(|ev| ev.name == *name) {
|
||||||
errors.push(unification_error(
|
errors.push(unification_error(
|
||||||
var_name,
|
var_name,
|
||||||
|
|
|
@ -74,7 +74,7 @@ where
|
||||||
&(ref arg_name, _): &'a (Spanning<&'a str>, Spanning<InputValue<S>>),
|
&(ref arg_name, _): &'a (Spanning<&'a str>, Spanning<InputValue<S>>),
|
||||||
) {
|
) {
|
||||||
if let Some((ref pos, args)) = self.current_args {
|
if let Some((ref pos, args)) = self.current_args {
|
||||||
if args.iter().find(|a| a.name == arg_name.item).is_none() {
|
if !args.iter().any(|a| a.name == arg_name.item) {
|
||||||
let message = match *pos {
|
let message = match *pos {
|
||||||
ArgumentPosition::Field(field_name, type_name) => {
|
ArgumentPosition::Field(field_name, type_name) => {
|
||||||
field_error_message(arg_name.item, field_name, type_name)
|
field_error_message(arg_name.item, field_name, type_name)
|
||||||
|
|
|
@ -115,11 +115,10 @@ where
|
||||||
|
|
||||||
if let Some(directive_type) = ctx.schema.directive_by_name(directive_name) {
|
if let Some(directive_type) = ctx.schema.directive_by_name(directive_name) {
|
||||||
if let Some(current_location) = self.location_stack.last() {
|
if let Some(current_location) = self.location_stack.last() {
|
||||||
if directive_type
|
if !directive_type
|
||||||
.locations
|
.locations
|
||||||
.iter()
|
.iter()
|
||||||
.find(|l| l == ¤t_location)
|
.any(|l| l == current_location)
|
||||||
.is_none()
|
|
||||||
{
|
{
|
||||||
ctx.report_error(
|
ctx.report_error(
|
||||||
&misplaced_error_message(directive_name, current_location),
|
&misplaced_error_message(directive_name, current_location),
|
||||||
|
|
|
@ -659,7 +659,7 @@ impl<'a, S: Debug> OverlappingFieldsCanBeMerged<'a, S> {
|
||||||
item: FragmentSpread { ref name, .. },
|
item: FragmentSpread { ref name, .. },
|
||||||
..
|
..
|
||||||
}) => {
|
}) => {
|
||||||
if fragment_names.iter().find(|n| *n == &name.item).is_none() {
|
if !fragment_names.iter().any(|n| *n == name.item) {
|
||||||
fragment_names.push(name.item);
|
fragment_names.push(name.item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ pub enum Scope<'a> {
|
||||||
pub struct VariableInAllowedPosition<'a, S: Debug + 'a> {
|
pub struct VariableInAllowedPosition<'a, S: Debug + 'a> {
|
||||||
spreads: HashMap<Scope<'a>, HashSet<&'a str>>,
|
spreads: HashMap<Scope<'a>, HashSet<&'a str>>,
|
||||||
variable_usages: HashMap<Scope<'a>, Vec<(Spanning<&'a String>, Type<'a>)>>,
|
variable_usages: HashMap<Scope<'a>, Vec<(Spanning<&'a String>, Type<'a>)>>,
|
||||||
|
#[allow(clippy::type_complexity)]
|
||||||
variable_defs: HashMap<Scope<'a>, Vec<&'a (Spanning<&'a str>, VariableDefinition<'a, S>)>>,
|
variable_defs: HashMap<Scope<'a>, Vec<&'a (Spanning<&'a str>, VariableDefinition<'a, S>)>>,
|
||||||
current_scope: Option<Scope<'a>>,
|
current_scope: Option<Scope<'a>>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -318,8 +318,9 @@ pub mod subscriptions {
|
||||||
I: Init<S, CtxT> + Send,
|
I: Init<S, CtxT> + Send,
|
||||||
{
|
{
|
||||||
fn handle(&mut self, msg: Result<ws::Message, ws::ProtocolError>, ctx: &mut Self::Context) {
|
fn handle(&mut self, msg: Result<ws::Message, ws::ProtocolError>, ctx: &mut Self::Context) {
|
||||||
let msg = msg.map(|r| Message(r));
|
let msg = msg.map(Message);
|
||||||
|
|
||||||
|
#[allow(clippy::single_match)]
|
||||||
match msg {
|
match msg {
|
||||||
Ok(msg) => {
|
Ok(msg) => {
|
||||||
let tx = self.graphql_tx.clone();
|
let tx = self.graphql_tx.clone();
|
||||||
|
@ -413,7 +414,6 @@ pub mod subscriptions {
|
||||||
ctx.close(Some(reason))
|
ctx.close(Some(reason))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[derive(Message)]
|
#[derive(Message)]
|
||||||
|
@ -434,7 +434,7 @@ pub mod subscriptions {
|
||||||
fn try_from(msg: Message) -> Result<Self, Self::Error> {
|
fn try_from(msg: Message) -> Result<Self, Self::Error> {
|
||||||
match msg.0 {
|
match msg.0 {
|
||||||
ws::Message::Text(text) => {
|
ws::Message::Text(text) => {
|
||||||
serde_json::from_slice(text.as_bytes()).map_err(|e| Error::Serde(e))
|
serde_json::from_slice(text.as_bytes()).map_err(Error::Serde)
|
||||||
}
|
}
|
||||||
ws::Message::Close(_) => Ok(ClientMessage::ConnectionTerminate),
|
ws::Message::Close(_) => Ok(ClientMessage::ConnectionTerminate),
|
||||||
_ => Err(Error::UnexpectedClientMessage),
|
_ => Err(Error::UnexpectedClientMessage),
|
||||||
|
|
|
@ -194,7 +194,6 @@ impl Attr {
|
||||||
|
|
||||||
/// Checks whether this [`Attr`] doesn't contain arguments related to an
|
/// Checks whether this [`Attr`] doesn't contain arguments related to an
|
||||||
/// [`OnField`] argument.
|
/// [`OnField`] argument.
|
||||||
#[must_use]
|
|
||||||
fn ensure_no_regular_arguments(&self) -> syn::Result<()> {
|
fn ensure_no_regular_arguments(&self) -> syn::Result<()> {
|
||||||
if let Some(span) = &self.name {
|
if let Some(span) = &self.name {
|
||||||
return Err(Self::err_disallowed(&span, "name"));
|
return Err(Self::err_disallowed(&span, "name"));
|
||||||
|
|
|
@ -552,7 +552,7 @@ pub struct FieldAttributes {
|
||||||
|
|
||||||
impl Parse for FieldAttributes {
|
impl Parse for FieldAttributes {
|
||||||
fn parse(input: ParseStream<'_>) -> syn::Result<Self> {
|
fn parse(input: ParseStream<'_>) -> syn::Result<Self> {
|
||||||
let items = Punctuated::<FieldAttribute, token::Comma>::parse_terminated(&input)?;
|
let items = Punctuated::<FieldAttribute, token::Comma>::parse_terminated(input)?;
|
||||||
|
|
||||||
let mut output = Self::default();
|
let mut output = Self::default();
|
||||||
|
|
||||||
|
@ -592,8 +592,8 @@ impl FieldAttributes {
|
||||||
attrs: &[syn::Attribute],
|
attrs: &[syn::Attribute],
|
||||||
_mode: FieldAttributeParseMode,
|
_mode: FieldAttributeParseMode,
|
||||||
) -> syn::Result<Self> {
|
) -> syn::Result<Self> {
|
||||||
let doc_comment = get_doc_comment(&attrs);
|
let doc_comment = get_doc_comment(attrs);
|
||||||
let deprecation = get_deprecated(&attrs);
|
let deprecation = get_deprecated(attrs);
|
||||||
|
|
||||||
let attr_opt = attrs.iter().find(|attr| attr.path.is_ident("graphql"));
|
let attr_opt = attrs.iter().find(|attr| attr.path.is_ident("graphql"));
|
||||||
|
|
||||||
|
|
|
@ -462,11 +462,11 @@ pub mod subscriptions {
|
||||||
let (ws_tx, ws_rx) = websocket.split();
|
let (ws_tx, ws_rx) = websocket.split();
|
||||||
let (s_tx, s_rx) = Connection::new(ArcSchema(root_node), init).split();
|
let (s_tx, s_rx) = Connection::new(ArcSchema(root_node), init).split();
|
||||||
|
|
||||||
let ws_rx = ws_rx.map(|r| r.map(|msg| Message(msg)));
|
let ws_rx = ws_rx.map(|r| r.map(Message));
|
||||||
let s_rx = s_rx.map(|msg| {
|
let s_rx = s_rx.map(|msg| {
|
||||||
serde_json::to_string(&msg)
|
serde_json::to_string(&msg)
|
||||||
.map(|t| warp::ws::Message::text(t))
|
.map(warp::ws::Message::text)
|
||||||
.map_err(|e| Error::Serde(e))
|
.map_err(Error::Serde)
|
||||||
});
|
});
|
||||||
|
|
||||||
match future::select(
|
match future::select(
|
||||||
|
|
Loading…
Reference in a new issue