-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
feat(mobile): enabled DCM #17957
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
feat(mobile): enabled DCM #17957
Conversation
mobile/analysis_options.yaml
Outdated
@@ -23,7 +23,7 @@ linter: | |||
# producing the lint. | |||
|
|||
rules: | |||
# avoid_print: false # Uncomment to disable the `avoid_print` rule | |||
avoid_print: false |
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.
It is always better to use debug logs in place of print statements so having this rule in place is actually encouraged. Is there a reason on why we need to disable this?
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.
My bad, I misread and thought it was disabled before.
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.
@atollk Thanks a lot for the PR. Can you fix the failing checks?
are there any I should remove entirely for now?
What I had in mind was that we remove everything from dcm and start with few set of rules initially, fix its violations across the code base and incrementally go from there. The below is the stat on the number of violations on main
warning issues: 1485, style issues: 2449
For some that I tried to fix the violations for, I wasn't sure if that would actually be an improvement.
Can you list such rules that you feel like are not useful. We can then evaluate and remove them
mobile/analysis_options.yaml
Outdated
@@ -23,7 +23,7 @@ linter: | |||
# producing the lint. | |||
|
|||
rules: | |||
# avoid_print: false # Uncomment to disable the `avoid_print` rule | |||
avoid_print: false | |||
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule |
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.
We could enable the prefer_single_quotes
rule in the future as well because the server uses single quotes for string and using this here would make things consistent across the codebase
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.
done
@@ -96,6 +103,11 @@ jobs: | |||
run: dart run custom_lint | |||
working-directory: ./mobile | |||
|
|||
- name: Run DCM | |||
run: dcm analyze --ci-key="${{ secrets.DCM_CI_KEY }}" lib |
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.
Can you confirm if this works without the ci-key
, because AFAIK, the open-source license do not provide us with an admin console but things should work normally without any key as long as dcm is running within the open source project to which it was allowed
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.
Yep, it works.
@atollk Can you fix the failing CI and we can get this merged? I don't think we need the |
@shenlong-tanwen We're still kind of stuck on the DCM issue, aren't we? Regarding ci-key and email: This is recommend by the DCM docs (https://dcm.dev/docs/ci-integrations/github-actions/#inputs-1) |
Sadly, yes. We can move this to a draft and wait for input from @incendial here or on the discord server before we can move forward with the PR. I tested it with a fork of my own and can confirm the issue. The blog says that it should work for forks as well, so probably something broke with the recent changes in DCM |
After testing some more, here's a proposal: |
@shenlong-tanwen looks good to go now imo |
Let me take a look, it should work for forks out of the box. |
After some investigation I remember now that, yeah, adding a remote might be a necessary step as we can't fully rely on the fork info as the fork can be just renamed. We can theoretically support non-renamed forks, but I'm not sure it's worth it. So if having an additional setup step works for you, then this is probably the best way right now. Plus, I always though that this is still required for syncing the fork https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/configuring-a-remote-repository-for-a-fork |
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.
Let's ignore the prefer_single_quotes
rule for now. The other changes look good to me. Thanks a lot for working on this.
@atollk Can you please rebase this on main and we can get this merged? Feel free to let me know if you'd like me to do it instead |
@shenlong-tanwen Sure, I can rebase it. But does that mean, it's good to be merged now? By the nature of this change, it needs to be merged pretty much immediately after a rebase, before any other changes to the mobile directory. |
Description
Enables DCM (dart code metrics) for more extensive static analysis.
Most lints were already satisfied. A few others I have fixed and the rest I have disabled for now.
@shenlong-tanwen Since you mentioned that the current list of lints is still being evaluated, are there any I should remove entirely for now? For some that I tried to fix the violations for, I wasn't sure if that would actually be an improvement.
How Has This Been Tested?
dcm analyze lib
)Checklist:
src/services/
uses repositories implementations for database calls, filesystem operations, etc.src/repositories/
is pretty basic/simple and does not have any immich specific logic (that belongs insrc/services/
)