-
Notifications
You must be signed in to change notification settings - Fork 822
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
common: Replace StringDataCompare with slices.Contains and cleanup string funcs #1631
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1631 +/- ##
==========================================
+ Coverage 36.50% 38.35% +1.84%
==========================================
Files 414 414
Lines 179351 149152 -30199
==========================================
- Hits 65472 57201 -8271
+ Misses 106004 84076 -21928
Partials 7875 7875
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good stuff just a minor thing, commentary and suggestion.
docs/ADD_NEW_EXCHANGE.md
Outdated
@@ -267,9 +267,9 @@ func TestGetEnabledExchanges(t *testing.T) { | |||
t.Errorf("received: '%v' but expected '%v'", len(exchanges), defaultEnabledExchanges) | |||
} | |||
|
|||
if !common.StringDataCompare(exchanges, "Bitfinex") { | |||
if !slices.Contains(exchanges, "Bitfinex") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: This is just pedantic nit picky all these changes on test files can use assert or require package. Resolve if you can't be bothered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed these since they aren't relevant anymore, can do a full updated pass in #1494 once Bitget PR is opened
allowedGranularities := [6]int64{60, 300, 900, 3600, 21600, 86400} | ||
validGran, _ := common.InArray(granularity, allowedGranularities) | ||
if !validGran { | ||
allowedGranularities := []int64{60, 300, 900, 3600, 21600, 86400} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE: Just had a quick play and which I thought was interesting, we can reduce the two parameter instance of a lot of these. Out of scope though.
// Container is a generic type for slices
type Container[T comparable] []T
func (c Container[T]) Contains(in T) bool {
return slices.Contains(c, in)
}
func TestXxx(t *testing.T) {
allowedGranularities := Container[int64]{60, 300, 900, 3600, 21600, 86400}
assert.True(t, allowedGranularities.Contains(300))
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥 Thanks. chACK.
80226e4
to
66f4770
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
soz
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks tACK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tACK!
PR Description
Replace StringDataCompare with slices.Contains + a bit of a cleanup. I've made StringSliceDifference generic since I thought it might be useful moving forward, though since we don't currently use it anywhere now I'd be happy to rm -rf it 😈
Type of change
How has this been tested
Checklist