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

Fix #4689: Add regex check to prohibit post() and postDelayed() #4900

Merged

Conversation

kkmurerwa
Copy link
Collaborator

@kkmurerwa kkmurerwa commented Mar 14, 2023

Explanation

Fix #4689: When merged, this PR will;

  • Add regex check to prohibit the usage of post() and postDelayed()
  • Add tests for the regex check added.
  • Add file exemptions for files that don't meet the new rules.

The commits pushed on 4th April 2023 will;

  • Remove tests from exemptions list of the regex check.
  • Add RegexPatternValidationCheckTest.kt to exemptions since it is matched correctly against the regex. This is an undesired side effect or removing tests from exemptions.
  • Modify the language of the error message to align with Oppia guidelines.
  • Remove the SpotlightFragment.kt from exemptions since it contains no instance of post() or postDelayed()
  • Update the regex to take care of cases with curly braces such as post {} instead of only matching post() and postDelayed().
  • Cater for any spaces between the post/postDelayed and the bracket used i.e. post (), postDelayed () and post {}.
  • Add another test to verify check for usages of post with curly braces.
  • Add an extra test in the test methods to ensure that the correct error message is being shown.

Essential Checklist

  • The PR title and explanation each start with "Fix #bugnum: " (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".)
  • Any changes to scripts/assets files have their rationale included in the PR explanation.
  • The PR follows the style guide.
  • The PR does not contain any unnecessary code changes from Android Studio (reference).
  • The PR is made from a branch that's not called "develop" and is up-to-date with "develop".
  • The PR is assigned to the appropriate reviewers (reference).

For UI-specific PRs only

If your PR includes UI-related changes, then:

  • Add screenshots for portrait/landscape for both a tablet & phone of the before & after UI changes
  • For the screenshots above, include both English and pseudo-localized (RTL) screenshots (see RTL guide)
  • Add a video showing the full UX flow with a screen reader enabled (see accessibility guide)
  • Add a screenshot demonstrating that you ran affected Espresso tests locally & that they're passing

- Add regex check to prohibit the usage of post() and postDelayed()
- Add tests for the regex check added
@oppiabot
Copy link

oppiabot bot commented Mar 21, 2023

Hi @kkmurerwa, I'm going to mark this PR as stale because it hasn't had any updates for 7 days. If no further activity occurs within 7 days, it will be automatically closed so that others can take up the issue.
If you are still working on this PR, please make a follow-up commit within 3 days (and submit it for review, if applicable). Please also let us know if you are stuck so we can help you!

@oppiabot oppiabot bot added the stale Corresponds to items that haven't seen a recent update and may be automatically closed. label Mar 21, 2023
@oppiabot oppiabot bot removed the stale Corresponds to items that haven't seen a recent update and may be automatically closed. label Mar 22, 2023
@kkmurerwa
Copy link
Collaborator Author

Hey @BenHenning. I did some housekeeping here and merged the latest changes from develop. All checks were passing before the merge and should even after the merge. The failing checks just need a rerun.

@BenHenning BenHenning self-assigned this Mar 24, 2023
Copy link
Sponsor Member

@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

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

Thanks @kkmurerwa! Had some follow-up thoughts, PTAL.

@BenHenning BenHenning assigned kkmurerwa and unassigned BenHenning Mar 29, 2023
@kkmurerwa kkmurerwa removed their assignment Apr 3, 2023
@kkmurerwa
Copy link
Collaborator Author

PTAL @kkmurerwa

@kkmurerwa
Copy link
Collaborator Author

Hey @BenHenning. I updated this PR with some new changes. They are detailed in a second section of the PR comment labeled Latest commit will. I have also addressed all issues mentioned and I hope it is now good to go.

@kkmurerwa
Copy link
Collaborator Author

PTAL @BenHenning

- Refactor the prohibited regex to cover false positives in some files
- Remove the wrongly exempted SpotlightFragment.kt file
@kkmurerwa
Copy link
Collaborator Author

Hey @BenHenning. A few checks failed after the last commit but it shouldn't be a problem. A quick rerun should fix it.

@MohitGupta121
Copy link
Member

@kkmurerwa Done, I re-run the CI checks. Thanks.

@kkmurerwa
Copy link
Collaborator Author

Thanks @MohitGupta121

Copy link
Sponsor Member

@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

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

Thanks @kkmurerwa. Took another pass--please make sure to respond to all comments before sending PRs back into review.

@BenHenning BenHenning assigned kkmurerwa and unassigned BenHenning Apr 6, 2023
- Rearrange the exempted files n lexicographical order.
- Rename the doesNotUsePostorPostDelayed to doesNotUsePostOrPostDelayed
- Modify the failure message to fix grammatical errors
@kkmurerwa
Copy link
Collaborator Author

@BenHenning I have responded to all unresolved comments and fixed the issues highlighted. I believe it is ready for another review.

@kkmurerwa
Copy link
Collaborator Author

PTAL @BenHenning

@oppiabot oppiabot bot assigned BenHenning and unassigned kkmurerwa Apr 6, 2023
@oppiabot
Copy link

oppiabot bot commented Apr 6, 2023

Unassigning @kkmurerwa since a re-review was requested. @kkmurerwa, please make sure you have addressed all review comments. Thanks!

Copy link
Sponsor Member

@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

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

Thanks @kkmurerwa! This LGTM!

@BenHenning BenHenning merged commit 0baeeb1 into oppia:develop Apr 11, 2023
25 checks passed
@kkmurerwa kkmurerwa deleted the regex-to-prohibit-post-and-post-delayed branch May 10, 2023 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Prohibit post/postDelayed via a new regex check
3 participants