Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

finish build new template project #54

Conversation

0nSystem
Copy link
Member

No description provided.

) {
// TODO required validate or control optionals
info!("Create template project");
let name = name_template.as_deref().unwrap_or("calculator");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review the lines 29-32. There's no need to dereference the option

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its solved

// TODO required validate or control optionals
info!("Create template project");
let name = name_template.as_deref().unwrap_or("calculator");
let resolved_compiler = compiler.clone().unwrap_or(CppCompiler::CLANG); // Deref ??? and not clone?
Copy link
Member

@TheRustifyer TheRustifyer Dec 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no need to clone. Also, there's no need to pass the Optionals there as references. Move the values (ie, pass by value)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is solved we required CppCompiler use Clone because ValueEnum hasnt implementarios Copy trait

zork_conf = zork_conf.replace("libcpp", "stdlib")
}
create_file(
&PathBuf::from_str(root_path.to_str().unwrap())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace raw .unwrap() for .expect(msg), or better use if let pattern in these situations

}
";

const SRC_MOD_FILE_2: &'static str = "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MOVE all the str slices to it's own file, ie: constants.rs or simillar

"
.as_bytes();

const SRC_MOD_FILE: &'static str = "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's usually a code smell anotate the lifetime of const or static string slices. They are always static, as they are stored directly in the generated binary. Remove the 'static lifetimes of those const declarations

DirBuilder::new()
.recursive(true)
.create(path_create)
.expect(format!("Error create directory: {}", path_create.to_string_lossy()).as_str())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error create directory => `Error create directory

DirBuilder::new()
.recursive(true)
.create(path_create)
.expect(format!("Error create directory: {}", path_create.to_string_lossy()).as_str())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.to_string_lossy(). Try to use one of the UTF-8 alternatives to mantain consistency across the whole API

@@ -10,4 +16,19 @@ fn main() {
log::warn!("warn");
log::info!("info");
log::error!("error");

create_template_project(&Some("proyect".to_owned()), true, &Some(CppCompiler::CLANG));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are passing default useless values. Remove then from the call site (here) or explictly pass a valid reference to the parser_cli args

move to constant variables
@0nSystem 0nSystem force-pushed the feature/GH-45-rewrite-zork++-from-scratch-in-rust-template-project branch from 6b3822f to 7aed694 Compare January 1, 2023 19:32
@TheRustifyer TheRustifyer self-requested a review January 1, 2023 20:49
match parser_cli.command.unwrap() {
zork::config_cli::Command::Tests => todo!(),
}
}else{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New code hasn't been formated, as usual...


}

fn execution_procces(path: &Path) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fn execution_process() isn't documented. Probably we may know what the function is doing, but not other people involved in the project. Every new feature in the code must be documented

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TheHiddenOnSystem solve the TODO's letfted on the code and request for approve again

@TheRustifyer TheRustifyer merged commit 04a95a2 into zerodaycode:feature/GH-45-rewrite-zork++-from-scratch-in-rust Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants