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

Check the entire code base for compliance with DOC String standard #226

Merged
merged 45 commits into from
Jan 7, 2025

Conversation

mandeepnh5
Copy link

@mandeepnh5 mandeepnh5 commented Jan 3, 2025

What kind of change does this PR introduce?
This change will check the entire code base for comapliance with the DOC string compliance

Issue Number:

Fixes #210

If relevant, did you update the documentation?
No

Does this PR introduce a breaking change?
No

Checklist

CodeRabbit AI Review

  • I have reviewed and addressed all critical issues flagged by CodeRabbit AI
  • I have implemented or provided justification for each non-critical suggestion
  • I have documented my reasoning in the PR comments where CodeRabbit AI suggestions were not implemented

Test Coverage

  • I have written tests for all new changes/features
  • I have verified that test coverage meets or exceeds 95%
  • I have run the test suite locally and all tests pass

Have you read the contributing guide?
Yes

Summary by CodeRabbit

  • New Features

    • Added a GitHub Actions workflow job to check docstring compliance in Python files
    • Introduced a script to validate docstrings against Google style guide standards
  • Chores

    • Added docstring_parser package to project requirements

The changes enhance code documentation quality and enforce documentation standards through automated checks.

Copy link

coderabbitai bot commented Jan 3, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This pull request introduces a comprehensive docstring compliance validation mechanism for the project. A new GitHub Actions job named Docstring-Compliance has been added to the pull request workflow. The job includes a Python script .github/workflows/scripts/check_docstrings.py that validates Python docstrings against the Google style guide. The script uses the docstring_parser library, which has been added to the requirements.txt file, to check for docstring presence, formatting, and adherence to documentation standards.

Changes

File Change Summary
.github/workflows/pull-request.yml Added new Docstring-Compliance job to validate docstring standards
.github/workflows/scripts/check_docstrings.py New script to validate Python docstrings using docstring_parser library
requirements.txt Added docstring_parser package for docstring parsing

Sequence Diagram

sequenceDiagram
    participant GHA as GitHub Actions
    participant Script as check_docstrings.py
    participant Parser as docstring_parser
    
    GHA->>Script: Run docstring validation
    Script->>Script: Scan Python files
    Script->>Parser: Parse docstrings
    Parser-->>Script: Validation results
    Script->>GHA: Report compliance status
Loading

Assessment against linked issues

Objective Addressed Explanation
Create script to check docstring compliance [#210]
Script resides in .github/workflows/scripts [#210]
Run as part of every pull request [#210]
Use docstring_parser library [#210]
Provide detailed violation information [#210]
Add pip package to requirements.txt [#210]

Possibly related PRs

Suggested labels

ignore-sensitive-files-pr

Poem

🐰 Docstrings dancing, neat and bright,
In GitHub's workflow, a validation's might!
Line by line, we check with care,
Google's style guide, beyond compare.
Compliance sings, a rabbit's delight! 📜✨


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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.

Copy link

github-actions bot commented Jan 3, 2025

Our Pull Request Approval Process

We have these basic policies to make the approval process smoother for our volunteer team.

Testing Your Code

Please make sure your code passes all tests. Our test code coverage system will fail if either of these two conditions occur:

  1. The overall code coverage drops below the target threshold of the repository
  2. Any file in the pull request has code coverage levels below the repository threshold

The process helps maintain the overall reliability of the code base and is a prerequisite for getting your PR approved. Assigned reviewers regularly review the PR queue and tend to focus on PRs that are passing.

Reviewers

When your PR has been assigned reviewers contact them to get your code reviewed and approved via:

  1. comments in this PR or
  2. our slack channel

Reviewing Your Code

Your reviewer(s) will have the following roles:

  1. arbitrators of future discussions with other contributors about the validity of your changes
  2. point of contact for evaluating the validity of your work
  3. person who verifies matching issues by others that should be closed.
  4. person who gives general guidance in fixing your tests

🎯 Contacting the person who assigned the mentors is not advised unless they make a request. Do not @ the person who did the assignment otherwise.

@mandeepnh5
Copy link
Author

@coderabbitai full review

Copy link

coderabbitai bot commented Jan 3, 2025

✅ Actions performed

Full review triggered.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (6)
.github/workflows/scripts/check_docstrings.py (2)

27-37: Consider checking for a Returns section to fully align with Google style docstrings.
While you currently validate the presence of Raises and Args sections, Google style guidelines also recommend including a Returns section where applicable.


21-22: Handle async def definitions if needed.
The current regex only matches regular functions but would skip async def definitions if your codebase includes them.

requirements.txt (1)

31-33: Pin or specify the version of docstring_parser.
To maintain consistent CI results and avoid unexpected regressions, consider pinning this dependency to a known compatible version.

.github/workflows/pull-request.yml (3)

224-224: Remove trailing spaces.
YAML linters will fail if they detect trailing white spaces on this line.

+224
🧰 Tools
🪛 yamllint (1.35.1)

[error] 224-224: trailing spaces

(trailing-spaces)


230-230: Update action version to adhere to the latest GitHub Actions guidelines.
Static analysis indicates that actions/checkout@v3 might be out-of-date. Consider using actions/checkout@v4.

-      - name: Checkout code
-        uses: actions/checkout@v3
+      - name: Checkout code
+        uses: actions/checkout@v4
🧰 Tools
🪛 actionlint (1.7.4)

230-230: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


241-241: Add a newline and remove trailing spaces at the end of the file.
YAML and some CI validators may enforce no trailing spaces and a newline at EOF for compliance.

-        run: python .github/workflows/scripts/check_docstrings.py 
+        run: python .github/workflows/scripts/check_docstrings.py
+
🧰 Tools
🪛 yamllint (1.35.1)

[error] 241-241: no new line character at the end of file

(new-line-at-end-of-file)


[error] 241-241: trailing spaces

(trailing-spaces)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 97d4ba3 and 6280437.

📒 Files selected for processing (3)
  • .github/workflows/pull-request.yml (1 hunks)
  • .github/workflows/scripts/check_docstrings.py (1 hunks)
  • requirements.txt (1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/pull-request.yml

230-230: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


233-233: the runner of "actions/setup-python@v4" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🪛 yamllint (1.35.1)
.github/workflows/pull-request.yml

[error] 224-224: trailing spaces

(trailing-spaces)


[error] 241-241: no new line character at the end of file

(new-line-at-end-of-file)


[error] 241-241: trailing spaces

(trailing-spaces)

🔇 Additional comments (3)
.github/workflows/scripts/check_docstrings.py (2)

28-31: Consider edge cases when parsing multiline docstrings that close on the same line.
If the docstring’s triple quotes end on the same line they started, this approach may skip them.


79-90: Exit code logic looks good.
Exiting with sys.exit(1) on violation detection ensures that CI will fail appropriately when docstring violations are found.

.github/workflows/pull-request.yml (1)

225-241: Job definition looks good.
The new Docstring-Compliance job neatly integrates docstring checks into the CI pipeline.

🧰 Tools
🪛 actionlint (1.7.4)

230-230: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


233-233: the runner of "actions/setup-python@v4" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🪛 yamllint (1.35.1)

[error] 241-241: no new line character at the end of file

(new-line-at-end-of-file)


[error] 241-241: trailing spaces

(trailing-spaces)

coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 3, 2025
Copy link
Contributor

@palisadoes palisadoes left a comment

Choose a reason for hiding this comment

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

You will have to lint the entire code base to make sure it is compliant with your test.

Then after doing that you'll have to edit one of the files to be non compliant and validate your test works

@mandeepnh5
Copy link
Author

@palisadoes oh alright so only it didn't run the pull request check?

@palisadoes
Copy link
Contributor

Please fix

@mandeepnh5
Copy link
Author

@palisadoes I am not finding a linting package used in this code base.
I maybe wrong i never did this

@palisadoes
Copy link
Contributor

  1. The linting is related to validating the DocStrings match the standard.
  2. There is another issue to lint the code outside of the DocStrings.

@mandeepnh5
Copy link
Author

image
Its telling I need maintainer approval for running pull request check

@palisadoes
Copy link
Contributor

I changed the branch protection rules. It should be OK the next time.

@palisadoes palisadoes added the ignore-sensitive-files-pr The contributor has a legitimate reason for editiing protected files label Jan 4, 2025
.github/workflows/pull-request.yml Outdated Show resolved Hide resolved
Copy link
Contributor

@palisadoes palisadoes left a comment

Choose a reason for hiding this comment

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

See comment

@mandeepnh5
Copy link
Author

mandeepnh5 commented Jan 5, 2025

Ok I will try fix it , it still is not working

@mandeepnh5
Copy link
Author

@palisadoes I have edited all the files which didnt follow DOC string standard

@mandeepnh5
Copy link
Author

sorry there still seems to be few more i will fix in some time

@mandeepnh5
Copy link
Author

@palisadoes Please check, If its proper i will remove print statements and commit clean code

@palisadoes palisadoes merged commit e4b8cba into PalisadoesFoundation:develop Jan 7, 2025
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ignore-sensitive-files-pr The contributor has a legitimate reason for editiing protected files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants