Skip to content

Commit

Permalink
fix: clear all clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ajaykumargdr committed Dec 28, 2023
1 parent cbe2592 commit 3035d88
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 6,146 deletions.
6,102 changes: 0 additions & 6,102 deletions Cargo.lock

This file was deleted.

13 changes: 3 additions & 10 deletions workflow/composer-v2/composer_primitives/src/types/source_files.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
use std::{
env::current_dir,
ffi::OsStr,
fs,
path::PathBuf,
};
use anyhow::Error;
use std::{env::current_dir, ffi::OsStr, fs, path::PathBuf};

use itertools::Either;
use walkdir::WalkDir;
use std::collections::HashSet;
use walkdir::WalkDir;

use crate::constant::FILE_EXTENSION;

#[derive(Clone, Debug )]
#[derive(Clone, Debug)]
pub struct SourceFiles {
base: PathBuf,
files: HashSet<PathBuf>,
Expand All @@ -35,7 +30,6 @@ impl SourceFiles {

let file_paths = fs::read_dir(&base)
.unwrap()
.into_iter()
.flat_map(|item| {
let item = item.unwrap();

Expand Down Expand Up @@ -72,5 +66,4 @@ impl SourceFiles {
pub fn base(&self) -> &PathBuf {
&self.base
}

}
34 changes: 17 additions & 17 deletions workflow/composer-v2/echo-library/src/common/composer.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use std::fs::OpenOptions;
use std::io::Write;

use anyhow::Ok;
use composer_primitives::types::SourceFiles;
use starlark::environment::FrozenModule;
use starlark::eval::ReturnFileLoader;
use std::fs::OpenOptions;
use std::io::Write;
use std::path::Path;

use super::*;

Expand Down Expand Up @@ -79,7 +79,7 @@ impl Composer {
}
}

pub fn build(&self, verbose: bool, temp_dir: &PathBuf) -> Result<(), Error> {
pub fn build(&self, verbose: bool, temp_dir: &Path) -> Result<(), Error> {
if verbose {
Command::new("rustup")
.current_dir(temp_dir.join("boilerplate"))
Expand All @@ -101,23 +101,23 @@ impl Composer {

fn copy_boilerplate(
&self,
temp_dir: &PathBuf,
temp_dir: &Path,
types_rs: &str,
workflow_name: String,
workflow: &Workflow,
) -> Result<PathBuf, Error> {
let temp_dir = temp_dir.join(&workflow_name);
let temp_dir = temp_dir.join(workflow_name);
let curr = temp_dir.join("boilerplate");

std::fs::create_dir_all(curr.clone().join("src"))?;

let src_curr = temp_dir.join("boilerplate/src");
let temp_path = src_curr.as_path().join("common.rs");

std::fs::write(temp_path, &COMMON[..])?;
std::fs::write(temp_path, COMMON)?;

let temp_path = src_curr.as_path().join("lib.rs");
std::fs::write(temp_path.clone(), &LIB[..])?;
std::fs::write(temp_path.clone(), LIB)?;

let mut lib = OpenOptions::new()
.write(true)
Expand All @@ -131,13 +131,13 @@ impl Composer {
std::fs::write(temp_path, types_rs)?;

let temp_path = src_curr.as_path().join("traits.rs");
std::fs::write(temp_path, &TRAIT[..])?;
std::fs::write(temp_path, TRAIT)?;

let temp_path = src_curr.as_path().join("macros.rs");
std::fs::write(temp_path, &MACROS[..])?;
std::fs::write(temp_path, MACROS)?;

let cargo_path = curr.join("Cargo.toml");
std::fs::write(cargo_path.clone(), &CARGO[..])?;
std::fs::write(cargo_path.clone(), CARGO)?;

let mut cargo_toml = OpenOptions::new()
.write(true)
Expand Down Expand Up @@ -177,12 +177,12 @@ impl Composer {
for load in ast.loads() {
loads.push((
load.module_id.to_owned(),
Self::compile(&self, load.module_id, files)?,
Self::compile(self, load.module_id, files)?,
));
}

let modules = loads.iter().map(|(a, b)| (a.as_str(), b)).collect();
let mut loader = ReturnFileLoader { modules: &modules };
let loader = ReturnFileLoader { modules: &modules };

// We build our globals by adding some functions we wrote
let globals = GlobalsBuilder::extended_by(&[
Expand Down Expand Up @@ -223,7 +223,7 @@ impl Composer {
{
let mut eval = Evaluator::new(&module);
// We add a reference to our store
eval.set_loader(&mut loader);
eval.set_loader(&loader);
eval.extra = Some(self);
eval.eval_module(ast, &globals)?;
}
Expand All @@ -233,8 +233,8 @@ impl Composer {

pub fn build_directory(
&self,
build_path: &PathBuf,
out_path: &PathBuf,
build_path: &Path,
out_path: &Path,
quiet: bool,
) -> Result<(), Error> {
let composer_custom_types = self.custom_types.borrow();
Expand All @@ -250,7 +250,7 @@ impl Composer {
&composer_custom_types,
)?;
let temp_dir =
self.copy_boilerplate(build_path, &types_rs, workflow_name.clone(), &workflow)?;
self.copy_boilerplate(build_path, &types_rs, workflow_name.clone(), workflow)?;

self.build(quiet, &temp_dir)?;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::*;
use anyhow::anyhow;

#[allow(clippy::type_complexity)]
#[starlark_module]
pub fn starlark_workflow_module(builder: &mut GlobalsBuilder) {
/// Creates a new task of the workflow and returns a task object of `Task` type
Expand Down
10 changes: 2 additions & 8 deletions workflow/composer-v2/echo-library/src/types/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,11 @@ pub enum Operation {

impl Operation {
pub fn is_map(&self) -> bool {
match self {
Self::Map(_) => true,
_ => false,
}
matches!(self, Self::Map(_))
}

pub fn is_combine(&self) -> bool {
match self {
Self::Combine => true,
_ => false,
}
matches!(self, Self::Combine)
}
}

Expand Down
6 changes: 3 additions & 3 deletions workflow/composer-v2/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use crate::commands::Commands;
use clap::StructOpt;

/// CLI Arguments entry point - includes global parameters and subcommands
/// Cli Arguments entry point - includes global parameters and subcommands
#[derive(StructOpt, Debug)]
#[structopt(
name = "composer",
author = "The HugoByte Team <[email protected]>",
version = "0.0.1"
)]
pub struct CLI {
pub struct Cli {
#[structopt(
short,
global = true,
Expand All @@ -23,7 +23,7 @@ pub struct CLI {
pub command: Commands,
}

impl CLI {
impl Cli {
pub fn quiet(&self) -> bool {
self.quiet
}
Expand Down
2 changes: 1 addition & 1 deletion workflow/composer-v2/src/commands/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ workflows(
self.package_name
);

fs::write(&temp_path, content.as_bytes()).map_err(io_error)
fs::write(temp_path, content.as_bytes()).map_err(io_error)
}
}
8 changes: 4 additions & 4 deletions workflow/composer-v2/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub(crate) use lib::*;
use clap::Parser;
use cli::*;
use commands::*;
use composer_primitives::{Result, Execute};
use composer_primitives::{Execute, Result};
use std::process::exit;
use types::Context;

Expand Down Expand Up @@ -35,7 +35,7 @@ fn set_panic_hook() {
"note: composer args: {}\n",
std::env::args().collect::<Vec<_>>().join(" ")
);
eprintln!("note: composer flags: {:?}\n", CLI::parse());
eprintln!("note: composer flags: {:?}\n", Cli::parse());
})
});
}
Expand All @@ -51,7 +51,7 @@ pub fn handle_error<T>(res: Result<T>) -> T {
}
}

pub fn run_with_args(cli: CLI) -> Result<()> {
pub fn run_with_args(cli: Cli) -> Result<()> {
let mut context = handle_error(Context::new());
if !cli.quiet() {
context.quiet();
Expand All @@ -68,5 +68,5 @@ pub fn run_with_args(cli: CLI) -> Result<()> {

fn main() {
set_panic_hook();
handle_error(run_with_args(CLI::parse()));
handle_error(run_with_args(Cli::parse()));
}

0 comments on commit 3035d88

Please sign in to comment.