-
Notifications
You must be signed in to change notification settings - Fork 32
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 a simple linter and a pre-commit hook for it #3029
base: develop
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughThe pull request introduces enhancements to the pre-commit process by adding a series of linting and analysis commands in the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (2)
lint.php (2)
45-45
: Prefix class names to adhere to WordPress coding standardsAccording to WordPress coding standards, class names should be prefixed with a unique project-specific prefix to prevent potential naming conflicts. Consider renaming
Lint_Rule
to include a prefix specific to your project.Apply this diff to rename the class:
-class Lint_Rule { +class YourPrefix_Lint_Rule {
175-175
: Ensure inline comments end with a periodThe inline comment on line 175 does not end with a period. As per WordPress documentation standards, all inline comments should conclude with a period.
Apply this diff to correct the issue:
- return false; // Skip excluded directories + return false; // Skip excluded directories.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (18)
.husky/pre-commit
(1 hunks)CHANGELOG.md
(0 hunks)lint.php
(1 hunks)src/@types/assets/window.d.ts
(0 hunks)src/Telemetry/Tracks/class-tracks-pixel.php
(0 hunks)src/content-helper/common/class-content-helper-feature.php
(0 hunks)src/content-helper/common/components/input-range/style.scss
(0 hunks)src/content-helper/editor-sidebar/performance-stats/performance-stats.scss
(0 hunks)src/content-helper/editor-sidebar/related-posts/related-posts.scss
(0 hunks)src/rest-api/content-helper/class-endpoint-smart-linking.php
(0 hunks)src/rest-api/settings/class-base-settings-endpoint.php
(0 hunks)src/services/class-base-api-service.php
(0 hunks)src/services/content-api/endpoints/class-endpoint-analytics-posts.php
(0 hunks)tests/Integration/ContentHelper/ContentHelperPostListStatsTest.php
(0 hunks)tests/Integration/RestAPI/BaseAPIControllerTest.php
(0 hunks)tests/Integration/RestAPI/ContentHelper/ContentHelperFeatureTestTrait.php
(0 hunks)tests/Integration/UI/SettingsPageTest.php
(0 hunks)wp-parsely.php
(0 hunks)
💤 Files with no reviewable changes (16)
- src/content-helper/common/components/input-range/style.scss
- src/services/class-base-api-service.php
- src/content-helper/common/class-content-helper-feature.php
- src/@types/assets/window.d.ts
- src/content-helper/editor-sidebar/related-posts/related-posts.scss
- src/content-helper/editor-sidebar/performance-stats/performance-stats.scss
- src/rest-api/settings/class-base-settings-endpoint.php
- src/Telemetry/Tracks/class-tracks-pixel.php
- tests/Integration/RestAPI/BaseAPIControllerTest.php
- src/services/content-api/endpoints/class-endpoint-analytics-posts.php
- wp-parsely.php
- tests/Integration/RestAPI/ContentHelper/ContentHelperFeatureTestTrait.php
- CHANGELOG.md
- tests/Integration/ContentHelper/ContentHelperPostListStatsTest.php
- tests/Integration/UI/SettingsPageTest.php
- src/rest-api/content-helper/class-endpoint-smart-linking.php
🧰 Additional context used
📓 Path-based instructions (1)
lint.php (1)
Pattern **/*.{html,php}
: "Perform a detailed review of the provided code with following key aspects in mind:
- Review the HTML and PHP code to ensure it is well-structured and adheres to best practices.
- Ensure the code follows WordPress coding standards and is well-documented.
- Confirm the code is secure and free from vulnerabilities.
- Optimize the code for performance, removing any unnecessary elements.
- Validate comments for accuracy, currency, and adherence to WordPress coding standards.
- Ensure each line comment concludes with a period.
- Verify code compatibility with the latest version of WordPress, avoiding deprecated functions or features."
🔇 Additional comments (1)
.husky/pre-commit (1)
1-4
: Pre-commit hooks are properly configured
The added pre-commit commands enhance code quality checks and align with best practices.
Description
With this PR we're introducing a very simplistic in-house linter, with optional auto-fixing support for simple linting violations. The linter has been included as a pre-commit hook and currently supports 2 rules related to unneeded extra lines.
We used
php lint.php --fix
to auto-fix all the linting violations present in this PR.The linter also supports just displaying any violations, using the
php lint.php
command.Know issues:
--fix
mode, as I didn't want to take more time with this. Again, we can live without this and it can be adjusted in the future.Motivation and context
How has this been tested?
Screenshots
Our linter in display mode:
Summary by CodeRabbit
New Features
Bug Fixes
Tests
Documentation