From 497c44c3c6981b549782217e82c9426b1a5639c5 Mon Sep 17 00:00:00 2001 From: marcusquinn <6428977+marcusquinn@users.noreply.github.com> Date: Mon, 21 Apr 2025 03:58:18 +0100 Subject: [PATCH] Add documentation for code quality tools and standards --- .ai-workflows/code-review.md | 56 ++++++- .wiki/Coding-Standards.md | 56 +++++++ .wiki/Contributing.md | 50 +++++++ README.md | 34 +++++ phpcs-simple.xml | 57 +++++++ readme.txt | 23 +++ wiki/Coding-Standards.md | 283 +++++++++++++++++++++++++++++++++++ wiki/Contributing.md | 180 ++++++++++++++++++++++ 8 files changed, 738 insertions(+), 1 deletion(-) create mode 100644 phpcs-simple.xml create mode 100644 wiki/Coding-Standards.md create mode 100644 wiki/Contributing.md diff --git a/.ai-workflows/code-review.md b/.ai-workflows/code-review.md index 14b357c..0b427ff 100644 --- a/.ai-workflows/code-review.md +++ b/.ai-workflows/code-review.md @@ -1,6 +1,6 @@ # Code Review Guide for AI Assistants -This document provides guidance for AI assistants to help with code review for the Fix Plugin Does Not Exist Notices plugin. +This document provides guidance for AI assistants to help with code review for th plugin. ## Code Review Checklist @@ -57,6 +57,60 @@ When reviewing code, check for the following: - [ ] Is keyboard navigation supported? - [ ] Is screen reader support implemented? +## Automated Code Review Tools + +This project uses several automated code review tools to maintain high code quality standards. These tools are free to use for public repositories and should be integrated into any new repositories based on this template. + +### 1. CodeRabbit + +[CodeRabbit](https://www.coderabbit.ai/) is an AI-powered code review tool that provides automated feedback on pull requests. + +- **Integration**: Add the CodeRabbit GitHub App to your repository +- **Benefits**: Provides AI-powered code reviews, identifies potential issues, and suggests improvements +- **Usage**: CodeRabbit automatically reviews pull requests when they are created or updated + +### 2. CodeFactor + +[CodeFactor](https://www.codefactor.io/) continuously monitors code quality and provides feedback on code style, complexity, and potential issues. + +- **Integration**: Add the CodeFactor GitHub App to your repository +- **Benefits**: Provides a grade for your codebase, identifies issues, and tracks code quality over time +- **Usage**: CodeFactor automatically analyzes your codebase and provides feedback on pull requests + +### 3. Codacy + +[Codacy](https://www.codacy.com/) is a code quality tool that provides static analysis, code coverage, and code duplication detection. + +- **Integration**: Add the Codacy GitHub App to your repository +- **Benefits**: Provides a grade for your codebase, identifies issues, and tracks code quality over time +- **Usage**: Codacy automatically analyzes your codebase and provides feedback on pull requests + +### 4. SonarCloud + +[SonarCloud](https://sonarcloud.io/) is a cloud-based code quality and security service that performs static code analysis to detect bugs, vulnerabilities, and code smells. + +- **Integration**: Add the SonarCloud GitHub App to your repository +- **Benefits**: Provides detailed analysis of code quality, security vulnerabilities, and technical debt +- **Usage**: SonarCloud automatically analyzes your codebase and provides feedback on pull requests + +### Using AI Assistants with Code Review Tools + +When you receive feedback from these code review tools, you can use AI assistants to help address the issues: + +1. Copy the output from the code review tool +2. Paste it into your AI assistant chat +3. Ask the AI to help you understand and fix the issues +4. Implement the suggested fixes +5. Commit the changes and verify that the issues are resolved + +Example prompt for AI assistants: + +``` +I received the following feedback from [Tool Name]. Please help me understand these issues and suggest fixes: + +[Paste the tool output here] +``` + ## Code Review Process ### 1. Understand the Context diff --git a/.wiki/Coding-Standards.md b/.wiki/Coding-Standards.md index 0d8f9dd..7024ca7 100644 --- a/.wiki/Coding-Standards.md +++ b/.wiki/Coding-Standards.md @@ -202,6 +202,8 @@ This plugin follows the [WordPress CSS Coding Standards](https://developer.wordp This plugin uses automated tools to enforce coding standards: +### Local Development Tools + 1. **PHP_CodeSniffer (PHPCS)**: Checks PHP code against the WordPress Coding Standards ```bash composer run phpcs @@ -222,6 +224,60 @@ This plugin uses automated tools to enforce coding standards: npm run lint:css ``` +### Continuous Integration Tools + +This project integrates with several code quality tools that automatically analyze your code when you create a pull request. These tools are free for public repositories and should be integrated into any new repositories based on this template. + +1. **CodeRabbit**: AI-powered code review tool + - Provides automated feedback on pull requests + - Identifies potential issues and suggests improvements + - [Website](https://www.coderabbit.ai/) + +2. **CodeFactor**: Continuous code quality monitoring + - Provides a grade for your codebase + - Identifies issues related to code style, complexity, and potential bugs + - Tracks code quality over time + - [Website](https://www.codefactor.io/) + +3. **Codacy**: Code quality and static analysis + - Provides a grade for your codebase + - Identifies issues related to code style, security, and performance + - Tracks code quality over time + - [Website](https://www.codacy.com/) + +4. **SonarCloud**: Code quality and security analysis + - Provides detailed analysis of code quality + - Identifies security vulnerabilities and technical debt + - Tracks code quality over time + - [Website](https://sonarcloud.io/) + +### How to Pass Code Quality Checks + +To ensure your code passes the quality checks from these tools, follow these guidelines: + +1. **Run Local Checks First** + - Before pushing your code, run PHPCS and PHPCBF locally + - Fix any issues identified by these tools + +2. **Address Common Issues** + - **Indentation**: Use 4 spaces for indentation (not tabs) + - **Line Length**: Keep lines under 100 characters + - **Naming Conventions**: Follow WordPress naming conventions + - **Documentation**: Add PHPDoc comments to classes, methods, and functions + - **Error Handling**: Implement proper error handling + - **Security**: Validate and sanitize input, escape output + +3. **Using AI Assistants with Code Quality Tools** + - When you receive feedback from code quality tools, you can use AI assistants to help address the issues + - Copy the output from the code quality tool and paste it into your AI assistant chat + - Ask the AI to help you understand and fix the issues + - Example prompt: "I received the following feedback from [Tool Name]. Please help me understand these issues and suggest fixes: [Paste the tool output here]" + +4. **Iterative Improvement** + - Address issues one at a time, starting with the most critical + - Commit and push your changes to see if they resolve the issues + - Continue this process until all issues are resolved + ## Conclusion Following these coding standards ensures that the plugin's code is consistent, readable, and maintainable. All contributors should adhere to these standards when submitting code to the project. diff --git a/.wiki/Contributing.md b/.wiki/Contributing.md index dfa8376..d5f12ba 100644 --- a/.wiki/Contributing.md +++ b/.wiki/Contributing.md @@ -78,6 +78,45 @@ If you want to contribute code: - Keep pull requests focused on a single change - Write a clear, descriptive title and description - Reference any related issues +- Ensure your code passes the automated code quality checks (see below) + +#### Code Quality Tools + +This project uses several automated code quality tools to ensure high standards. These tools are free for public repositories and will automatically analyze your code when you create a pull request: + +1. **CodeRabbit**: AI-powered code review tool + - [Website](https://www.coderabbit.ai/) + - Provides automated feedback on pull requests + +2. **CodeFactor**: Continuous code quality monitoring + - [Website](https://www.codefactor.io/) + - Provides a grade for your codebase + +3. **Codacy**: Code quality and static analysis + - [Website](https://www.codacy.com/) + - Identifies issues related to code style, security, and performance + +4. **SonarCloud**: Code quality and security analysis + - [Website](https://sonarcloud.io/) + - Provides detailed analysis of code quality and security + +#### Using AI Assistants with Code Quality Tools + +When you receive feedback from these code quality tools, you can use AI assistants to help address the issues: + +1. Copy the output from the code quality tool +2. Paste it into your AI assistant chat +3. Ask the AI to help you understand and fix the issues +4. Implement the suggested fixes +5. Commit the changes and verify that the issues are resolved + +Example prompt for AI assistants: + +``` +I received the following feedback from [Tool Name]. Please help me understand these issues and suggest fixes: + +[Paste the tool output here] +``` ## Development Environment @@ -95,6 +134,17 @@ Before submitting a pull request, make sure to run the tests: - End-to-End Tests: `npm run test:e2e` - Coding Standards: `npm run lint:php` +#### Code Quality Checks + +To ensure your code meets the quality standards, run these commands before submitting a pull request: + +- Check coding standards: `composer run phpcs` +- Fix coding standards automatically: `composer run phpcbf` +- Check JavaScript coding standards: `npm run lint:js` +- Check CSS coding standards: `npm run lint:css` + +These checks will help identify and fix issues before they are caught by the automated code quality tools in the pull request process. + ## Documentation If you're adding a new feature or changing existing functionality, please update the documentation: diff --git a/README.md b/README.md index 4e2abc5..6cc0910 100644 --- a/README.md +++ b/README.md @@ -235,6 +235,40 @@ Contributions are welcome! Please feel free to submit a Pull Request. 4. Push to the branch: `git push origin feature/amazing-feature` 5. Submit a pull request +For more detailed information, see the [Contributing Guide](.wiki/Contributing.md). + +### Code Quality Tools + +This project uses several automated code quality tools to ensure high standards. These tools are free for public repositories and should be integrated into any new repositories based on this template: + +1. **CodeRabbit**: AI-powered code review tool + - [Website](https://www.coderabbit.ai/) + - Provides automated feedback on pull requests + +2. **CodeFactor**: Continuous code quality monitoring + - [Website](https://www.codefactor.io/) + - Provides a grade for your codebase + +3. **Codacy**: Code quality and static analysis + - [Website](https://www.codacy.com/) + - Identifies issues related to code style, security, and performance + +4. **SonarCloud**: Code quality and security analysis + - [Website](https://sonarcloud.io/) + - Provides detailed analysis of code quality and security + +### Using AI Assistants with Code Quality Tools + +When you receive feedback from these code quality tools, you can use AI assistants to help address the issues: + +1. Copy the output from the code quality tool +2. Paste it into your AI assistant chat +3. Ask the AI to help you understand and fix the issues +4. Implement the suggested fixes +5. Commit the changes and verify that the issues are resolved + +For more information on coding standards and how to pass code quality checks, see the [Coding Standards Guide](.wiki/Coding-Standards.md). + ## Developers ### AI-Powered Development diff --git a/phpcs-simple.xml b/phpcs-simple.xml new file mode 100644 index 0000000..1be1b41 --- /dev/null +++ b/phpcs-simple.xml @@ -0,0 +1,57 @@ + + + A simplified ruleset for WordPress Plugin Starter Template. + + + . + + + */vendor/* + */node_modules/* + */bin/* + */.github/* + */tests/* + */build/* + */dist/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/readme.txt b/readme.txt index c97f9a6..f31a7d0 100644 --- a/readme.txt +++ b/readme.txt @@ -133,6 +133,29 @@ Contributions are welcome! Please feel free to submit a Pull Request. 4. Push to the branch: `git push origin feature/amazing-feature` 5. Submit a pull request +For more detailed information, see the [Contributing Guide](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/wiki/Contributing) in the wiki. + += Code Quality Tools = + +This project uses several automated code quality tools to ensure high standards. These tools are free for public repositories and should be integrated into any new repositories based on this template: + +1. **CodeRabbit**: AI-powered code review tool that provides automated feedback on pull requests +2. **CodeFactor**: Continuous code quality monitoring that provides a grade for your codebase +3. **Codacy**: Code quality and static analysis that identifies issues related to code style, security, and performance +4. **SonarCloud**: Code quality and security analysis that provides detailed analysis of code quality and security + += Using AI Assistants with Code Quality Tools = + +When you receive feedback from these code quality tools, you can use AI assistants to help address the issues: + +1. Copy the output from the code quality tool +2. Paste it into your AI assistant chat +3. Ask the AI to help you understand and fix the issues +4. Implement the suggested fixes +5. Commit the changes and verify that the issues are resolved + +For more information on coding standards and how to pass code quality checks, see the [Coding Standards Guide](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/wiki/Coding-Standards) in the wiki. + == Installation == 1. Clone or download this repository diff --git a/wiki/Coding-Standards.md b/wiki/Coding-Standards.md new file mode 100644 index 0000000..7024ca7 --- /dev/null +++ b/wiki/Coding-Standards.md @@ -0,0 +1,283 @@ +# Coding Standards + +This document outlines the coding standards used in this plugin. Following these standards ensures consistency, readability, and maintainability of the codebase. + +## PHP Coding Standards + +This plugin follows the [WordPress Coding Standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/) with some additional guidelines. + +### File Structure + +- Each PHP file should begin with the PHP opening tag `