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

Update Pre-Commit hooks #16983

Merged
merged 8 commits into from
Aug 12, 2024
Merged

Update Pre-Commit hooks #16983

merged 8 commits into from
Aug 12, 2024

Conversation

SaschaCowley
Copy link
Member

@SaschaCowley SaschaCowley commented Aug 9, 2024

Link to issue number:

None

Summary of the issue:

Continuing work on our pre-commit hooks, there are still several we don't use but could.

Description of user facing changes

None.

Description of development approach

Tested pre-commit hooks available at https://github.com/pre-commit/pre-commit-hooks/. Added those that work as expected and do not require major changes to our code base. Added:

  • Automatic checking of yaml, toml and XML syntax
  • Checks that no Python debug statements are included in commits
  • Remove BOM on Python, C/C++ and Batch files, if present
  • Ensure that unit test files are named according to unittest rules.
  • Ensure that any include VCS links are permalinks.

Testing strategy:

Ran the tests individually with pre-commit run <hook-id> -a and all together with pre-commit run -a.

Known issues with pull request:

The following are good candidates for inclusion:

  • check-builtin-literals: We have a lot of violations of this one
  • check-docstring-first: We have a lot of violations of this one
  • check-illegal-windows-names: Not yet in a tagged version.
  • check-added-large-files: We have several files that are larger than the default limit of 500kb. It is not clear what our cut-off should be, and it doesn't seem as though we can have different sizes for different file types.
    • The biggest culprits seem to be translations, with the largest (Simplified Chinese (PRC)) character descriptions being 3.21MiB.

Code Review Checklist:

  • Documentation:
    • Change log entry
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • API is compatible with existing add-ons.
  • Security precautions taken.

Summary by CodeRabbit

  • New Features

    • Enhanced pre-commit hooks for improved code quality and style enforcement.
    • Added checks for various file types including TOML, YAML, XML, and VCS permalinks.
  • Improvements

    • Modified existing test hook to enforce unittest standards, refining the validation process for Python files.

@SaschaCowley SaschaCowley requested a review from a team as a code owner August 9, 2024 04:30
@SaschaCowley SaschaCowley requested a review from seanbudd August 9, 2024 04:30
Copy link
Contributor

coderabbitai bot commented Aug 9, 2024

Walkthrough

The recent updates to the .pre-commit-config.yaml file significantly enhance code quality checks by introducing several new pre-commit hooks. These hooks address a variety of file types, ensuring adherence to formatting standards and improving code integrity. Additionally, existing hooks have been modified to refine their functionality, specifically tailoring the unittest process to exclude certain Python files. Overall, these changes bolster the validation process for more maintainable and reliable code contributions.

Changes

File Change Summary
.pre-commit-config.yaml Added new checks: debug-statements, fix-byte-order-marker, check-toml, check-yaml, check-xml, and check-vcs-permalinks. Modified name-tests-test to include args: ["--unittest"] with specific exclusion patterns for certain Python tests.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Pre-commit
    participant Codebase

    User->>Pre-commit: Initiates pre-commit hook checks
    Pre-commit->>Codebase: Runs new checks (e.g., debug-statements, check-yaml)
    Codebase-->>Pre-commit: Provides validation results
    Pre-commit-->>User: Displays report on code quality and style
Loading

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

.pre-commit-config.yaml Show resolved Hide resolved
.pre-commit-config.yaml Show resolved Hide resolved
.pre-commit-config.yaml Show resolved Hide resolved
.pre-commit-config.yaml Show resolved Hide resolved
@SaschaCowley SaschaCowley requested a review from seanbudd August 9, 2024 06:16
.pre-commit-config.yaml Outdated Show resolved Hide resolved
test.txt Outdated
@@ -0,0 +1 @@
Test link: https://github.com/pre-commit/pre-commit-hooks/blob/main/pre_commit_hooks/check_vcs_permalinks.py
Copy link
Member

Choose a reason for hiding this comment

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

please remove this file

@seanbudd seanbudd merged commit c8a847b into master Aug 12, 2024
4 checks passed
@seanbudd seanbudd deleted the updatePrecommit branch August 12, 2024 04:44
@github-actions github-actions bot added this to the 2024.4 milestone Aug 12, 2024
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