Skip to content

Commit

Permalink
Fix Nightly Clippy lints (#5673)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonSapin authored Jul 16, 2024
1 parent 9eb2509 commit 1d8940b
Show file tree
Hide file tree
Showing 57 changed files with 339 additions and 706 deletions.
5 changes: 4 additions & 1 deletion apollo-federation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
//! See [Router documentation](https://www.apollographql.com/docs/router/federation-version-support/)
//! for which Federation versions are supported by which Router versions.
#![allow(dead_code)] // TODO: This is fine while we're iterating, but should be removed later.
// TODO: This is fine while we're iterating, but should be removed later.
#![allow(dead_code)]
// TODO: silence false positives (apollo_compiler::Name) and investigate the rest
#![allow(clippy::mutable_key_type)]

mod api_schema;
mod compat;
Expand Down
14 changes: 7 additions & 7 deletions apollo-federation/src/operation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
//! Each "conceptual" type consists of up to three actual types: a data type, an "element"
//! type, and a selection type.
//! - The data type records the data about the type. Things like a field name or fragment type
//! condition are in the data type. These types can be constructed and modified with plain rust.
//! condition are in the data type. These types can be constructed and modified with plain rust.
//! - The element type contains the data type and maintains a key for the data. These types provide
//! APIs for modifications that keep the key up-to-date.
//! APIs for modifications that keep the key up-to-date.
//! - The selection type contains the element type and, for composite fields, a subselection.
//!
//! For example, for fields, the data type is [`FieldData`], the element type is
Expand Down Expand Up @@ -4003,11 +4003,11 @@ impl NamedFragments {
/// want to consider to ignore the fragment for that subgraph, and that is when:
/// 1. the subset that apply is actually empty. The fragment wouldn't be valid in this case anyway.
/// 2. the subset is a single leaf field: in that case, using the one field directly is just shorter than using
/// the fragment, so we consider the fragment don't really apply to that subgraph. Technically, using the
/// fragment could still be of value if the fragment name is a lot smaller than the one field name, but it's
/// enough of a niche case that we ignore it. Note in particular that one sub-case of this rule that is likely
/// to be common is when the subset ends up being just `__typename`: this would basically mean the fragment
/// don't really apply to the subgraph, and that this will ensure this is the case.
/// the fragment, so we consider the fragment don't really apply to that subgraph. Technically, using the
/// fragment could still be of value if the fragment name is a lot smaller than the one field name, but it's
/// enough of a niche case that we ignore it. Note in particular that one sub-case of this rule that is likely
/// to be common is when the subset ends up being just `__typename`: this would basically mean the fragment
/// don't really apply to the subgraph, and that this will ensure this is the case.
pub(crate) fn is_selection_set_worth_using(selection_set: &SelectionSet) -> bool {
if selection_set.selections.len() == 0 {
return false;
Expand Down
10 changes: 5 additions & 5 deletions apollo-federation/src/operation/rebase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,12 @@ impl Field {
///
/// There are 2 valid cases we want to allow:
/// 1. either `parent_type` and `field_parent_type` are the same underlying type (same name) but from different underlying schema. Typically,
/// happens when we're building subgraph queries but using selections from the original query which is against the supergraph API schema.
/// happens when we're building subgraph queries but using selections from the original query which is against the supergraph API schema.
/// 2. or they are not the same underlying type, but the field parent type is from an interface (or an interface object, which is the same
/// here), in which case we may be rebasing an interface field on one of the implementation type, which is ok. Note that we don't verify
/// that `parent_type` is indeed an implementation of `field_parent_type` because it's possible that this implementation relationship exists
/// in the supergraph, but not in any of the subgraph schema involved here. So we just let it be. Not that `rebase_on` will complain anyway
/// if the field name simply does not exist in `parent_type`.
/// here), in which case we may be rebasing an interface field on one of the implementation type, which is ok. Note that we don't verify
/// that `parent_type` is indeed an implementation of `field_parent_type` because it's possible that this implementation relationship exists
/// in the supergraph, but not in any of the subgraph schema involved here. So we just let it be. Not that `rebase_on` will complain anyway
/// if the field name simply does not exist in `parent_type`.
fn can_rebase_on(
&self,
parent_type: &CompositeTypeDefinitionPosition,
Expand Down
2 changes: 1 addition & 1 deletion apollo-federation/src/query_plan/fetch_dependency_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,7 @@ impl FetchDependencyGraph {
let get_subgraph_schema = |subgraph_name: &Arc<str>| {
self.federated_query_graph
.schema_by_source(subgraph_name)
.map(|schema| schema.clone())
.cloned()
};

// For nodes that fetches from an @interfaceObject, we can sometimes have something like
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ pub(crate) struct FetchDependencyGraphToQueryPlanProcessor {
/// A plan is essentially some mix of sequences and parallels of fetches. And the plan cost
/// is about minimizing both:
/// 1. The expected total latency of executing the plan. Typically, doing 2 fetches in
/// parallel will most likely have much better latency then executing those exact same
/// fetches in sequence, and so the cost of the latter must be greater than that of
/// the former.
/// parallel will most likely have much better latency then executing those exact same
/// fetches in sequence, and so the cost of the latter must be greater than that of
/// the former.
/// 2. The underlying use of resources. For instance, if we query 2 fields and we have
/// the choice between getting those 2 fields from a single subgraph in 1 fetch, or
/// get each from a different subgraph with 2 fetches in parallel, then we want to
/// favor the former as just doing a fetch in and of itself has a cost in terms of
/// resources consumed.
/// the choice between getting those 2 fields from a single subgraph in 1 fetch, or
/// get each from a different subgraph with 2 fetches in parallel, then we want to
/// favor the former as just doing a fetch in and of itself has a cost in terms of
/// resources consumed.
///
/// Do note that at the moment, this cost is solely based on the "shape" of the plan and has
/// to make some conservative assumption regarding concrete runtime behaviour. In particular,
Expand Down
2 changes: 2 additions & 0 deletions apollo-federation/src/schema/position.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6067,10 +6067,12 @@ fn validate_arguments(arguments: &[Node<InputValueDefinition>]) -> Result<(), Fe

impl FederationSchema {
/// Note that the input schema must be partially valid, in that:
///
/// 1. All schema element references must point to an existing schema element of the appropriate
/// kind (e.g. object type fields must return an existing output type).
/// 2. If the schema uses the core/link spec, then usages of the @core/@link directive must be
/// valid.
///
/// The input schema may be otherwise invalid GraphQL (e.g. it may not contain a Query type). If
/// you want a ValidFederationSchema, use ValidFederationSchema::new() instead.
pub(crate) fn new(schema: Schema) -> Result<FederationSchema, FederationError> {
Expand Down
4 changes: 2 additions & 2 deletions apollo-router/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ description = "A configurable, high-performance routing runtime for Apollo Feder
license = "Elastic-2.0"

# renovate-automation: rustc version
rust-version = "1.72.0"
rust-version = "1.76.0"
edition = "2021"
build = "build/main.rs"

Expand Down Expand Up @@ -171,7 +171,7 @@ opentelemetry-otlp = { version = "0.13.0", default-features = false, features =
"http-proto",
"metrics",
"reqwest-client",
"trace"
"trace",
] }
opentelemetry-semantic-conventions = "0.12.0"
opentelemetry-zipkin = { version = "0.18.0", default-features = false, features = [
Expand Down
3 changes: 2 additions & 1 deletion apollo-router/src/axum_factory/compression/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ pub(crate) enum Compressor {
}

impl Compressor {
pub(crate) fn new<'a, It: 'a>(it: It) -> Option<Self>
pub(crate) fn new<'a, It>(it: It) -> Option<Self>
where
It: Iterator<Item = &'a str>,
It: 'a,
{
for s in it {
match s {
Expand Down
16 changes: 8 additions & 8 deletions apollo-router/src/axum_factory/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ async fn it_displays_sandbox() {

// Regular studio redirect
let response = client
.get(&format!(
.get(format!(
"{}/",
server.graphql_listen_address().as_ref().unwrap()
))
Expand Down Expand Up @@ -422,7 +422,7 @@ async fn it_displays_sandbox_with_different_supergraph_path() {

// Regular studio redirect
let response = client
.get(&format!(
.get(format!(
"{}/custom",
server.graphql_listen_address().as_ref().unwrap()
))
Expand Down Expand Up @@ -739,7 +739,7 @@ async fn response_with_root_wildcard() -> Result<(), ApolloRouterError> {
// Post query without path
let response = client
.post(
&server
server
.graphql_listen_address()
.as_ref()
.unwrap()
Expand Down Expand Up @@ -1046,7 +1046,7 @@ async fn cors_preflight() -> Result<(), ApolloRouterError> {
let response = client
.request(
Method::OPTIONS,
&format!(
format!(
"{}/graphql",
server.graphql_listen_address().as_ref().unwrap()
),
Expand Down Expand Up @@ -1197,7 +1197,7 @@ async fn it_displays_homepage() {
.await
.unwrap();
let response = client
.get(&format!(
.get(format!(
"{}/",
server.graphql_listen_address().as_ref().unwrap()
))
Expand Down Expand Up @@ -1244,7 +1244,7 @@ async fn it_doesnt_display_disabled_homepage() {
.await
.unwrap();
let response = client
.get(&format!(
.get(format!(
"{}/",
server.graphql_listen_address().as_ref().unwrap()
))
Expand Down Expand Up @@ -1303,7 +1303,7 @@ async fn it_answers_to_custom_endpoint() -> Result<(), ApolloRouterError> {

for path in &["/a-custom-path", "/an-other-custom-path"] {
let response = client
.get(&format!(
.get(format!(
"{}{}",
server.graphql_listen_address().as_ref().unwrap(),
path
Expand All @@ -1318,7 +1318,7 @@ async fn it_answers_to_custom_endpoint() -> Result<(), ApolloRouterError> {

for path in &["/a-custom-path", "/an-other-custom-path"] {
let response = client
.post(&format!(
.post(format!(
"{}{}",
server.graphql_listen_address().as_ref().unwrap(),
path
Expand Down
2 changes: 1 addition & 1 deletion apollo-router/src/batching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ mod tests {

// We should see the aggregation of all of the requests
let actual: Vec<graphql::Request> = serde_json::from_str(
&String::from_utf8(request.into_body().to_bytes().await.unwrap().to_vec()).unwrap(),
std::str::from_utf8(&request.into_body().to_bytes().await.unwrap()).unwrap(),
)
.unwrap();

Expand Down
2 changes: 1 addition & 1 deletion apollo-router/src/configuration/cors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub(crate) struct Cors {
/// and make sure you either:
/// - accept `x-apollo-operation-name` AND / OR `apollo-require-preflight`
/// - defined `csrf` required headers in your yml configuration, as shown in the
/// `examples/cors-and-csrf/custom-headers.router.yaml` files.
/// `examples/cors-and-csrf/custom-headers.router.yaml` files.
pub(crate) allow_headers: Vec<String>,

/// Which response headers should be made available to scripts running in the browser,
Expand Down
5 changes: 2 additions & 3 deletions apollo-router/src/configuration/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,8 @@ impl InstrumentData {

// We need to update the entry we just made because the selected strategy is a named object in the config.
// The jsonpath spec doesn't include a utility for getting the keys out of an object, so we do it manually.
if let Some((_, demand_control_attributes)) = self
.data
.get_mut(&"apollo.router.config.demand_control".to_string())
if let Some((_, demand_control_attributes)) =
self.data.get_mut("apollo.router.config.demand_control")
{
Self::get_first_key_from_path(
demand_control_attributes,
Expand Down
Loading

0 comments on commit 1d8940b

Please sign in to comment.