Skip to content

Commit

Permalink
fix: clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
shanithkk committed Dec 28, 2023
1 parent 34aa98b commit cbe2592
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion workflow/composer-v2/echo-library/src/common/composer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ impl Composer {

let wasm_path = format!(
"{}/boilerplate/target/wasm32-wasi/release/boilerplate.wasm",
temp_dir.display().to_string()
temp_dir.display()
);

fs::create_dir_all(out_path.join("output"))?;
Expand Down
12 changes: 6 additions & 6 deletions workflow/composer-v2/echo-library/src/common/parse_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,11 +356,11 @@ fn get_impl_execute_trait_code(workflow: &Workflow) -> String {
fn get_add_nodes_code(flow: &Vec<String>) -> String {
let mut add_nodes_code = String::new();

for i in 0..flow.len() {
for i in flow {
add_nodes_code.push_str(&format!(
"let {}_index = workflow.add_node(Box::new({}));\n",
flow[i].to_case(Case::Snake),
flow[i].to_case(Case::Snake)
i.to_case(Case::Snake),
i.to_case(Case::Snake)
));
}

Expand Down Expand Up @@ -574,11 +574,11 @@ pub fn add_polkadot_openwhisk(workflow: &Workflow) -> String {
let mut toml_dependencies = String::new();

if kinds.contains("openwhisk") {
toml_dependencies = format!("{}", get_openwhisk());
toml_dependencies = get_openwhisk();
}

if kinds.contains("polkadot") {
toml_dependencies = format!("{}", get_polkadot());
toml_dependencies = get_polkadot();
}

if kinds.contains("openwhisk") && kinds.contains("polkadot") {
Expand Down Expand Up @@ -616,7 +616,7 @@ pub fn get_struct_stake_ledger(workflow: &Workflow) -> String {
let mut toml_dependencies = String::new();

if kinds.contains("polkadot") {
toml_dependencies = format!("{}", staking_ledger());
toml_dependencies = staking_ledger();
}

toml_dependencies
Expand Down
6 changes: 3 additions & 3 deletions workflow/composer-v2/src/commands/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ pub struct Create {

impl Create {
pub fn execute(self) -> result::Result<()> {
let current = std::env::current_dir().map_err(|error| io_error(error))?;
let current = std::env::current_dir().map_err(io_error)?;
let package = current.join(&self.package_name);
fs::create_dir_all(&package).map_err(|error| io_error(error))?;
fs::create_dir_all(&package).map_err(io_error)?;

let temp_path = package.join("main.echo");
let content = format!(
Expand All @@ -39,6 +39,6 @@ workflows(
self.package_name
);

fs::write(&temp_path, content.as_bytes()).map_err(|error| io_error(error))
fs::write(&temp_path, content.as_bytes()).map_err(io_error)
}
}
6 changes: 5 additions & 1 deletion workflow/composer-v2/src/errors/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ impl From<std::io::Error> for IOError {

impl Display for IOError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self)
match self {
IOError::PathNotFound => write!(f, "PathNotFound"),
IOError::Anyhow(error) => write!(f, "ErrorInComposer: {}", error),
IOError::Other(error) => write!(f, "Error: {}", error),
}
}
}
2 changes: 1 addition & 1 deletion workflow/composer-v2/src/types/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl Default for Context {
build_directory: None,
output_directory: None,
source_files: None,
parser: Box::new(Composer::default()),
parser: Box::<Composer>::default(),
quiet: false,
}
}
Expand Down
2 changes: 1 addition & 1 deletion workflow/composer-v2/src/types/echo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl Parser for Composer {
output_directory: &OutputDirectory,
quiet: bool,
) -> result::Result<()> {
self.build_directory(&build_directory.path, &output_directory.base(), quiet)
self.build_directory(&build_directory.path, output_directory.base(), quiet)
.map_err(|error| Box::new(IOError::Anyhow(error)) as Box<dyn Exception>)?;
Ok(())
}
Expand Down

0 comments on commit cbe2592

Please sign in to comment.