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

Prevent plugin runs to use the moodle.Commenting.TodoComment sniff #267

Merged
merged 1 commit into from
Jan 19, 2024

Conversation

stronk7
Copy link
Member

@stronk7 stronk7 commented Jan 17, 2024

A new todo-comment-regex option has been added to the phpcs command.

It allows to specify the regex that will be used with inspecting
todo (TODO and @todo) comments.

By default, an empty string is used for the option and that makes
the Sniff to stop checking. Whoever wants to check for anything
(tracker issue, github issue, arbitrary url, ...) can us the new
option to configure it.

Fixes #266

Copy link

codecov bot commented Jan 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (8f23cf5) 85.17% compared to head (2b00727) 85.19%.

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #267      +/-   ##
============================================
+ Coverage     85.17%   85.19%   +0.02%     
  Complexity      718      718              
============================================
  Files            75       75              
  Lines          2232     2236       +4     
============================================
+ Hits           1901     1905       +4     
  Misses          331      331              

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

@stronk7
Copy link
Member Author

stronk7 commented Jan 18, 2024

Ok, we have agreed to add a new option (ttodo-comment-regex) to the phpcs command.

  1. It will default to '' (or null), so the Sniff won't do anything.
  2. People wanting to enable it just will have to set the option with a valid regexp and then the Sniff will run and report.

So this PR is not valid right now... working on it soon... ciao :-)

@stronk7 stronk7 force-pushed the prevent_todo_sniff_for_plugins branch from 50e7728 to a66c02d Compare January 18, 2024 18:46
@stronk7
Copy link
Member Author

stronk7 commented Jan 18, 2024

Commit amended, now the new todo-comment-regextakes the baton to decide how to proceed:

  • By default it uses empty string value that, at all effects, disables the todo Sniff completely.
  • By setting it to anything else, the todo Sniff will check that all the todo comments (TODO and @todo), match the regex.

Ciao :-)

kabalin
kabalin previously approved these changes Jan 18, 2024
Copy link
Member

@kabalin kabalin left a comment

Choose a reason for hiding this comment

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

Thanks Eloy, LGTM.

@kabalin
Copy link
Member

kabalin commented Jan 18, 2024

Changelog record is required (feel free to add later).

@stronk7
Copy link
Member Author

stronk7 commented Jan 18, 2024

Thanks @kabalin,

I'll add the CHANGELOG details, yep (tomorrow).

Also I've converted this to draft because we need the new moodle-cs release to happen in order to get the new unit tests that I've added passing (they require a working moodle-cs with the new config option).

Once we bump to new moodle-cs, I'll complete this.

Ciao :-)

@stronk7 stronk7 force-pushed the prevent_todo_sniff_for_plugins branch from a347beb to 7ab76ff Compare January 19, 2024 08:23
@stronk7
Copy link
Member Author

stronk7 commented Jan 19, 2024

CHANGELOG updated with text:

Added

  • Added support for the --todo-comment-regex option to the phpcs command. When specified, all the todo comments (TODO and @todo) are inspected to ensure that they contain some text matching the regular expression (a tracker issue key: MDL-[0-9]+, a link to GitHub: github.com/moodle/moodle/pull/[0-9]+, ... or any other valid alternative).

Still holding on moodlehq/moodle-cs#91 and moodle-cs release, to progress this. Not in a hurry.

A new `todo-comment-regex` option has been added to the phpcs command.

It allows to specify the regex that will be used with inspecting
todo (TODO and @todo) comments.

By default, an empty string is used for the option and that makes
the Sniff to stop checking. Whoever wants to check for anything
(tracker issue, github issue, arbitrary url, ...) can us the new
option to configure it.

Fixes moodlehq#266
@stronk7 stronk7 force-pushed the prevent_todo_sniff_for_plugins branch from 7ab76ff to 2b00727 Compare January 19, 2024 17:49
@stronk7 stronk7 marked this pull request as ready for review January 19, 2024 17:57
@stronk7
Copy link
Member Author

stronk7 commented Jan 19, 2024

About to go merging this (once tests end), as far as it was approved with all the changes but the CHANGELOG ones that came later.

Immediately after getting this landed, will make a release, so it can be tested out there (default and custom regular expressions).

Ciao :-)

@stronk7 stronk7 merged commit 5cf4b64 into moodlehq:main Jan 19, 2024
17 checks passed
@stronk7 stronk7 deleted the prevent_todo_sniff_for_plugins branch January 19, 2024 18:42
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.

Ensure that we only use the TodoComment Sniff for core runs, not for plugin ones
2 participants