Skip to content

SR use case insensitive when checking wireframe background color opacity#1223

Merged
mariusc83 merged 1 commit into
feature/sdkv2from
mconstantin/fix-translucent-color-verification
Jan 10, 2023
Merged

SR use case insensitive when checking wireframe background color opacity#1223
mariusc83 merged 1 commit into
feature/sdkv2from
mconstantin/fix-translucent-color-verification

Conversation

@mariusc83

Copy link
Copy Markdown
Member

What does this PR do?

We were using assuming that the Wireframe backgroundColor will always be reported in capital letters when checking for its opacity. This was buggy and in this PR we are fixing this by using a case insensitive RegEx instead.

Motivation

What inspired you to submit this pull request?

Additional Notes

Anything else we should know when reviewing?

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)

@mariusc83 mariusc83 self-assigned this Jan 9, 2023
@mariusc83
mariusc83 marked this pull request as ready for review January 9, 2023 12:17
@mariusc83
mariusc83 requested a review from a team as a code owner January 9, 2023 12:17
return this.opacity == FULL_OPACITY_ALPHA &&
this.backgroundColor != null &&
this.backgroundColor.takeLast(2) == FULL_OPACITY_ALPHA_AS_HEXA_STRING
this.backgroundColor.takeLast(2).matches(FULL_OPACITY_REG_EX)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

probably we don't need regex here, we can just convert to upper/lowecase and compare?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yes was not sure which one is better but I think conversion is faster. I will do that.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

Merging #1223 (c0c2ad6) into feature/sdkv2 (0b06acb) will increase coverage by 0.04%.
The diff coverage is 93.88%.

@@                Coverage Diff                @@
##           feature/sdkv2    #1223      +/-   ##
=================================================
+ Coverage          82.72%   82.76%   +0.04%     
=================================================
  Files                353      354       +1     
  Lines              12589    12590       +1     
  Branches            2086     2088       +2     
=================================================
+ Hits               10414    10420       +6     
+ Misses              1535     1530       -5     
  Partials             640      640              
Impacted Files Coverage Δ
.../kotlin/com/datadog/android/v2/api/FeatureScope.kt 50.00% <ø> (ø)
.../android/sessionreplay/processor/WireframeUtils.kt 98.36% <50.00%> (-1.64%) ⬇️
...otlin/com/datadog/android/tracing/AndroidTracer.kt 92.94% <85.71%> (-1.43%) ⬇️
...android/log/internal/domain/DatadogLogGenerator.kt 97.04% <100.00%> (+0.09%) ⬆️
...essionreplay/internal/domain/RequestBodyFactory.kt 97.62% <100.00%> (-0.38%) ⬇️
...lay/internal/domain/SessionReplayRequestFactory.kt 96.23% <100.00%> (-0.96%) ⬇️
...nternal/exception/InvalidPayloadFormatException.kt 100.00% <100.00%> (ø)
...n/com/datadog/android/v2/core/SdkInternalLogger.kt 88.89% <0.00%> (-2.78%) ⬇️
...ain/java/com/datadog/opentracing/PendingTrace.java 56.90% <0.00%> (-2.59%) ⬇️
...lin/com/datadog/android/rum/internal/RumFeature.kt 92.03% <0.00%> (-1.45%) ⬇️
... and 18 more

@mariusc83
mariusc83 force-pushed the mconstantin/fix-translucent-color-verification branch from c0c2ad6 to 1789cee Compare January 9, 2023 13:21

@0xnm 0xnm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm! I added some suggestions.

return this.opacity == FULL_OPACITY_ALPHA &&
this.backgroundColor != null &&
this.backgroundColor.takeLast(2) == FULL_OPACITY_ALPHA_AS_HEXA_STRING
this.backgroundColor.takeLast(2).lowercase() == FULL_OPACITY_STRING_HEXA

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
this.backgroundColor.takeLast(2).lowercase() == FULL_OPACITY_STRING_HEXA
this.backgroundColor.takeLast(2).lowercase(Locale.US) == FULL_OPACITY_STRING_HEXA

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Isn't it by default ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Oh the default is the ROOT meaning the project locale....damn


companion object {
const val FULL_OPACITY_ALPHA_AS_HEXA_STRING = "FF"
val FULL_OPACITY_STRING_HEXA = "ff"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
val FULL_OPACITY_STRING_HEXA = "ff"
const val FULL_OPACITY_STRING_HEXA = "ff"

@mariusc83
mariusc83 force-pushed the mconstantin/fix-translucent-color-verification branch from 1789cee to c226a55 Compare January 9, 2023 13:27
@mariusc83
mariusc83 force-pushed the mconstantin/fix-translucent-color-verification branch from c226a55 to 2f7ddb1 Compare January 10, 2023 08:55
@mariusc83
mariusc83 merged commit 8747487 into feature/sdkv2 Jan 10, 2023
@mariusc83
mariusc83 deleted the mconstantin/fix-translucent-color-verification branch January 10, 2023 10:05
@xgouchet xgouchet added this to the 1.17.0 milestone Dec 13, 2023
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.

4 participants