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

Add try..except block in pre-commit linter #6019

Merged
merged 3 commits into from
Dec 21, 2018

Conversation

apb7
Copy link
Contributor

@apb7 apb7 commented Dec 21, 2018

Add try..except block to handle the case when
there are no Python, JavaScript or CSS files to lint.

Explanation

Checklist

  • The PR title starts with "Fix #bugnum: ", followed by a short, clear summary of the changes. (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".)
  • The PR explanation includes the words "Fixes #bugnum: ..." (or "Fixes part of #bugnum" if the PR only partially fixes an issue).
  • The linter/Karma presubmit checks have passed.
    • These should run automatically, but if not, you can manually trigger them locally using python scripts/pre_commit_linter.py and bash scripts/run_frontend_tests.sh.
  • The PR is made from a branch that's not called "develop".
  • The PR follows the style guide.
  • The PR is assigned to an appropriate reviewer.
    • If you're a new contributor, please ask on Gitter for someone to assign a reviewer.
    • If you're not sure who the appropriate reviewer is, please assign to the issue's "owner" -- see the "talk-to" label on the issue.

Add try..except block to handle the case when
there are no Python, JavaScript or CSS files to lint.
TIMEOUT_MULTIPLIER * len(file_group) / number_of_files_to_lint))

# try..except block is needed to catch ZeroDivisionError
# when there are no Python, JavaScript or CSS files to lint.
Copy link
Member

Choose a reason for hiding this comment

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

We also count HTML files, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Um, yes, we include the HTML files to check for the CSS part. Let me modify the comment here then. Thanks!

@codecov-io
Copy link

codecov-io commented Dec 21, 2018

Codecov Report

Merging #6019 into develop will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           develop   #6019   +/-   ##
=======================================
  Coverage     45.3%   45.3%           
=======================================
  Files          520     520           
  Lines        30667   30667           
  Branches      4597    4597           
=======================================
  Hits         13893   13893           
  Misses       16774   16774

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d101331...ee66f00. Read the comment docs.

@@ -739,8 +739,14 @@ def _pre_commit_linter(all_files):
for file_group, process in zip(file_groups_to_lint, linting_processes):
# Require timeout parameter to prevent against endless waiting for the
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably move this comment inside the try block?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, thanks!

@apb7
Copy link
Contributor Author

apb7 commented Dec 21, 2018

Thanks, @nithusha21! Hi @BenHenning, can you please approve this as a code owner? Thanks!

@nithusha21 nithusha21 merged commit 8a58279 into oppia:develop Dec 21, 2018
@apb7 apb7 deleted the add-check-for-no-files-to-lint branch December 21, 2018 16:32
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.

4 participants