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

Reduce cognitive complexity: just move some of the contents in functions #4743

Merged
merged 4 commits into from
Apr 18, 2023

Conversation

sylvestre
Copy link
Contributor

No description provided.

@uutils uutils deleted a comment from github-actions bot Apr 16, 2023
/// # Panics
///
/// Panics if multiple hash algorithms are specified or if a required flag is missing.
fn create_algorithm_from_flags(matches: &ArgMatches) -> (&'static str, Box<dyn Digest>, usize) {
Copy link
Contributor

Choose a reason for hiding this comment

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

For consistency reasons I would either rename this function to create_algo_from_flags or rename the existing function detect_algo to detect_algorithm

///
/// Returns an empty Result or an error in case of failure.
///
fn strip_file(to: &Path, b: &Behavior) -> UResult<()> {
if b.strip && cfg!(not(windows)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would move if b.strip to the copy function and replace cfg!(not(windows)) with #[cfg(not(windows))].

Copy link
Contributor Author

Choose a reason for hiding this comment

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

much better, thanks

@sylvestre sylvestre merged commit e734be6 into uutils:main Apr 18, 2023
@sylvestre sylvestre deleted the cognitive_complexity branch April 18, 2023 06:06
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