Skip to content

Refactor build-templated-pages/features #12241

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tygyh
Copy link
Contributor

@tygyh tygyh commented Mar 1, 2024

Objective

  • Refactor 'features' file to remove boolean argument and increase readability.

Solution

  • Extract methods and change arguments.

@tygyh tygyh force-pushed the Refactor-features branch from 797eae3 to cea7ab8 Compare March 1, 2024 20:55
Copy link
Contributor

github-actions bot commented Mar 1, 2024

You added a new feature but didn't add a description for it. Please update the root Cargo.toml file.

@alice-i-cecile alice-i-cecile requested a review from BD103 March 1, 2024 21:05
@alice-i-cecile alice-i-cecile changed the title Refactor features Refactor build-generated-pages/features Mar 2, 2024
@alice-i-cecile alice-i-cecile changed the title Refactor build-generated-pages/features Refactor build-templated-pages/features Mar 2, 2024
@alice-i-cecile alice-i-cecile added C-Code-Quality A section of code that is hard to understand or change A-Meta About the project itself labels Mar 2, 2024
Copy link
Member

@BD103 BD103 left a comment

Choose a reason for hiding this comment

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

I agree that a refactor is due here, but I have a few requests. The main goal is to increase readability and decrease pointless allocations, by using more references and such.

Comment on lines 98 to 104
let value = |v: &Value| {
let feature_name = v.as_str().unwrap();
let feature = |v: &Value| v.as_str().unwrap().to_string();
let features_to_array = |name| features.get(name).unwrap().as_array().unwrap();
let map = features_to_array(feature_name).iter().map(feature);
std::iter::once(feature_name.to_string()).chain(map)
};
Copy link
Member

Choose a reason for hiding this comment

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

This is quite difficult to read. Is there a way to refactor this so it is more understandable? (Even better, if you can return impl Iterator<Item = String / &str>.)

If that's not possible, could you add comments explaining the purpose of this code?

@tygyh tygyh force-pushed the Refactor-features branch from cea7ab8 to d3d9e59 Compare March 2, 2024 22:41
Copy link
Contributor

github-actions bot commented Mar 2, 2024

You added a new example but didn't add metadata for it. Please update the root Cargo.toml file.

@tygyh tygyh force-pushed the Refactor-features branch from d3d9e59 to 7e5a828 Compare March 2, 2024 22:49
Copy link
Contributor

github-actions bot commented Mar 2, 2024

You added a new feature but didn't add a description for it. Please update the root Cargo.toml file.

@tygyh tygyh force-pushed the Refactor-features branch from 7e5a828 to 69ccd9b Compare March 2, 2024 23:03
Copy link
Contributor

github-actions bot commented Mar 2, 2024

You added a new feature but didn't add a description for it. Please update the root Cargo.toml file.

@tygyh tygyh force-pushed the Refactor-features branch from 69ccd9b to 6ea62b9 Compare March 3, 2024 07:37
Copy link
Contributor

github-actions bot commented Mar 3, 2024

You added a new feature but didn't add a description for it. Please update the root Cargo.toml file.

@IQuick143 IQuick143 added the S-Adopt-Me The original PR author has no intent to complete this work. Pick me up! label May 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Meta About the project itself C-Code-Quality A section of code that is hard to understand or change S-Adopt-Me The original PR author has no intent to complete this work. Pick me up!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants