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::{
|
||||
graphql_object, graphql_value, EmptyMutation, EmptySubscription, GraphQLEnum, GraphQLError,
|
||||
RootNode, Value,
|
||||
};
|
||||
use juniper::{graphql_object, GraphQLEnum};
|
||||
|
||||
#[derive(GraphQLEnum)]
|
||||
enum UserKind {
|
||||
|
|
|
@ -87,7 +87,7 @@ where
|
|||
|
||||
/// The argument's name
|
||||
pub fn name(&'a self) -> &str {
|
||||
&self.name
|
||||
self.name
|
||||
}
|
||||
|
||||
/// The value of the argument
|
||||
|
@ -289,7 +289,7 @@ where
|
|||
fragments,
|
||||
);
|
||||
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() {
|
||||
p.applies_for = Applies::OnlyType(c);
|
||||
}
|
||||
|
@ -308,7 +308,7 @@ where
|
|||
.children
|
||||
.iter()
|
||||
.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))
|
||||
}
|
||||
Applies::All => Some(c.inner.for_explicit_type(type_name)),
|
||||
|
|
|
@ -689,7 +689,7 @@ where
|
|||
}
|
||||
});
|
||||
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 {
|
||||
None
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ where
|
|||
{
|
||||
// TODO: Remove in 0.17 `juniper` version.
|
||||
/// 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> {
|
||||
self.operation_name.as_deref()
|
||||
}
|
||||
|
|
|
@ -335,7 +335,7 @@ where
|
|||
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() {
|
||||
return Err(GraphQLError::ValidationError(errors));
|
||||
|
|
|
@ -59,6 +59,7 @@ impl<T> Spanning<T> {
|
|||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
#[allow(clippy::self_named_constructors)]
|
||||
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)) {
|
||||
Some(Spanning {
|
||||
|
|
|
@ -399,7 +399,7 @@ impl<'a, S> MetaType<'a, S> {
|
|||
.iter()
|
||||
.filter_map(|n| schema.concrete_type_by_name(n))
|
||||
.filter_map(|t| t.fields(schema))
|
||||
.flat_map(|f| f)
|
||||
.flatten()
|
||||
.collect(),
|
||||
),
|
||||
_ => None,
|
||||
|
|
|
@ -256,7 +256,7 @@ impl GraphQLParserTranslator {
|
|||
.map(|a| {
|
||||
a.iter()
|
||||
.filter(|x| !x.is_builtin())
|
||||
.map(|x| GraphQLParserTranslator::translate_argument(&x))
|
||||
.map(|x| GraphQLParserTranslator::translate_argument(x))
|
||||
.collect()
|
||||
})
|
||||
.unwrap_or_else(Vec::new);
|
||||
|
@ -300,7 +300,7 @@ fn generate_directives<'a, T>(status: &DeprecationStatus) -> Vec<ExternalDirecti
|
|||
where
|
||||
T: Text<'a>,
|
||||
{
|
||||
if let Some(d) = deprecation_to_directive(&status) {
|
||||
if let Some(d) = deprecation_to_directive(status) {
|
||||
vec![d]
|
||||
} else {
|
||||
vec![]
|
||||
|
|
|
@ -361,6 +361,7 @@ impl Database {
|
|||
}
|
||||
|
||||
pub fn get_character(&self, id: &str) -> Option<CharacterValue> {
|
||||
#[allow(clippy::manual_map)]
|
||||
if let Some(h) = self.humans.get(id) {
|
||||
Some(h.clone().into())
|
||||
} else if let Some(d) = self.droids.get(id) {
|
||||
|
|
|
@ -241,7 +241,7 @@ where
|
|||
let exec_vars = executor.variables();
|
||||
|
||||
let sub_exec = executor.field_sub_executor(
|
||||
&response_name,
|
||||
response_name,
|
||||
f.name.item,
|
||||
*start_pos,
|
||||
f.selection_set.as_ref().map(|v| &v[..]),
|
||||
|
@ -309,7 +309,7 @@ where
|
|||
let type_name = instance.type_name(info);
|
||||
if executor
|
||||
.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
|
||||
{
|
||||
let sub_result = instance
|
||||
|
@ -355,7 +355,7 @@ where
|
|||
let concrete_type_name = instance.concrete_type_name(sub_exec.context(), info);
|
||||
if executor
|
||||
.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_async(
|
||||
|
|
|
@ -520,7 +520,7 @@ where
|
|||
let type_name = instance.type_name(info);
|
||||
if executor
|
||||
.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
|
||||
{
|
||||
let sub_result = instance.resolve_into_type(
|
||||
|
@ -558,7 +558,7 @@ where
|
|||
let concrete_type_name = instance.concrete_type_name(sub_exec.context(), info);
|
||||
if executor
|
||||
.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(
|
||||
info,
|
||||
|
|
|
@ -287,7 +287,7 @@ where
|
|||
start: ref start_pos,
|
||||
..
|
||||
}) => {
|
||||
if is_excluded(&f.directives, &executor.variables()) {
|
||||
if is_excluded(&f.directives, executor.variables()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -327,7 +327,7 @@ where
|
|||
f.arguments.as_ref().map(|m| {
|
||||
m.item
|
||||
.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()
|
||||
}),
|
||||
&meta_field.arguments,
|
||||
|
@ -361,7 +361,7 @@ where
|
|||
start: ref start_pos,
|
||||
..
|
||||
}) => {
|
||||
if is_excluded(&spread.directives, &executor.variables()) {
|
||||
if is_excluded(&spread.directives, executor.variables()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -400,7 +400,7 @@ where
|
|||
start: ref start_pos,
|
||||
..
|
||||
}) => {
|
||||
if is_excluded(&fragment.directives, &executor.variables()) {
|
||||
if is_excluded(&fragment.directives, executor.variables()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -239,7 +239,7 @@ where
|
|||
match *value {
|
||||
// TODO: avoid this bad duplicate as_str() call. (value system refactor)
|
||||
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) {
|
||||
errors.push(unification_error(
|
||||
var_name,
|
||||
|
|
|
@ -74,7 +74,7 @@ where
|
|||
&(ref arg_name, _): &'a (Spanning<&'a str>, Spanning<InputValue<S>>),
|
||||
) {
|
||||
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 {
|
||||
ArgumentPosition::Field(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(current_location) = self.location_stack.last() {
|
||||
if directive_type
|
||||
if !directive_type
|
||||
.locations
|
||||
.iter()
|
||||
.find(|l| l == ¤t_location)
|
||||
.is_none()
|
||||
.any(|l| l == current_location)
|
||||
{
|
||||
ctx.report_error(
|
||||
&misplaced_error_message(directive_name, current_location),
|
||||
|
|
|
@ -659,7 +659,7 @@ impl<'a, S: Debug> OverlappingFieldsCanBeMerged<'a, S> {
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ pub enum Scope<'a> {
|
|||
pub struct VariableInAllowedPosition<'a, S: Debug + 'a> {
|
||||
spreads: HashMap<Scope<'a>, HashSet<&'a str>>,
|
||||
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>)>>,
|
||||
current_scope: Option<Scope<'a>>,
|
||||
}
|
||||
|
|
|
@ -318,8 +318,9 @@ pub mod subscriptions {
|
|||
I: Init<S, CtxT> + Send,
|
||||
{
|
||||
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 {
|
||||
Ok(msg) => {
|
||||
let tx = self.graphql_tx.clone();
|
||||
|
@ -413,7 +414,6 @@ pub mod subscriptions {
|
|||
ctx.close(Some(reason))
|
||||
}
|
||||
};
|
||||
()
|
||||
}
|
||||
}
|
||||
#[derive(Message)]
|
||||
|
@ -434,7 +434,7 @@ pub mod subscriptions {
|
|||
fn try_from(msg: Message) -> Result<Self, Self::Error> {
|
||||
match msg.0 {
|
||||
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),
|
||||
_ => Err(Error::UnexpectedClientMessage),
|
||||
|
|
|
@ -194,7 +194,6 @@ impl Attr {
|
|||
|
||||
/// Checks whether this [`Attr`] doesn't contain arguments related to an
|
||||
/// [`OnField`] argument.
|
||||
#[must_use]
|
||||
fn ensure_no_regular_arguments(&self) -> syn::Result<()> {
|
||||
if let Some(span) = &self.name {
|
||||
return Err(Self::err_disallowed(&span, "name"));
|
||||
|
|
|
@ -552,7 +552,7 @@ pub struct FieldAttributes {
|
|||
|
||||
impl Parse for FieldAttributes {
|
||||
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();
|
||||
|
||||
|
@ -592,8 +592,8 @@ impl FieldAttributes {
|
|||
attrs: &[syn::Attribute],
|
||||
_mode: FieldAttributeParseMode,
|
||||
) -> syn::Result<Self> {
|
||||
let doc_comment = get_doc_comment(&attrs);
|
||||
let deprecation = get_deprecated(&attrs);
|
||||
let doc_comment = get_doc_comment(attrs);
|
||||
let deprecation = get_deprecated(attrs);
|
||||
|
||||
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 (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| {
|
||||
serde_json::to_string(&msg)
|
||||
.map(|t| warp::ws::Message::text(t))
|
||||
.map_err(|e| Error::Serde(e))
|
||||
.map(warp::ws::Message::text)
|
||||
.map_err(Error::Serde)
|
||||
});
|
||||
|
||||
match future::select(
|
||||
|
|
Loading…
Reference in a new issue