Skip to content

Konsist #1526

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 11 commits into from
Oct 11, 2023
Merged

Konsist #1526

merged 11 commits into from
Oct 11, 2023

Conversation

bmarty
Copy link
Member

@bmarty bmarty commented Oct 10, 2023

Type of change

  • Feature
  • Bugfix
  • Technical: More quality on the project
  • Other :

Content

Add Konsist to do some static analysis on the code.
Add some test and fixes the existing issues.

Motivation and context

More quality and consistency across the codebase.

Screenshots / GIFs

NA

Tests

  • Konsist tests are unit test.
  • Smoke test for regression, but should be covered by screenshot test.

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

@bmarty bmarty requested a review from a team as a code owner October 10, 2023 15:37
@bmarty bmarty requested review from jmartinesp and removed request for a team October 10, 2023 15:37
@ElementBot
Copy link
Collaborator

ElementBot commented Oct 10, 2023

Fails
🚫

Danger failed to run ./tools/danger/dangerfile-lint.js.

Error Error

Cannot find module 'danger-plugin-lint-report'
Require stack:
- ./tools/danger/dangerfile-lint.js
- /usr/src/danger/dist/runner/runners/inline.js
- /usr/src/danger/dist/commands/danger-runner.js
Error: Cannot find module 'danger-plugin-lint-report'
Require stack:
- ./tools/danger/dangerfile-lint.js
- /usr/src/danger/dist/runner/runners/inline.js
- /usr/src/danger/dist/commands/danger-runner.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:931:15)
    at Function.Module._load (internal/modules/cjs/loader.js:774:27)
    at Function._module2.default._load (/usr/src/danger/node_modules/override-require/dist/overrideRequire.js:43:25)
    at Module.require (internal/modules/cjs/loader.js:1003:19)
    at require (internal/modules/cjs/helpers.js:107:18)
    at Object.<anonymous> (./tools/danger/dangerfile-lint.js:9:18)
    at Module._compile (internal/modules/cjs/loader.js:1114:14)
    at requireFromString (/usr/src/danger/node_modules/require-from-string/index.js:28:4)
    at /usr/src/danger/dist/runner/runners/inline.js:161:68
    at step (/usr/src/danger/dist/runner/runners/inline.js:52:23)

Dangerfile

------------------^

Generated by 🚫 dangerJS against 7c5a41f

@github-actions
Copy link
Contributor

📱 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/k9z6CV

@sonarqubecloud
Copy link

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

@codecov
Copy link

codecov bot commented Oct 10, 2023

Codecov Report

Attention: 118 lines in your changes are missing coverage. Please review.

Comparison is base (6e9d198) 58.96% compared to head (7c5a41f) 59.03%.
Report is 8 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1526      +/-   ##
===========================================
+ Coverage    58.96%   59.03%   +0.06%     
===========================================
  Files         1137     1152      +15     
  Lines        30324    30360      +36     
  Branches      6223     6220       -3     
===========================================
+ Hits         17882    17923      +41     
+ Misses        9764     9759       -5     
  Partials      2678     2678              
Files Coverage Δ
...c/main/kotlin/io/element/android/x/MainActivity.kt 0.00% <ø> (ø)
...c/main/kotlin/io/element/android/x/di/AppModule.kt 0.00% <ø> (ø)
...o/element/android/appnav/LoggedInEventProcessor.kt 0.00% <ø> (ø)
...eatures/createroom/impl/addpeople/AddPeopleView.kt 45.23% <ø> (ø)
...createroom/impl/configureroom/ConfigureRoomView.kt 56.39% <ø> (ø)
...eatures/createroom/impl/root/CreateRoomRootView.kt 58.69% <ø> (ø)
...ndroid/features/invitelist/impl/InviteListState.kt 100.00% <100.00%> (+12.50%) ⬆️
...android/features/invitelist/impl/InviteListView.kt 60.25% <ø> (ø)
...res/invitelist/impl/components/InviteSummaryRow.kt 86.02% <ø> (ø)
...t/android/features/leaveroom/api/LeaveRoomState.kt 100.00% <100.00%> (+7.69%) ⬆️
... and 104 more

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

@bmarty bmarty requested review from a team and julioromano and removed request for jmartinesp and a team October 11, 2023 08:51
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.

Just some comments

}

@Test
fun `Top level function with '@Composable' annotation starting with a upper case should be placed in a file with the same name`() {

Choose a reason for hiding this comment

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

Isn't detekt already checking this (or maybe it checks something similar?)?

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, Detekt is checking class name / filename, but not Composable function name / filename

}

@Test
fun `Data class state MUST not have default value`() {

Choose a reason for hiding this comment

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

Should we at least allow a default {} for the event sink?

Copy link
Member Author

Choose a reason for hiding this comment

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

This idea is to help the developer remember (by not compiling the code otherwise) that all the fields in the state should be provided when created by the presenter. So I think it's safer to enforce this for all the params.

}

@Test
fun `no field should have 'm' prefix`() {

Choose a reason for hiding this comment

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

:D

@@ -71,7 +71,7 @@ fun BlurHashAsyncImage(
}

@Composable
fun BlurHashImage(
private fun BlurHashImage(

Choose a reason for hiding this comment

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

Are these visibility changes enforced by konsist too?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, else the file should be renamed to BlurHashImage.kt, which mean that actually this function should be moved to its own file).

The inner rule (of mine) is: one public composable per file.

@bmarty
Copy link
Member Author

bmarty commented Oct 11, 2023

Thanks for the the review @julioromano
CI failure does not seem to be related to the content of this PR, let's merge it 🤞

@bmarty bmarty merged commit 6a28814 into develop Oct 11, 2023
@bmarty bmarty deleted the feature/bma/konsist branch October 11, 2023 14:40
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