Skip to content

Improve coverage in permalinks package #1502

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

Merged
merged 2 commits into from
Oct 6, 2023

Conversation

jmartinesp
Copy link
Member

@jmartinesp jmartinesp commented Oct 6, 2023

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other : Improve coverage in io.element.android.libraries.matrix.api.permalink (it was 9% before).

Content

Added some tests to check our handling of permalinks is correct, and also improve coverage.

Motivation and context

Improving reliability, bumping coverage.

Checklist

@jmartinesp jmartinesp requested a review from a team as a code owner October 6, 2023 08:27
@jmartinesp jmartinesp requested review from julioromano and removed request for a team October 6, 2023 08:27
@github-actions
Copy link
Contributor

github-actions bot commented Oct 6, 2023

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/vSDhRz

@codecov
Copy link

codecov bot commented Oct 6, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (5d49196) 58.39% compared to head (28ac632) 58.71%.
Report is 2 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1502      +/-   ##
===========================================
+ Coverage    58.39%   58.71%   +0.32%     
===========================================
  Files         1133     1133              
  Lines        30298    30298              
  Branches      6214     6214              
===========================================
+ Hits         17692    17789      +97     
+ Misses        9951     9838     -113     
- Partials      2655     2671      +16     

see 6 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

@julioromano julioromano left a comment

Choose a reason for hiding this comment

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

LGTM!

/**
* Returns true if the app is in debug mode.
*/
fun isInDebug() = BuildConfig.DEBUG

Choose a reason for hiding this comment

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

This is what I call "API renaming", I used to do quite a good amount of this in another codebase and then started wondering if I really should:

  • On one side I like it because it make things more idiomatic.
  • On the other it makes the code less readable to new comers (every Android dev knows what BuildConfig.DEBUG is but nobody knows what isInDebug() so it could potentially do anything).

Copy link
Member Author

Choose a reason for hiding this comment

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

I just did this because BuildConfig.DEBUG didn't seem to be accessible in unit tests. Maybe by generating resources it would work?

Choose a reason for hiding this comment

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

BuildConfig generation is optional since AGP8, maybe that's the issue?
But even better question, why do you need BuildConfig in a unit test, what are you trying to do?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, the BuildConfig generation is already enabled for that module. As for why I need this, it's because UserId("foo") will crash in debug mode so we can track invalid ids but will work fine in release mode. Since we have some code that needs to check for invalid ids in release mode in these classes we need to take into account both cases.

Another option would be to remove this check.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Oct 6, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@jmartinesp jmartinesp merged commit 6a7713a into develop Oct 6, 2023
@jmartinesp jmartinesp deleted the chore/jme/improve-coverage-in-permalinks branch October 6, 2023 09:37
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.

2 participants