Clippy clean
This commit is contained in:
parent
490533b640
commit
386b0b2876
|
@ -4,6 +4,7 @@
|
||||||
//! It uses the [pest](https://crates.io/crates/pest) crate to parse the input and then transforms
|
//! It uses the [pest](https://crates.io/crates/pest) crate to parse the input and then transforms
|
||||||
//! it into Rust types.
|
//! it into Rust types.
|
||||||
#![warn(missing_docs)]
|
#![warn(missing_docs)]
|
||||||
|
#![allow(clippy::unnecessary_wraps)]
|
||||||
#![forbid(unsafe_code)]
|
#![forbid(unsafe_code)]
|
||||||
|
|
||||||
use crate::types::OperationType;
|
use crate::types::OperationType;
|
||||||
|
|
|
@ -68,8 +68,10 @@ use futures_util::lock::Mutex;
|
||||||
|
|
||||||
use fnv::FnvHashMap;
|
use fnv::FnvHashMap;
|
||||||
|
|
||||||
type ResSender<K, T> =
|
#[allow(clippy::type_complexity)]
|
||||||
oneshot::Sender<Result<HashMap<K, <T as Loader<K>>::Value>, <T as Loader<K>>::Error>>;
|
struct ResSender<K: Send + Hash + Eq + Clone + 'static, T: Loader<K>>(
|
||||||
|
oneshot::Sender<Result<HashMap<K, T::Value>, T::Error>>,
|
||||||
|
);
|
||||||
|
|
||||||
struct Requests<K: Send + Hash + Eq + Clone + 'static, T: Loader<K>> {
|
struct Requests<K: Send + Hash + Eq + Clone + 'static, T: Loader<K>> {
|
||||||
keys: HashSet<K>,
|
keys: HashSet<K>,
|
||||||
|
@ -95,12 +97,12 @@ impl<K: Send + Hash + Eq + Clone + 'static, T: Loader<K>> Requests<K, T> {
|
||||||
for key in &keys {
|
for key in &keys {
|
||||||
res.extend(values.get(key).map(|value| (key.clone(), value.clone())));
|
res.extend(values.get(key).map(|value| (key.clone(), value.clone())));
|
||||||
}
|
}
|
||||||
tx.send(Ok(res)).ok();
|
tx.0.send(Ok(res)).ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
for (_, tx) in self.pending {
|
for (_, tx) in self.pending {
|
||||||
tx.send(Err(err.clone())).ok();
|
tx.0.send(Err(err.clone())).ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -188,7 +190,7 @@ impl<T> DataLoader<T> {
|
||||||
let keys = keys.collect::<HashSet<_>>();
|
let keys = keys.collect::<HashSet<_>>();
|
||||||
typed_requests.keys.extend(keys.clone());
|
typed_requests.keys.extend(keys.clone());
|
||||||
let (tx, rx) = oneshot::channel();
|
let (tx, rx) = oneshot::channel();
|
||||||
typed_requests.pending.push((keys, tx));
|
typed_requests.pending.push((keys, ResSender(tx)));
|
||||||
if typed_requests.keys.len() >= self.max_batch_size {
|
if typed_requests.keys.len() >= self.max_batch_size {
|
||||||
let r = std::mem::take(&mut *typed_requests);
|
let r = std::mem::take(&mut *typed_requests);
|
||||||
drop(requests);
|
drop(requests);
|
||||||
|
|
|
@ -678,22 +678,20 @@ fn visit_input_value<'a, V: Visitor<'a>>(
|
||||||
if let Some(expected_ty) = expected_ty {
|
if let Some(expected_ty) = expected_ty {
|
||||||
let expected_ty = expected_ty.unwrap_non_null();
|
let expected_ty = expected_ty.unwrap_non_null();
|
||||||
if let MetaTypeName::Named(expected_ty) = expected_ty {
|
if let MetaTypeName::Named(expected_ty) = expected_ty {
|
||||||
if let Some(ty) = ctx
|
if let Some(MetaType::InputObject { input_fields, .. }) = ctx
|
||||||
.registry
|
.registry
|
||||||
.types
|
.types
|
||||||
.get(MetaTypeName::concrete_typename(expected_ty))
|
.get(MetaTypeName::concrete_typename(expected_ty))
|
||||||
{
|
{
|
||||||
if let MetaType::InputObject { input_fields, .. } = ty {
|
for (item_key, item_value) in values {
|
||||||
for (item_key, item_value) in values {
|
if let Some(input_value) = input_fields.get(item_key.as_str()) {
|
||||||
if let Some(input_value) = input_fields.get(item_key.as_str()) {
|
visit_input_value(
|
||||||
visit_input_value(
|
v,
|
||||||
v,
|
ctx,
|
||||||
ctx,
|
pos,
|
||||||
pos,
|
Some(MetaTypeName::create(&input_value.ty)),
|
||||||
Some(MetaTypeName::create(&input_value.ty)),
|
item_value,
|
||||||
item_value,
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,10 +17,8 @@ impl<'ctx, 'a> Visitor<'ctx> for CacheControlCalculate<'a> {
|
||||||
ctx: &mut VisitorContext<'_>,
|
ctx: &mut VisitorContext<'_>,
|
||||||
_selection_set: &Positioned<SelectionSet>,
|
_selection_set: &Positioned<SelectionSet>,
|
||||||
) {
|
) {
|
||||||
if let Some(current_type) = ctx.current_type() {
|
if let Some(MetaType::Object { cache_control, .. }) = ctx.current_type() {
|
||||||
if let MetaType::Object { cache_control, .. } = current_type {
|
*self.cache_control = self.cache_control.merge(cache_control);
|
||||||
*self.cache_control = self.cache_control.merge(cache_control);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,37 +51,33 @@ impl<'ctx, 'a> Visitor<'ctx> for ComplexityCalculate<'ctx, 'a> {
|
||||||
fn exit_field(&mut self, ctx: &mut VisitorContext<'ctx>, field: &'ctx Positioned<Field>) {
|
fn exit_field(&mut self, ctx: &mut VisitorContext<'ctx>, field: &'ctx Positioned<Field>) {
|
||||||
let children_complex = self.complexity_stack.pop().unwrap();
|
let children_complex = self.complexity_stack.pop().unwrap();
|
||||||
|
|
||||||
if let Some(ty) = ctx.parent_type() {
|
if let Some(MetaType::Object { fields, .. }) = ctx.parent_type() {
|
||||||
if let MetaType::Object { fields, .. } = ty {
|
if let Some(meta_field) = fields.get(MetaTypeName::concrete_typename(
|
||||||
if let Some(meta_field) = fields.get(MetaTypeName::concrete_typename(
|
field.node.name.node.as_str(),
|
||||||
field.node.name.node.as_str(),
|
)) {
|
||||||
)) {
|
if let Some(compute_complexity) = &meta_field.compute_complexity {
|
||||||
if let Some(compute_complexity) = &meta_field.compute_complexity {
|
match compute_complexity {
|
||||||
match compute_complexity {
|
ComplexityType::Const(n) => {
|
||||||
ComplexityType::Const(n) => {
|
*self.complexity_stack.last_mut().unwrap() += n;
|
||||||
*self.complexity_stack.last_mut().unwrap() += n;
|
}
|
||||||
}
|
ComplexityType::Fn(f) => {
|
||||||
ComplexityType::Fn(f) => {
|
if MetaTypeName::create(&meta_field.ty).is_list() {
|
||||||
if MetaTypeName::create(&meta_field.ty).is_list() {
|
match f(
|
||||||
match f(
|
ctx,
|
||||||
ctx,
|
self.variable_definition.unwrap(),
|
||||||
self.variable_definition.unwrap(),
|
&field.node,
|
||||||
&field.node,
|
children_complex,
|
||||||
children_complex,
|
) {
|
||||||
) {
|
Ok(n) => {
|
||||||
Ok(n) => {
|
*self.complexity_stack.last_mut().unwrap() += n;
|
||||||
*self.complexity_stack.last_mut().unwrap() += n;
|
|
||||||
}
|
|
||||||
Err(err) => {
|
|
||||||
ctx.report_error(vec![field.pos], err.to_string())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Err(err) => ctx.report_error(vec![field.pos], err.to_string()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user