Skip to content
This repository was archived by the owner on Jan 22, 2024. It is now read-only.

Refactor Memo List Serialization#528

Merged
keefertaylor merged 2 commits intomasterfrom
refactor-memo-1
Sep 17, 2020
Merged

Refactor Memo List Serialization#528
keefertaylor merged 2 commits intomasterfrom
refactor-memo-1

Conversation

@keefertaylor
Copy link
Contributor

High Level Overview of Change

Refactor memo list to be standardized.

Context of Change

Refactor method to use same idioms as other list serialization methods (see for example, pathListToJSON).

Specifically:

  • Change name to memoListToJSON for consistency
  • Use a simple map function internally
  • Do not check inputs for validity, defer that responsibility to callers (note, this removes a unit test)
  • Input is Array<Memo> and output is Array<MemoJSON>

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (non-breaking change that only restructures code)
  • Tests (You added tests for code that already exists, or your new feature included in this PR)
  • Documentation Updates
  • Release

Before / After

No change. This is prep work for a larger refactor of common transaction fields in #519

Test Plan

CI shows that this does not affect the public API; removed a unit test which was testing removed functionality.

return { Memos: convertedMemos }
memoListToJSON(memos: Memo[]): MemoJSON[] {
// eslint-disable-next-line @typescript-eslint/unbound-method -- Manually assigning `this`.
return memos.map(this.memoToJSON, this)
Copy link
Contributor

@tedkalaw tedkalaw Sep 10, 2020

Choose a reason for hiding this comment

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

can you use an arrow function instead here?

return memos.map((memo) => this.memoToJSON(memo))

this is preserved in arrow functions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Totally. I was trying to make the linter happy here (we do this other places too).

Do we have any thoughts on whether we should disable this linter rule?

Copy link
Contributor

Choose a reason for hiding this comment

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

it gets mad with arrow functions? the dox for the rule implies that arrow funcs are cool: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/unbound-method.md

if we're doing this other places already, i say just go for it as is

@keefertaylor
Copy link
Contributor Author

keefertaylor commented Sep 10, 2020

+ Hans who may have comments about the linter. I think you've mentioned we could disable the rule in question in the past, I just forget exactly what you've said :)

@keefertaylor
Copy link
Contributor Author

Gentle ping, @tedkalaw

@codecov
Copy link

codecov bot commented Sep 16, 2020

Codecov Report

Merging #528 into master will decrease coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #528      +/-   ##
==========================================
- Coverage   92.01%   92.00%   -0.02%     
==========================================
  Files          11       11              
  Lines         676      675       -1     
  Branches      161      161              
==========================================
- Hits          622      621       -1     
  Misses         28       28              
  Partials       26       26              
Impacted Files Coverage Δ
src/XRP/serializer.ts 92.13% <100.00%> (-0.02%) ⬇️

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 d080413...6ed7f05. Read the comment docs.

return { Memos: convertedMemos }
memoListToJSON(memos: Memo[]): MemoJSON[] {
// eslint-disable-next-line @typescript-eslint/unbound-method -- Manually assigning `this`.
return memos.map(this.memoToJSON, this)
Copy link
Contributor

Choose a reason for hiding this comment

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

it gets mad with arrow functions? the dox for the rule implies that arrow funcs are cool: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/unbound-method.md

if we're doing this other places already, i say just go for it as is

@keefertaylor keefertaylor merged commit 3f6acff into master Sep 17, 2020
@keefertaylor keefertaylor deleted the refactor-memo-1 branch September 17, 2020 06:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants