From fd053eb08692fba60e12809d0c3fd4067852c82e Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Thu, 25 Mar 2021 13:14:10 -0500 Subject: [PATCH 1/6] chore: s/IOError/IoError --- crates/houston/src/error.rs | 4 ++-- crates/houston/src/profile/mod.rs | 2 +- crates/sputnik/src/error.rs | 4 ++-- installers/binstall/src/error.rs | 2 +- src/error/metadata/mod.rs | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/houston/src/error.rs b/crates/houston/src/error.rs index e319fdf9c..92dc2d3ad 100644 --- a/crates/houston/src/error.rs +++ b/crates/houston/src/error.rs @@ -48,7 +48,7 @@ pub enum HoustonProblem { #[error(transparent)] TomlDeserialization(#[from] toml::de::Error), - /// IOError occurs when any given std::io::Error arises. + /// IoError occurs when any given std::io::Error arises. #[error(transparent)] - IOError(#[from] io::Error), + IoError(#[from] io::Error), } diff --git a/crates/houston/src/profile/mod.rs b/crates/houston/src/profile/mod.rs index 32e39ae3e..00257d472 100644 --- a/crates/houston/src/profile/mod.rs +++ b/crates/houston/src/profile/mod.rs @@ -121,7 +121,7 @@ impl Profile { tracing::debug!(dir = ?dir); Ok(fs::remove_dir_all(dir).map_err(|e| match e.kind() { io::ErrorKind::NotFound => HoustonProblem::ProfileNotFound(name.to_string()), - _ => HoustonProblem::IOError(e), + _ => HoustonProblem::IoError(e), })?) } diff --git a/crates/sputnik/src/error.rs b/crates/sputnik/src/error.rs index 1ec6cc581..b44772f20 100644 --- a/crates/sputnik/src/error.rs +++ b/crates/sputnik/src/error.rs @@ -5,9 +5,9 @@ use std::io; /// SputnikError is the type of Error that occured. #[derive(Error, Debug)] pub enum SputnikError { - /// IOError occurs when any given std::io::Error arises. + /// IoError occurs when any given std::io::Error arises. #[error(transparent)] - IOError(#[from] io::Error), + IoError(#[from] io::Error), /// JSONError occurs when an error occurs when serializing/deserializing JSON. #[error(transparent)] diff --git a/installers/binstall/src/error.rs b/installers/binstall/src/error.rs index 34efa7c3f..dcee54fc6 100644 --- a/installers/binstall/src/error.rs +++ b/installers/binstall/src/error.rs @@ -6,7 +6,7 @@ use std::io; #[derive(Error, Debug)] pub enum InstallerError { #[error(transparent)] - IOError(#[from] io::Error), + IoError(#[from] io::Error), #[error("Could not find the home directory of the current user")] NoHomeUnix, diff --git a/src/error/metadata/mod.rs b/src/error/metadata/mod.rs index b23f19749..f399273e0 100644 --- a/src/error/metadata/mod.rs +++ b/src/error/metadata/mod.rs @@ -109,7 +109,7 @@ impl From<&mut anyhow::Error> for Metadata { | HoustonProblem::PathNotUnicode { path_display: _ } | HoustonProblem::TomlDeserialization(_) | HoustonProblem::TomlSerialization(_) - | HoustonProblem::IOError(_) => (Some(Suggestion::SubmitIssue), None), + | HoustonProblem::IoError(_) => (Some(Suggestion::SubmitIssue), None), }; return Metadata { suggestion, From 2be9048c06144c1be59c9b17eed91ad0c3e67366 Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Thu, 25 Mar 2021 13:24:44 -0500 Subject: [PATCH 2/6] chore: removes unnecessary ? --- crates/houston/src/profile/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/houston/src/profile/mod.rs b/crates/houston/src/profile/mod.rs index 00257d472..e9ec56458 100644 --- a/crates/houston/src/profile/mod.rs +++ b/crates/houston/src/profile/mod.rs @@ -119,10 +119,10 @@ impl Profile { pub fn delete(name: &str, config: &Config) -> Result<(), HoustonProblem> { let dir = Profile::dir(name, config); tracing::debug!(dir = ?dir); - Ok(fs::remove_dir_all(dir).map_err(|e| match e.kind() { + fs::remove_dir_all(dir).map_err(|e| match e.kind() { io::ErrorKind::NotFound => HoustonProblem::ProfileNotFound(name.to_string()), _ => HoustonProblem::IoError(e), - })?) + }) } /// Lists profiles based on directories in `$APOLLO_CONFIG_HOME/profiles` From 3b4bcaeb62ff4311c6cedb699e699964c5278bef Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Thu, 25 Mar 2021 13:31:14 -0500 Subject: [PATCH 3/6] chore: s/URLParseError/UrlParseError --- crates/sputnik/src/error.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/sputnik/src/error.rs b/crates/sputnik/src/error.rs index b44772f20..4c9e79742 100644 --- a/crates/sputnik/src/error.rs +++ b/crates/sputnik/src/error.rs @@ -21,9 +21,9 @@ pub enum SputnikError { #[error("Could not parse the version of the tool.")] VersionParseError(#[from] semver::SemVerError), - /// URLParseError occurs when the URL to POST the anonymous usage data cannot be parsed. + /// UrlParseError occurs when the URL to POST the anonymous usage data cannot be parsed. #[error("Could not parse telemetry URL.")] - URLParseError(#[from] url::ParseError), + UrlParseError(#[from] url::ParseError), /// ConfigError occurs when the configuration location of the globally persistent machine /// identifier cannot be found. From 0b6399ade9b30e88cb3c6f58018ed0a314527f7a Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Thu, 25 Mar 2021 13:32:21 -0500 Subject: [PATCH 4/6] chore: s/HTTPError/HttpError --- crates/sputnik/src/error.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/sputnik/src/error.rs b/crates/sputnik/src/error.rs index 4c9e79742..b5b61fc4a 100644 --- a/crates/sputnik/src/error.rs +++ b/crates/sputnik/src/error.rs @@ -13,9 +13,9 @@ pub enum SputnikError { #[error(transparent)] JSONError(#[from] serde_json::Error), - /// HTTPError occurs when an error occurs while reporting anonymous usage data. + /// HttpError occurs when an error occurs while reporting anonymous usage data. #[error("Could not report anonymous usage data.")] - HTTPError(#[from] reqwest::Error), + HttpError(#[from] reqwest::Error), /// VersionParseError occurs when the version of the tool cannot be determined. #[error("Could not parse the version of the tool.")] From 3001259d9fa47542a604b0e539b1db302a78b893 Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Thu, 25 Mar 2021 13:39:22 -0500 Subject: [PATCH 5/6] chore: the rest --- crates/rover-client/src/blocking/client.rs | 2 +- crates/rover-client/src/error.rs | 4 ++-- crates/rover-client/src/lib.rs | 1 + crates/sputnik/src/error.rs | 4 ++-- src/command/core/build.rs | 2 +- src/command/graph/fetch.rs | 2 +- src/command/output.rs | 8 ++++---- src/command/subgraph/fetch.rs | 2 +- src/error/metadata/mod.rs | 4 ++-- 9 files changed, 15 insertions(+), 14 deletions(-) diff --git a/crates/rover-client/src/blocking/client.rs b/crates/rover-client/src/blocking/client.rs index 096169de0..e49c61a3e 100644 --- a/crates/rover-client/src/blocking/client.rs +++ b/crates/rover-client/src/blocking/client.rs @@ -59,7 +59,7 @@ impl Client { return Err(RoverClientError::MalformedKey); } - return Err(RoverClientError::GraphQL { + return Err(RoverClientError::GraphQl { msg: errs .into_iter() .map(|err| err.message) diff --git a/crates/rover-client/src/error.rs b/crates/rover-client/src/error.rs index 175ddf011..e43fb85d3 100644 --- a/crates/rover-client/src/error.rs +++ b/crates/rover-client/src/error.rs @@ -5,7 +5,7 @@ use thiserror::Error; pub enum RoverClientError { /// The provided GraphQL was invalid. #[error("{msg}")] - GraphQL { + GraphQl { /// The encountered GraphQL error. msg: String, }, @@ -27,7 +27,7 @@ pub enum RoverClientError { /// Invalid JSON in response body. #[error("could not parse JSON")] - InvalidJSON(#[from] serde_json::Error), + InvalidJson(#[from] serde_json::Error), /// Encountered an error handling the received response. #[error("{msg}")] diff --git a/crates/rover-client/src/lib.rs b/crates/rover-client/src/lib.rs index b220f0cc2..2a4ad7ecd 100644 --- a/crates/rover-client/src/lib.rs +++ b/crates/rover-client/src/lib.rs @@ -16,6 +16,7 @@ pub mod introspection; pub use error::RoverClientError; /// Module for actually querying studio +#[allow(clippy::upper_case_acronyms)] pub mod query; /// Module for getting release info diff --git a/crates/sputnik/src/error.rs b/crates/sputnik/src/error.rs index b5b61fc4a..382cf9b2e 100644 --- a/crates/sputnik/src/error.rs +++ b/crates/sputnik/src/error.rs @@ -9,9 +9,9 @@ pub enum SputnikError { #[error(transparent)] IoError(#[from] io::Error), - /// JSONError occurs when an error occurs when serializing/deserializing JSON. + /// JsonError occurs when an error occurs when serializing/deserializing JSON. #[error(transparent)] - JSONError(#[from] serde_json::Error), + JsonError(#[from] serde_json::Error), /// HttpError occurs when an error occurs while reporting anonymous usage data. #[error("Could not report anonymous usage data.")] diff --git a/src/command/core/build.rs b/src/command/core/build.rs index 52bf1d338..265c25ccc 100644 --- a/src/command/core/build.rs +++ b/src/command/core/build.rs @@ -21,7 +21,7 @@ impl Build { let subgraph_definitions = core_config.get_subgraph_definitions(&self.config_path)?; match harmonizer::harmonize(subgraph_definitions) { - Ok(csdl) => Ok(RoverStdout::CSDL(csdl)), + Ok(csdl) => Ok(RoverStdout::Csdl(csdl)), Err(composition_errors) => { let num_failures = composition_errors.len(); for composition_error in composition_errors { diff --git a/src/command/graph/fetch.rs b/src/command/graph/fetch.rs index 3381fa0e6..d3d4c1e38 100644 --- a/src/command/graph/fetch.rs +++ b/src/command/graph/fetch.rs @@ -42,6 +42,6 @@ impl Fetch { &client, )?; - Ok(RoverStdout::SDL(sdl)) + Ok(RoverStdout::Sdl(sdl)) } } diff --git a/src/command/output.rs b/src/command/output.rs index bd57e6fb4..5a4cb9a2d 100644 --- a/src/command/output.rs +++ b/src/command/output.rs @@ -17,8 +17,8 @@ use crate::utils::table::{self, cell, row}; #[derive(Clone, PartialEq, Debug)] pub enum RoverStdout { DocsList(HashMap<&'static str, &'static str>), - SDL(String), - CSDL(String), + Sdl(String), + Csdl(String), SchemaHash(String), SubgraphList(ListDetails), VariantList(Vec), @@ -44,11 +44,11 @@ impl RoverStdout { } println!("{}", table); } - RoverStdout::SDL(sdl) => { + RoverStdout::Sdl(sdl) => { eprintln!("SDL:"); println!("{}", &sdl); } - RoverStdout::CSDL(csdl) => { + RoverStdout::Csdl(csdl) => { eprintln!("CSDL:"); println!("{}", &csdl); } diff --git a/src/command/subgraph/fetch.rs b/src/command/subgraph/fetch.rs index 769da0954..e51ae6bc1 100644 --- a/src/command/subgraph/fetch.rs +++ b/src/command/subgraph/fetch.rs @@ -48,6 +48,6 @@ impl Fetch { &self.subgraph, )?; - Ok(RoverStdout::SDL(sdl)) + Ok(RoverStdout::Sdl(sdl)) } } diff --git a/src/error/metadata/mod.rs b/src/error/metadata/mod.rs index f399273e0..48f18c748 100644 --- a/src/error/metadata/mod.rs +++ b/src/error/metadata/mod.rs @@ -38,7 +38,7 @@ impl From<&mut anyhow::Error> for Metadata { fn from(error: &mut anyhow::Error) -> Self { if let Some(rover_client_error) = error.downcast_ref::() { let (suggestion, code) = match rover_client_error { - RoverClientError::InvalidJSON(_) + RoverClientError::InvalidJson(_) | RoverClientError::InvalidHeaderName(_) | RoverClientError::InvalidHeaderValue(_) | RoverClientError::SendRequest(_) @@ -72,7 +72,7 @@ impl From<&mut anyhow::Error> for Metadata { (Some(Suggestion::CheckGraphNameAndAuth), None) } RoverClientError::AdhocError { msg: _ } - | RoverClientError::GraphQL { msg: _ } + | RoverClientError::GraphQl { msg: _ } | RoverClientError::IntrospectionError { msg: _ } => (None, None), RoverClientError::InvalidKey => (Some(Suggestion::CheckKey), None), RoverClientError::MalformedKey => (Some(Suggestion::ProperKey), None), From 31c34ad75d454b6433aae427b80c08f94f9c707c Mon Sep 17 00:00:00 2001 From: Avery Harnish Date: Thu, 25 Mar 2021 13:45:44 -0500 Subject: [PATCH 6/6] chore: implement From instead of Into --- src/utils/git.rs | 56 ++++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/utils/git.rs b/src/utils/git.rs index 4d51bed20..48b4ffd37 100644 --- a/src/utils/git.rs +++ b/src/utils/git.rs @@ -132,54 +132,54 @@ impl GitContext { } type GraphPublishContextInput = graph::publish::publish_schema_mutation::GitContextInput; -impl Into for GitContext { - fn into(self) -> GraphPublishContextInput { +impl From for GraphPublishContextInput { + fn from(git_context: GitContext) -> GraphPublishContextInput { GraphPublishContextInput { - branch: self.branch, - commit: self.commit, - committer: self.author, - remote_url: self.remote_url, - message: self.message, + branch: git_context.branch, + commit: git_context.commit, + committer: git_context.author, + remote_url: git_context.remote_url, + message: git_context.message, } } } type GraphCheckContextInput = graph::check::check_schema_query::GitContextInput; -impl Into for GitContext { - fn into(self) -> GraphCheckContextInput { +impl From for GraphCheckContextInput { + fn from(git_context: GitContext) -> GraphCheckContextInput { GraphCheckContextInput { - branch: self.branch, - commit: self.commit, - committer: self.author, - remote_url: self.remote_url, - message: self.message, + branch: git_context.branch, + commit: git_context.commit, + committer: git_context.author, + remote_url: git_context.remote_url, + message: git_context.message, } } } type SubgraphPublishContextInput = subgraph::publish::publish_partial_schema_mutation::GitContextInput; -impl Into for GitContext { - fn into(self) -> SubgraphPublishContextInput { +impl From for SubgraphPublishContextInput { + fn from(git_context: GitContext) -> SubgraphPublishContextInput { SubgraphPublishContextInput { - branch: self.branch, - commit: self.commit, - committer: self.author, - remote_url: self.remote_url, - message: self.message, + branch: git_context.branch, + commit: git_context.commit, + committer: git_context.author, + remote_url: git_context.remote_url, + message: git_context.message, } } } type SubgraphCheckContextInput = subgraph::check::check_partial_schema_query::GitContextInput; -impl Into for GitContext { - fn into(self) -> SubgraphCheckContextInput { +impl From for SubgraphCheckContextInput { + fn from(git_context: GitContext) -> SubgraphCheckContextInput { SubgraphCheckContextInput { - branch: self.branch, - commit: self.commit, - committer: self.author, - remote_url: self.remote_url, - message: self.message, + branch: git_context.branch, + commit: git_context.commit, + committer: git_context.author, + remote_url: git_context.remote_url, + message: git_context.message, } } }