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

New sniff to detect correct setUp/tearDown parent calls #165

Merged
merged 2 commits into from
May 31, 2024

Conversation

stronk7
Copy link
Member

@stronk7 stronk7 commented May 28, 2024

It detects various situations like:

  • Missing calls to parent.
  • Dupe calls.
  • Incorrect calls.

And, when possible, tries to fix the missing ones (not others) by adding them in a correct place:

  • For setUp cases, at the beginning of the method (after global and require statements, if any).
  • For tearDown cases, at the end of the method.

Only for 405 and above.

Of course, covered with tests.

Fixes #106

Note that this is built on top of #162.

@stronk7
Copy link
Member Author

stronk7 commented May 28, 2024

These are the results when executing it against core (4.5dev). 492 cases detected and fixed.

stronk7/moodle@c22f9e0

Ciao :-)

Copy link

codecov bot commented May 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.99%. Comparing base (4431d70) to head (7d14837).

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #165      +/-   ##
============================================
+ Coverage     97.93%   97.99%   +0.06%     
- Complexity      860      886      +26     
============================================
  Files            38       39       +1     
  Lines          2564     2647      +83     
============================================
+ Hits           2511     2594      +83     
  Misses           53       53              

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

@stronk7 stronk7 force-pushed the setup_teardown_parent branch 5 times, most recently from 87cd2e6 to a1d52e9 Compare May 28, 2024 15:54
It detects various situations like:
  - Missing calls to parent.
  - Dupe calls.
  - Incorrect calls.

And, when possible, tries to fix the missing ones (not others)
by adding them in a correct place:
  - For setUp cases, at the beginning of the method.
  - For tearDown cases, at the end of the method.

Of course, covered with tests.

Fixes moodlehq#106
stronk7 referenced this pull request in andrewnicols/moodle-cs May 31, 2024
@stronk7
Copy link
Member Author

stronk7 commented May 31, 2024

Thanks @andrewnicols , I've cherry-picked your commit here, and applied a few small (comments, problem cases) modifications to it, to better understand what's going with those empty methods.

I think this now is perfect! 😎

@stronk7 stronk7 requested a review from andrewnicols May 31, 2024 08:12
@andrewnicols andrewnicols merged commit bc14e30 into moodlehq:main May 31, 2024
13 checks passed
@stronk7 stronk7 deleted the setup_teardown_parent branch May 31, 2024 16:13
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.

Detect that setUpBeforeClass, setUp, tearDown, and tearDownAfterClass are always calling to parent
2 participants