Skip to content
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(analyze): Add DCM and fix potentiall bugs, depreciations #315

Merged
merged 11 commits into from
Sep 6, 2024

Conversation

mhadaily
Copy link
Contributor

Description

This pull request introduces several changes, primarily focusing on integrating Dart Code Metrics (DCM) into the CI workflow, updating the contributing guidelines, and making various code improvements and refactorings. The most important changes are summarized below:

CI/CD Workflow Enhancements:

  • Added a step to install DCM in the GitHub Actions workflow (.github/workflows/checks.yml).
  • Updated the analysis step to use DCM for both Flutter and Dart in the GitHub Actions workflow (.github/workflows/checks.yml).

Documentation Updates:

  • Updated CONTRIBUTING.md to include steps for installing and activating DCM, and clarified the use of DCM in the contribution process.

Code Quality and Linting:

  • Added Dart Code Metrics configuration to analysis_options.yaml and other related files to enforce specific linting rules. [1] [2] [3]

Code Refactoring:

  • Refactored multiple files to improve code readability and maintainability, including changes to widget properties and method calls. [1] [2] [3] [4] [5] [6] [7]

Minor Code Improvements:

  • Made minor adjustments to formatting and method calls to enhance code consistency and readability. [1] [2] [3] [4]

These changes collectively improve the project's CI/CD pipeline, documentation, code quality, and overall maintainability.

Related Issues

Replace this paragraph with a list of issues related to this PR from the issue database. Indicate, which of these issues are resolved or fixed by this PR.

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]).
This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes tests for all changed/updated/fixed behaviors.
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (melos run analyze) does not report any problems on my PR.
  • The package compiles with the minimum Flutter version stated in the pubspec.yaml

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change.
  • No, this is not a breaking change.

…o easy dcm fixes, ensure you are enabling ignored rules and fix them one by one at some point later
@ulusoyca
Copy link
Collaborator

@mhadaily Can we have an example here to demonstrate how to create an internal static analysis package that includes all the rules and is also added as dependency to the demo apps and also to the package lib? I see that currently every demo app has its own analysis option. We can add baseline to silence warnings in the demo apps if they are too big changes.

Copy link
Collaborator

@ulusoyca ulusoyca left a comment

Choose a reason for hiding this comment

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

We can accept all the suggsted changes in the demo app. My comments are focusing only the package lib. I left minor comments. Huge thanks 🚀

lib/src/wolt_modal_sheet.dart Outdated Show resolved Hide resolved
@ulusoyca
Copy link
Collaborator

@mhadaily Looks like the workflow is expecting an approval to run. Is this intentional? If yes, it does not sound useful since we expect the static analysis feedback from CI to work even in draft PRs.

image

@incendial
Copy link

@mhadaily Looks like the workflow is expecting an approval to run. Is this intentional? If yes, it does not sound useful since we expect the static analysis feedback from CI to work even in draft PRs.

Hmm, if that's related to this PR, then that's probably because of how GitHub actions work. Either DCM needs to be installed without the action or another trigger should be used (example: https://github.com/leoafarias/fvm/blob/main/.github/workflows/test.yml#L45).

I'd say the first approach is safer.

@mhadaily
Copy link
Contributor Author

@mhadaily Looks like the workflow is expecting an approval to run. Is this intentional? If yes, it does not sound useful since we expect the static analysis feedback from CI to work even in draft PRs.

image

@ulusoyca according to this https://docs.github.com/en/actions/managing-workflow-runs-and-deployments/managing-workflow-runs/approving-workflow-runs-from-public-forks
It seems since I am first time contributor and I am touching some pull_request_target, you need to approve this change and run.

it looks like this is only for first time contributor and will not happen later. Let's give it a try.

@mhadaily
Copy link
Contributor Author

We can accept all the suggsted changes in the demo app. My comments are focusing only the package lib. I left minor comments. Huge thanks 🚀

Awesome, first two comments.

@mhadaily mhadaily requested a review from ulusoyca August 31, 2024 08:14
@ulusoyca
Copy link
Collaborator

@mhadaily WidgetStatePropertyAll fill fail because the min Flutter SDK version is 3.13.0+

@mhadaily
Copy link
Contributor Author

@mhadaily WidgetStatePropertyAll fill fail because the min Flutter SDK version is 3.13.0+

AH that's right, I didn't check that. Should I change min SDK or you prefer I revert the change for "WidgetStatePropertyAll" ?

@ulusoyca
Copy link
Collaborator

ulusoyca commented Aug 31, 2024

@mhadaily WidgetStatePropertyAll fill fail because the min Flutter SDK version is 3.13.0+

AH that's right, I didn't check that. Should I change min SDK or you prefer I revert the change for "WidgetStatePropertyAll" ?

Actually it is a good idea to change the min SDK in the example apps, without changing the package min SDK constraint.

@mhadaily
Copy link
Contributor Author

Done @ulusoyca

Copy link
Collaborator

@ulusoyca ulusoyca left a comment

Choose a reason for hiding this comment

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

🚢

@mhadaily
Copy link
Contributor Author

btw, @ulusoyca when you got chance, try to enable the "disabled rule" and fix the issue, I find several potential bugs and also memory leaks problems.

also if you run dcm check-unused-files and dcm check-unused-files you will see you also have dead code and files.

generally a good idea to play around with some of the commands

@ulusoyca
Copy link
Collaborator

ulusoyca commented Aug 31, 2024

@mhadaily Thanks for the setup, I will delete / simplify some demo projects, and add / enable more rules

@mhadaily
Copy link
Contributor Author

@ulusoyca It seems the main library actually had 3.13 but the examples were not. so I changed everything, Not sure why it needs approval again. it was working without approval but suddenly last commit needs it again.

@ulusoyca
Copy link
Collaborator

🚢

@mhadaily
Copy link
Contributor Author

It's still failing, I am not sure why? do you have any idea?
I checked it on my machine and it seems it's all good
Screenshot 2024-08-31 at 20 47 11

@ulusoyca
Copy link
Collaborator

It's still failing, I am not sure why? do you have any idea? I checked it on my machine and it seems it's all good Screenshot 2024-08-31 at 20 47 11

Your Local is probably the latest flutter but the action is run on 3.13.0. I think the examples should use MaterialState instead of WidgetState

@mhadaily
Copy link
Contributor Author

Well, that is correct, I thought WidgetState is available after 3.13, anyway I have revert it to MaterialState. Maybe approve again and let's see how it works.

if it passes then we are good. I can probably deal with depreciation when you are ready.

@mhadaily
Copy link
Contributor Author

@ulusoyca sorry again 😄

one more time approval. I think this is the final time. Though tests are failing and I think you know that already

@ulusoyca
Copy link
Collaborator

@mhadaily we are good now!

@ulusoyca
Copy link
Collaborator

ulusoyca commented Sep 6, 2024

@mhadaily can we merge now?

@mhadaily
Copy link
Contributor Author

mhadaily commented Sep 6, 2024 via email

@ulusoyca ulusoyca merged commit 3b9355c into woltapp:main Sep 6, 2024
3 of 4 checks passed
@mhadaily mhadaily deleted the dcm-checks branch September 7, 2024 12:04
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