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

#1144 Disable node coloring when uploading file with no expression #1153

Merged
merged 5 commits into from
Dec 4, 2024

Conversation

ntran18
Copy link
Collaborator

@ntran18 ntran18 commented Nov 27, 2024

No description provided.

@ntran18 ntran18 changed the base branch from master to beta November 27, 2024 01:10
@ntran18 ntran18 requested a review from dondi November 27, 2024 01:10
Copy link
Owner

@dondi dondi left a comment

Choose a reason for hiding this comment

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

Good refactors! I have a suggestion for one more…see if it’s doable (hope you agree about the benefits I list here about the benefits of using the some iterator)

Comment on lines 515 to 522
const hasExpressionData = (sheets) => {
for (var property in sheets) {
if (property.match(ENDS_IN_EXPRESSION_REGEXP)) {
return true;
}
}
return false;
};
Copy link
Owner

Choose a reason for hiding this comment

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

This isn’t functionally incorrect, but along the lines of more current idioms when processing lists or objects, see if this can be written as a some call? https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some

Using some will make the code look something like this…

Suggested change
const hasExpressionData = (sheets) => {
for (var property in sheets) {
if (property.match(ENDS_IN_EXPRESSION_REGEXP)) {
return true;
}
}
return false;
};
const hasExpressionData = (sheets) => {
return (/*expression with sheets*/).some(
value => (/*expression with value */).match(ENDS_IN_EXPRESSION_REGEXP)
)
};

…which to me sounds more concise, and objectively does not use side effects as well as easier for an optimizer to parallelize

I realize sheets isn’t an array, but there may be ways to take advantage of the simpler expressiveness of some vs. having a return true with a return false at the end (that’s why I have some placeholder /* */ comments in there instead of specific code; there may be other places too)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I just modified it to use some call instead.

Copy link
Owner

Choose a reason for hiding this comment

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

You certainly modified it in graph.js, but does that mean that lines 515–522 above are duplicated?

Copy link
Owner

@dondi dondi left a comment

Choose a reason for hiding this comment

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

The some refactor looks great, but I hadn’t realized that there appear to be two copies of hasExpressionData? Please take a look at the overall diff; thanks!

}
}
return false;
return Object.keys(sheets).some(property => property.match(ENDS_IN_EXPRESSION_REGEXP));
Copy link
Owner

Choose a reason for hiding this comment

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

Thanks, this looks good! But it looks like this function is duplicated in update-app.js? (see line 515 below) Should these functions be consolidated into one?

Sorry I didn’t notice this before…

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I didn't notice it either ....

Comment on lines 515 to 522
const hasExpressionData = (sheets) => {
for (var property in sheets) {
if (property.match(ENDS_IN_EXPRESSION_REGEXP)) {
return true;
}
}
return false;
};
Copy link
Owner

Choose a reason for hiding this comment

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

You certainly modified it in graph.js, but does that mean that lines 515–522 above are duplicated?

Copy link
Owner

@dondi dondi left a comment

Choose a reason for hiding this comment

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

LGTM—it appears we have accidentally found some hidden duplicated code 😁 That was a lucky search-and-replace accident haha

@dondi dondi merged commit 347fca8 into beta Dec 4, 2024
1 check passed
@dondi dondi deleted the maika-1144 branch December 4, 2024 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants