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

refactor: Extract func coerceValue from set and remove func set #149

Merged
merged 3 commits into from
Sep 24, 2021

Conversation

dylanahsmith
Copy link
Collaborator

cc @wisepythagoras

Problem

#145 is attempting to follow the current pattern of merging more code paths into set, which results in extra conditional complexity in set in order to essentially determine where it is called from and thus which argument to use.

Solution

The common functionality in the set function is value coercion, so just extract that to a separate function so that we can get rid of set.

Note that this makes all of these functions (coerceValue, Set, SetIdx) a lot more readable in isolation. In contrast, the call site for set makes it unclear why the placeholder arguments are passed in and the set function is harder to understand without knowing the context in which it is called from.

@codecov
Copy link

codecov bot commented Jun 25, 2021

Codecov Report

Merging #149 (97dc1ff) into master (8d15ff3) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #149      +/-   ##
==========================================
+ Coverage   97.46%   97.48%   +0.01%     
==========================================
  Files          12       12              
  Lines         474      477       +3     
==========================================
+ Hits          462      465       +3     
  Misses          8        8              
  Partials        4        4              
Impacted Files Coverage Δ
object.go 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8d15ff3...97dc1ff. Read the comment docs.

@wisepythagoras
Copy link
Contributor

I like this solution. I'll incorporate it in #145 once it's merged.

Copy link
Owner

@rogchap rogchap left a comment

Choose a reason for hiding this comment

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

Reads better, thank you.

@dylanahsmith dylanahsmith merged commit 9d9805c into rogchap:master Sep 24, 2021
@dylanahsmith dylanahsmith deleted the split-object-set branch September 24, 2021 00:43
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.

3 participants