Skip to content

Commit

Permalink
Refactor code to fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
xN4P4LM committed Oct 24, 2023
1 parent c8ff688 commit c4ffb83
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/controller/init/submodules/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub fn get_submodule_paths() -> Vec<(String, String, bool)> {
.collect::<Vec<String>>();

// return the submodule paths
return map_dirs(sub_module_paths);
map_dirs(sub_module_paths)
}

// check_if_submodule_init_run_needed(sub_module_paths: Vec<(String, String, bool)>)
Expand Down
4 changes: 2 additions & 2 deletions src/controller/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ pub fn run(command: String, args: &[String]) {
"status" => status(args),
"-v" | "--version" => {
// print the version number of the program
print!("Tools Version: {}\n", env!("CARGO_PKG_VERSION"));
print!("Project Version: {}\n", CONFIG.get_version());
println!("Tools Version: {}", env!("CARGO_PKG_VERSION"));
println!("Project Version: {}", CONFIG.get_version());
}
_ => {
helpers::help::main_help::print_help();
Expand Down
3 changes: 1 addition & 2 deletions src/helpers/docker/docker_compose/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ fn get_path_to_docker_compose() -> PathBuf {
let raw_project_path = &CONFIG.project_path;
let project_path = PathBuf::from(raw_project_path);
let docker_compose_filename = &CONFIG.docker_compose;
let docker_compose_path = append_path(&project_path, docker_compose_filename);
docker_compose_path
append_path(&project_path, docker_compose_filename)
}

/// ## get_docker_compose_file() -> DockerCompose
Expand Down
7 changes: 2 additions & 5 deletions src/helpers/filesystem/dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,11 @@ pub fn recursively_delete_directory(path: &str) -> bool {
/// - String - The absolute path of the directory
pub fn get_absolute_path(path: &str) -> String {
// check if the path starts with root, and if not, prepend the project path
let path = if path.starts_with("/") {
if path.starts_with("/") {
path.to_string()
} else {
format!("{}/{}", CONFIG.project_path, path)
};

// return the absolute path without checking if it exists
path
}
}

/// ## map_dirs(list_dirs: Vec<String>) -> Vec<(String, String, bool)>
Expand Down
6 changes: 2 additions & 4 deletions src/helpers/filesystem/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
/// - PathBuf - The path to the file or directory
#[allow(dead_code)]
pub fn get_path(path: &str) -> std::path::PathBuf {
let path = std::fs::canonicalize(path).unwrap();
path
std::fs::canonicalize(path).unwrap()
}

/// ## append_path(base_path: &PathBuf, file: &str)
Expand All @@ -22,6 +21,5 @@ pub fn get_path(path: &str) -> std::path::PathBuf {
/// ## Returns
/// - PathBuf - The path to the file or directory
pub fn append_path(base_path: &std::path::PathBuf, file: &str) -> std::path::PathBuf {
let file_path = base_path.join(file);
file_path
base_path.join(file)
}
7 changes: 3 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,18 @@ mod controller;
mod helpers;
mod models;

pub static CONFIG: Lazy<AppConfigFile> = Lazy::new(|| config::app_config::get_config());
pub static CONFIG: Lazy<AppConfigFile> = Lazy::new(config::app_config::get_config);

/// ## main()
/// This function is the entry point for the program
fn main() {
// if the config project path is not the current directory,
// warn the user that this may cause unexpected behavior
if CONFIG.project_path
!= std::env::current_dir()
if *CONFIG.project_path
!= *std::env::current_dir()
.expect("Couldn't get current directory")
.to_str()
.unwrap()
.to_string()
{
println!("WARNING: The project path in the configuration file is not the current directory. This may cause unexpected behavior.");
}
Expand Down
2 changes: 1 addition & 1 deletion src/models/project/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub struct Project {
pub description: String, // required - This is the description of the project that serves as the description of the repository
pub languages: Option<Vec<String>>, // optional - This is a list of programming languages used in the service
pub frameworks: Option<Vec<String>>, // optional - This is the framework the service is developed
pub services: Option<Vec<Box<Project>>>, // required for parent projects, or hierarchical projects - This is the list of services/children in the project
pub services: Option<Vec<Project>>, // required for parent projects, or hierarchical projects - This is the list of services/children in the project
pub repo: Option<Vec<ProjectRepository>>, // optional - This is the configuration for the repository
pub parent: Option<Box<Project>>, // required for hierarchical projects - This is the parent project of the microservice
pub from_template: Option<bool>, // optional - This indicates if the repository was created from a templates
Expand Down

0 comments on commit c4ffb83

Please sign in to comment.