[go: nahoru, domu]

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

Detekt - Resolve/Suppress All Baseline Warnings - Long methods warnings #17198

Conversation

Hoossayn
Copy link
Contributor
@Hoossayn Hoossayn commented Sep 22, 2022

Parent: #17010

This PR resolved/suppress all complexity related LongMethod warnings for the WordPress module (see docs here):

15 x LongMethod (Resolve: https://github.com/wordpress-mobile/WordPress-Android/pull/17198/commits)

To test:

  • There is nothing much to test here.

  • Verifying that all the CI checks are successful should be enough (especially the detekt check).

  • However, if you really want to be thorough, you could smoke test the WordPress and/or Jetpack apps to verify that everything works as expected on every screen that relates to these changes.

Regression Notes

  1. Potential unintended areas of impact

  2. What I did to test those areas of impact (or what existing automated tests I relied on)
    See To test section above.

  3. What automated tests I added (or what prevented me from doing so)
    N/A

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@Hoossayn Hoossayn marked this pull request as ready for review September 23, 2022 08:43
@ParaskP7 ParaskP7 self-assigned this Sep 26, 2022
@ParaskP7 ParaskP7 self-requested a review September 26, 2022 09:10
@ParaskP7 ParaskP7 added this to the Future milestone Sep 26, 2022
@ParaskP7
Copy link
Contributor

👋 @Hoossayn !

Thank you so much for contributing yet another PR to this repo, this is awesome! 🙇

In addition to the code changes, how would you like us to start working on improving on the PR description itself? This is very important to us as it helps with the organization aspects of working on an issue. Also, doing so is very helpful to reviewers as it informs them on every aspect of the PR, without having them be thinking about any missing aspect themselves, thus increasing their level on confidence on your code changes and the testing to verify that everything is still working as expected.

In addition to the above, you could also start creating new issues, based on the parent issue and start informing us on the tasks you are going to be working next. This way we will be aware what to expect, possibly even help and guide you, even before a future PR is created. Wdyt?

PS: For inspiration, you could also take a look at this FluxC relevant parent issue, its sub-issues (for example this), the corresponding PR based on these sub-issues (for example this), and based on the later, you could try and follow a similar PR description approach.

FYI: To help you out a bit, below is how I would described this PR:


Parent: #17010
Closes: <# OF AN ISSUE ASSOCIATED WITH THIS PR>

This PR resolved/suppress all complexity related LongMethod warnings for the WordPress module (see docs here):

  1. 15 x LongMethod (Resolve: <COMMIT HASH LINK(S)> + Suppress: <COMMIT HASH LINK(S)>)

To test:

  • There is nothing much to test here.
  • Verifying that all the CI checks are successful should be enough (especially the detekt check).
  • However, if you really want to be thorough, you could smoke test the WordPress and/or Jetpack apps to verify that everything works as expected on every screen that relates to these changes. For example:
    • <SCREEN 1>
    • <SCREEN 2>
    • <SCREEN 3>

Regression Notes

  1. Potential unintended areas of impact

<SOME 123> functionality is not workings as expected.

  1. What I did to test those areas of impact (or what existing automated tests I relied on)

See To test section above.

  1. What automated tests I added (or what prevented me from doing so)

N/A

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

Copy link
Contributor
@ParaskP7 ParaskP7 left a comment

Choose a reason for hiding this comment

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

👋 @Hoossayn !

Thank you so much for this PR. Your contributions are always welcome! 🎉

I did an initial quick review of this PR, along with triggering CI on it via a draft PR that I just pushed on the main repo.

I'll do a more thorough review on the code changes after you follow-up on the bellow initial comments from my side:

  1. Blocker (🚫): Please take a look as the CI checks that are failing on a couple of occasions and try to fix those issues:
    • The Dependency Tree Diff check is failing due the conflicts that exist in this PR. Please take a look at that and resolve the conflicts first.
    • The detekt check is failing due to the 6 new LongParameterList issues that start appearing as part of your refactoring attempt to solve the LongMethod issues. Please take a look at that and resolve these newly created Detekt issues. You can run ./gradlew detekt locally on your side before pushing your changes to verify that Detekt runs successfully and there is no build failures associated with this task.
  2. Suggestion (💡): For all these 15 files you touched, you did that on a single commit basis. I could recommend to you, for this (or next time), to spit such changes into at least 15 commits, each commit to deal with a specific refactor. This way it would be easier for the reviewer to review each change in isolation. On some occasions, I would personally go as far as splitting on of these potential 15 separate commits even further, into more commits. For example, for the MediaPickerActivity.kt file change, I would have first extracted the takeAPhoto() function, then committed this change, then, I would have extracted the editImageIntent(...) function, then committed another change. Thus for that specific file, I would have ended up with 2 commits instead of 1 (out of the 15). One would do this in order to make it easier for the reviewer to do the code review diffing afterwards, in order for them to verify that everything was done appropriately, most probably, in an automated way, so that to avoid any hidden surprises. Wdyt? 🤔

<ID>LongMethod:StatsWidgetConfigureFragment.kt$StatsWidgetConfigureFragment$override fun onViewCreated(view: View, savedInstanceState: Bundle?)</ID>
<ID>LongMethod:SuggestionActivity.kt$SuggestionActivity$private fun initializeActivity(siteModel: SiteModel, suggestionType: SuggestionType)</ID>
<ID>LoopWithTooManyJumpStatements:RemoveMediaUseCase.kt$RemoveMediaUseCase$for (mediaId in mediaIds) { if (!TextUtils.isEmpty(mediaId)) { // make sure the MediaModel exists val mediaModel = try { mediaStore.getMediaWithLocalId(Integer.valueOf(mediaId)) ?: continue } catch (e: NumberFormatException) { AppLog.e(AppLog.T.MEDIA, "Invalid media id: $mediaId") continue } // also make sure it's not being uploaded anywhere else (maybe on some other Post, // simultaneously) if (mediaModel.uploadState != null &amp;&amp; mediaUtils.isLocalFile(mediaModel.uploadState.toLowerCase(Locale.ROOT)) &amp;&amp; !uploadService.isPendingOrInProgressMediaUpload(mediaModel)) { dispatcher.dispatch(MediaActionBuilder.newRemoveMediaAction(mediaModel)) } } }</ID>
<ID>LoopWithTooManyJumpStatements:RemoveMediaUseCase.kt$RemoveMediaUseCase$for (mediaId in mediaIds) { if (!TextUtils.isEmpty(mediaId)) { // make sure the MediaModel exists val mediaModel = try { mediaStore.getMediaWithLocalId(Integer.valueOf(mediaId)) ?: continue } catch (e: NumberFormatException) { AppLog.e(AppLog.T.MEDIA, "Invalid media id: $mediaId") continue } // also make sure it's not being uploaded anywhere else (maybe on some other Post, // simultaneously) if (mediaModel.uploadState != null &amp;&amp; mediaUtils.isLocalFile(mediaModel.uploadState.toLowerCase(Locale.ROOT)) &amp;&amp; !uploadService.isPendingOrInProgressMediaUpload(mediaModel)) { dispatcher.dispatch(MediaActionBuilder.newRemoveMediaAction(mediaModel)) } } }</ID>
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor (🔍): Consider adding an extra space to this LoopWithTooManyJumpStatements:RemoveMediaUseCase related line as this file is not incorrectly formatted due to this change.

@Hoossayn
Copy link
Contributor Author

👋 @Hoossayn !

Thank you so much for contributing yet another PR to this repo, this is awesome! 🙇

In addition to the code changes, how would you like us to start working on improving on the PR description itself? This is very important to us as it helps with the organization aspects of working on an issue. Also, doing so is very helpful to reviewers as it informs them on every aspect of the PR, without having them be thinking about any missing aspect themselves, thus increasing their level on confidence on your code changes and the testing to verify that everything is still working as expected.

In addition to the above, you could also start creating new issues, based on the parent issue and start informing us on the tasks you are going to be working next. This way we will be aware what to expect, possibly even help and guide you, even before a future PR is created. Wdyt?

PS: For inspiration, you could also take a look at this FluxC relevant parent issue, its sub-issues (for example this), the corresponding PR based on these sub-issues (for example this), and based on the later, you could try and follow a similar PR description approach.

FYI: To help you out a bit, below is how I would described this PR:

Parent: #17010 Closes: <# OF AN ISSUE ASSOCIATED WITH THIS PR>

This PR resolved/suppress all complexity related LongMethod warnings for the WordPress module (see docs here):

  1. 15 x LongMethod (Resolve: <COMMIT HASH LINK(S)> + Suppress: <COMMIT HASH LINK(S)>)

To test:

  • There is nothing much to test here.

  • Verifying that all the CI checks are successful should be enough (especially the detekt check).

  • However, if you really want to be thorough, you could smoke test the WordPress and/or Jetpack apps to verify that everything works as expected on every screen that relates to these changes. For example:

    • <SCREEN 1>
    • <SCREEN 2>
    • <SCREEN 3>

Regression Notes

  1. Potential unintended areas of impact

<SOME 123> functionality is not workings as expected.

  1. What I did to test those areas of impact (or what existing automated tests I relied on)

See To test section above.

  1. What automated tests I added (or what prevented me from doing so)

N/A

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

👋🏾 @ParaskP7 thank you for your input, appreciate it greatly, i have done some changes to follow suite to your suggestion, kindly let me know if there's any further changes that's required

@ParaskP7
Copy link
Contributor

👋 @Hoossayn !

Thank you for the changes and for following the suggestions, much appreciated. 🙇

PS: I am a bit busy amt, but I'll be sure to get to review this changes first thing next week.

@ParaskP7 ParaskP7 self-requested a review October 3, 2022 15:21
@ParaskP7
Copy link
Contributor
ParaskP7 commented Oct 3, 2022

👋 @Hoossayn !

I have started reviewing your PR today. 🔍

Closes: #15

On your PR description, you are point that this #15 PR, why is that? 🤔

FYI: Usually, a Closed: #123 line in a PR description associates the PR with an issue that this PR, upon merge, is automatically closing as done.

In addition to the above, you could also start creating new issues, based on the #17010 and start informing us on the tasks you are going to be working next. This way we will be aware what to expect, possibly even help and guide you, even before a future PR is created. Wdyt?

As per this comment on mine, let's start creating issues that are going to then be then associated with the PRs you are going to be creating so that we can track the parent #17010 better and also make sure that the Closes: #123 line always refer to that issue that this PR is trying to tackle.

Copy link
Contributor
@ParaskP7 ParaskP7 left a comment

Choose a reason for hiding this comment

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

👋 @Hoossayn !

I did a quick review of the new commits you pushed, once more, thank you for helping! 🥇

As I have lots of code review comments based on the code changes I am seeing so far, and because I would hate to overwhelm you with them, I would recommend for us to take a small step back, close this PR and do the following instead:

  • Open another PR, which will only try to fix the LongMethod warnings for these 3 org.wordpress.android.ui.mediapicker related classes:
    • MediaPickerActivity
    • MediaPickerFragment
    • MediaPickerViewModel
  • While doing the above, try to commit your changes as soon as possible, at the basis, I would expect 3 commits, one per class above. Even further, I would like you to do the following, commit per refactor. For example, for the MediaPickerFragment class I suggest you do the following refactors into separate commits:
    • setUpRecyclerView(...)
    • navigateEvent(...)
    • editMedia(...)
    • previewMedia(...)
    • previewUrl(...)
  • While working on each refactor commit above, please make sure you are not creating any new warnings, and if possible resolving all existing. For example, for the MediaPickerFragment.navigateEvent(...) refactor, you could resolve the lambda argument leftover warnings, by moving the lambda argument out of the parentheses (AS could help you with that). And then, removing navigationEvent altogether, replacing it with it, leaving this a one-liner, like this: viewModel.onNavigate.observeEvent(viewLifecycleOwner) { navigateEvent(it) }

With that, I think we will end-up moving faster, at least commit your changes to trunk quicker. Wdyt? 🤔

@Hoossayn
Copy link
Contributor Author
Hoossayn commented Oct 5, 2022

👋 @Hoossayn !

I have started reviewing your PR today. 🔍

Closes: #15

On your PR description, you are point that this #15 PR, why is that? 🤔

FYI: Usually, a Closed: #123 line in a PR description associates the PR with an issue that this PR, upon merge, is automatically closing as done.

In addition to the above, you could also start creating new issues, based on the #17010 and start informing us on the tasks you are going to be working next. This way we will be aware what to expect, possibly even help and guide you, even before a future PR is created. Wdyt?

As per this comment on mine, let's start creating issues that are going to then be then associated with the PRs you are going to be creating so that we can track the parent #17010 better and also make sure that the Closes: #123 line always refer to that issue that this PR is trying to tackle.

hey 👋🏾 @ParaskP7, Been sorry for just getting to this, been tied up with other things

On your PR description, you are point that this #15 PR, why is that? 🤔
this is a copy and paste error from my end 😬

start informing us on the tasks you are going to be working next. This way we will be aware what to expect
i'll be working on the MediaPickerFragment next

@Hoossayn
Copy link
Contributor Author
Hoossayn commented Oct 5, 2022
  • MediaPickerActivity

👋🏾 @ParaskP7
Thank you for taking your time to go through the PR,

I have created a new PR like you suggested, tackling only issues on MediaPickerActivity.

Thanks

@ParaskP7
Copy link
Contributor
ParaskP7 commented Oct 6, 2022

👋 @Hoossayn !

hey 👋🏾 @ParaskP7, Been sorry for just getting to this, been tied up with other things

Hey, please don't apologize, we are not in a rush here, not at all. At this point, it is better we do it right than hurry into it. So, pretty please feel free to complete this at your own pace and when you have some additional time on your side.

this is a copy and paste error from my end 😬

Happens to the best of us! 😅

i'll be working on the MediaPickerFragment next

The way I was thinking of you informing us on what you are going to be working next is via a detailed GitHub issue. You could use that to plan all this work.

As an example, see here. You will notice that I created this issue first, noting all the work I should be doing next and then spitting this work into sections that I could pick up to work on.

@ParaskP7
Copy link
Contributor
ParaskP7 commented Oct 6, 2022

👋 @Hoossayn !

Thank you for taking your time to go through the PR,

Thank you, for your time! 🥇

I have created a new #17278 like you suggested, tackling only issues on MediaPickerActivity.

Great, I'll take a look at that today! 🚀

In the meanwhile, I will be closing this PR in favor of this #17278 and any subsequent PRs that you are going to be working next. I hope that's okay with you.

@ParaskP7 ParaskP7 closed this Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants