-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Fixes #7010: Adds a linting check that ensures all TODO comments have a username with them #7114
Fixes #7010: Adds a linting check that ensures all TODO comments have a username with them #7114
Conversation
I'm having a hard time adding reviewers (not quite sure why) but @seanlip @apb7 @lilithxxx PTAL whenever you get a chance! Thanks so much. |
Hi @teddymarchildon, I've assigned @apb7 as a reviewer for this PR! (and sorry for the trouble!) Also, can you please check why the lint tests are failing for this PR and fix it? |
It looks like it is failing the linter because this PR adds a lint check to ensure that TODO comments are assigned to a user. I thought the scripts/pre_commit_linter.py only is run on the files changed in the commit, but it looks like it is run on the entire codebase in the travis-ci. So, for example, Should I find the owner, or the last person who edited the TODO comment, of the TODO comments currently unassigned and write them in as the assigned user? It looks like the vast majority of TODO comments already have an assigned user. |
Locally (as git push hook) it runs on the files changed in the feature-branch. But on travis we run these tests for the entire repo.
Yeah, this sounds good to me! Also, in case you'll find it hard to assign a username for any TODO item than you can assign it to the code-owner of the file. (For issues like #7010 we expect the contributor to introduce the new check as well as fix the existing issues. ) |
Hi @teddymarchildon. Due to recent changes in the "develop" branch, this PR now has a merge conflict. Please follow this link if you need help resolving the conflict, so that the PR can be merged. Thanks! |
Codecov Report
@@ Coverage Diff @@
## develop #7114 +/- ##
===========================================
- Coverage 98.06% 97.82% -0.24%
===========================================
Files 377 376 -1
Lines 63208 62757 -451
===========================================
- Hits 61987 61395 -592
- Misses 1221 1362 +141
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## develop #7114 +/- ##
=======================================
Coverage 87.5% 87.5%
=======================================
Files 945 945
Lines 83414 83414
Branches 2349 2349
=======================================
Hits 72993 72993
Misses 9976 9976
Partials 445 445
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @teddymarchildon, thanks for the PR. Left some comments, ptal.
scripts/pre_commit_linter.py
Outdated
@@ -220,6 +220,13 @@ | |||
'excluded_files': (), | |||
'excluded_dirs': ('core/tests/') | |||
}, | |||
{ | |||
'regexp': r'\/\/\sTODO[^\(]*[^\)]$', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of points here:
- I think it would be better if we put the regexp in
BAD_PATTERNS
since this needs to be checked for all files, irrespective of the type. - Let's enforce the
TODO(@username):
pattern instead ofTODO(username):
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha, will enforce the @ sign!
I actually thought about putting the regexp in BAD_PATTERNS
, but all of those patterns are checked here as just seeing if the pattern exists in the file, not with a regular expression. I would be happy to find a pattern that works for that method if you prefer! Something like TODO:
as a bad pattern
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@teddymarchildon, I see. Can we set up a BAD_PATTERNS_REGEXP
for this (since we have bad patterns regexp for different file types)? We can then use the same mechanism. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @teddymarchildon, have you looked into this? Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I must've missed that comment, working on it now!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@apb7 Updated! Much cleaner - thanks for the heads up.
Github was having issues with their API earlier, which might be why. |
Hi @teddymarchildon. Due to recent changes in the "develop" branch, this PR now has a merge conflict. Please follow this link if you need help resolving the conflict, so that the PR can be merged. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks, @teddymarchildon. Nice work!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@teddymarchildon, This looks great, thanks for adding the checks and fixing the existing wrong patterns :)
I've left a few comments, PTAL.
@apb7: Can we have a follow-up issue for handling: (We can implement this latter)
- TODO comments end with a period(.) [I think we have such checks for comments]
- TODO message should start with a capital letter.
scripts/pre_commit_linter.py
Outdated
BAD_PATTERNS_REGEXP = [ | ||
{ | ||
'regexp': r'TODO[^\(]*[^\)][^:]*[^\w]*$', | ||
'message': 'Please assign TODO comments to a user ' + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need +
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@apb7, do we want these test to only fail for a specific pattern or for any unexpected TODO pattern?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DubeySandeep The + sign is used so that each line length is below 80 characters as mandated by pylint
I'm happy to enforce the uppercase starting character in this regexp, and I believe all comments have to end with a period as enforced by one of the linting processes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @DubeySandeep, thanks for the comments. Please find the responses inline:
do we want these test to only fail for a specific pattern or for any unexpected TODO pattern?
I think the scope of this PR is to ensure that all TODO comments have an associated username in a specific pattern. Let me know if you think otherwise.
Do we need + here?
Nice catch! No, I don't think we require +
here. @teddymarchildon, can you please check other multi-line bad pattern messages. They do not use +
.
TODO comments end with a period(.) [I think we have such checks for comments]
I think the comment check will cover this as well, right?
TODO message should start with a capital letter.
I'll file a follow-up issue for this (filed #7182). @teddymarchildon, if you're interested, please let us know on that issue thread. We'll assign it to you. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the reply @apb7, @teddymarchildon can you please update the PR as Apurv suggested so that we can quickly merge this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DubeySandeep I believe I have addressed the comments, and can start working on the next issue once this one is merged. Let me know if there is anything else to fix up or if I missed something from those comments!
if _check_bad_pattern_in_file( | ||
filepath, file_content, regexp): | ||
failed = True | ||
total_error_count += 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@apb7, total_error_count
is the number of files with bad patterns? (that's also not true though) or it's the number of failed patterns?
(I mean in one file there can be multiple errors for a single bad_pattern regexp.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's the total number of failed patterns (for reference, please see other regexp checks). Thanks!
@@ -46,7 +46,7 @@ <h2 translate="I18N_GET_STARTED_PAGE_PARAGRAPH_8_HEADING"></h2> | |||
<p translate="I18N_GET_STARTED_PAGE_PARAGRAPH_8"> | |||
</p> | |||
|
|||
<!-- todo: make it easy to get the right link to share, update this doc with that info --> | |||
<!-- TODO(vojtechjelinek): make it easy to get the right link to share, update this doc with that info --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@apb7, I think the "Period at the end of comment" doesn't work here!
@@ -48,7 +48,7 @@ describe('rich-text components', function() { | |||
explorationEditorMainTab.setContent(function(richTextEditor) { | |||
richTextEditor.appendBoldText('bold'); | |||
richTextEditor.appendPlainText(' '); | |||
// TODO (Jacob) add test for image RTE component | |||
// TODO(Jacob): add test for image RTE component |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@apb7, Ditto.
@@ -95,11 +95,11 @@ describe('Oppia static pages tour', function() { | |||
|
|||
afterEach(function() { | |||
general.checkForConsoleErrors([ | |||
// TODO (Jacob) Remove when | |||
// TODO(Jacob): Remove when | |||
// https://code.google.com/p/google-cast-sdk/issues/detail?id=309 is fixed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little confused about what the next step is here. I see some comments by @DubeySandeep addressed to @apb7 and I don't know whether the ball is still in @teddymarchildon's court or not. I'm assigning @apb7 to reply to @DubeySandeep's comments. @teddymarchildon -- would you mind replying to this thread and leaving a top-level comment if you're done with everything and would just like to get a review? I'm happy to merge this once @apb7 and @DubeySandeep confirm. Thanks! |
My bad, I forgot to add a comment once I was done addressing comments. I just added one replying, but I think I have addressed the issues @DubeySandeep and @apb7 brought up - if not let me know and I can fix it up! I can start working on the next issue once this one is merged. |
Great, thanks @teddymarchildon! In that case, deassigning you and adding @DubeySandeep @apb7 for final review/confirmation. Also, please note that you can work on more than one issue at a time! Just make sure to do that on a new, separate feature branch created from develop, as described here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the issue stated in #7010 is resolved and we can merge this PR. LGTM!
@teddymarchildon, Congrats on your first successful PR to Oppia! :) |
OK, merging! Congrats @teddymarchildon :D |
Fixes #7010: Adds a linting check that ensures all TODO comments have a username with them.
This adds a lint check that ensures all TODO comments have a username with them.
Checklist
python scripts/pre_commit_linter.py
andbash scripts/run_frontend_tests.sh
.