Merge pull request #8 from wpallstars/code-quality-documentation
Add documentation for code quality tools and standards
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
# Code Review Guide for AI Assistants
|
# 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
|
## Code Review Checklist
|
||||||
|
|
||||||
@@ -57,6 +57,60 @@ When reviewing code, check for the following:
|
|||||||
- [ ] Is keyboard navigation supported?
|
- [ ] Is keyboard navigation supported?
|
||||||
- [ ] Is screen reader support implemented?
|
- [ ] 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
|
## Code Review Process
|
||||||
|
|
||||||
### 1. Understand the Context
|
### 1. Understand the Context
|
||||||
|
|||||||
@@ -202,6 +202,8 @@ This plugin follows the [WordPress CSS Coding Standards](https://developer.wordp
|
|||||||
|
|
||||||
This plugin uses automated tools to enforce coding standards:
|
This plugin uses automated tools to enforce coding standards:
|
||||||
|
|
||||||
|
### Local Development Tools
|
||||||
|
|
||||||
1. **PHP_CodeSniffer (PHPCS)**: Checks PHP code against the WordPress Coding Standards
|
1. **PHP_CodeSniffer (PHPCS)**: Checks PHP code against the WordPress Coding Standards
|
||||||
```bash
|
```bash
|
||||||
composer run phpcs
|
composer run phpcs
|
||||||
@@ -222,6 +224,60 @@ This plugin uses automated tools to enforce coding standards:
|
|||||||
npm run lint:css
|
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
|
## 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.
|
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.
|
||||||
|
|||||||
@@ -78,6 +78,45 @@ If you want to contribute code:
|
|||||||
- Keep pull requests focused on a single change
|
- Keep pull requests focused on a single change
|
||||||
- Write a clear, descriptive title and description
|
- Write a clear, descriptive title and description
|
||||||
- Reference any related issues
|
- 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
|
## 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`
|
- End-to-End Tests: `npm run test:e2e`
|
||||||
- Coding Standards: `npm run lint:php`
|
- 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
|
## Documentation
|
||||||
|
|
||||||
If you're adding a new feature or changing existing functionality, please update the documentation:
|
If you're adding a new feature or changing existing functionality, please update the documentation:
|
||||||
|
|||||||
34
README.md
34
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`
|
4. Push to the branch: `git push origin feature/amazing-feature`
|
||||||
5. Submit a pull request
|
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
|
## Developers
|
||||||
|
|
||||||
### AI-Powered Development
|
### AI-Powered Development
|
||||||
|
|||||||
57
phpcs-simple.xml
Normal file
57
phpcs-simple.xml
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<ruleset name="WordPress Plugin Starter Template Simple">
|
||||||
|
<description>A simplified ruleset for WordPress Plugin Starter Template.</description>
|
||||||
|
|
||||||
|
<!-- Check all PHP files in directory tree by default. -->
|
||||||
|
<file>.</file>
|
||||||
|
|
||||||
|
<!-- Exclude paths -->
|
||||||
|
<exclude-pattern>*/vendor/*</exclude-pattern>
|
||||||
|
<exclude-pattern>*/node_modules/*</exclude-pattern>
|
||||||
|
<exclude-pattern>*/bin/*</exclude-pattern>
|
||||||
|
<exclude-pattern>*/.github/*</exclude-pattern>
|
||||||
|
<exclude-pattern>*/tests/*</exclude-pattern>
|
||||||
|
<exclude-pattern>*/build/*</exclude-pattern>
|
||||||
|
<exclude-pattern>*/dist/*</exclude-pattern>
|
||||||
|
|
||||||
|
<!-- Command line arguments -->
|
||||||
|
<arg value="sp"/>
|
||||||
|
<arg name="extensions" value="php"/>
|
||||||
|
<arg name="basepath" value="."/>
|
||||||
|
<arg name="parallel" value="8"/>
|
||||||
|
|
||||||
|
<!-- Configs -->
|
||||||
|
<config name="minimum_supported_wp_version" value="5.0"/>
|
||||||
|
<config name="testVersion" value="7.0-"/>
|
||||||
|
|
||||||
|
<!-- Rules -->
|
||||||
|
<rule ref="WordPress">
|
||||||
|
<!-- Exclude rules that are too strict for this project -->
|
||||||
|
<exclude name="WordPress.Files.FileName.InvalidClassFileName"/>
|
||||||
|
<exclude name="WordPress.Files.FileName.NotHyphenatedLowercase"/>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<!-- Additional rules for better code quality -->
|
||||||
|
<rule ref="Generic.Formatting.MultipleStatementAlignment">
|
||||||
|
<properties>
|
||||||
|
<property name="maxPadding" value="1"/>
|
||||||
|
<property name="error" value="false"/>
|
||||||
|
</properties>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<!-- Use spaces for indentation -->
|
||||||
|
<rule ref="Generic.WhiteSpace.ScopeIndent">
|
||||||
|
<properties>
|
||||||
|
<property name="indent" value="4"/>
|
||||||
|
<property name="tabIndent" value="false"/>
|
||||||
|
</properties>
|
||||||
|
</rule>
|
||||||
|
<rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
|
||||||
|
|
||||||
|
<!-- Enforce proper line endings -->
|
||||||
|
<rule ref="Generic.Files.LineEndings">
|
||||||
|
<properties>
|
||||||
|
<property name="eolChar" value="\n"/>
|
||||||
|
</properties>
|
||||||
|
</rule>
|
||||||
|
</ruleset>
|
||||||
23
readme.txt
23
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`
|
4. Push to the branch: `git push origin feature/amazing-feature`
|
||||||
5. Submit a pull request
|
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 ==
|
== Installation ==
|
||||||
|
|
||||||
1. Clone or download this repository
|
1. Clone or download this repository
|
||||||
|
|||||||
283
wiki/Coding-Standards.md
Normal file
283
wiki/Coding-Standards.md
Normal file
@@ -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 `<?php` (no closing tag)
|
||||||
|
- Files should use the Unix line endings (LF)
|
||||||
|
- Files should be encoded in UTF-8 without BOM
|
||||||
|
|
||||||
|
### Naming Conventions
|
||||||
|
|
||||||
|
- **Classes**: Use `PascalCase` for class names
|
||||||
|
```php
|
||||||
|
class MyClassName {}
|
||||||
|
```
|
||||||
|
|
||||||
|
- **Methods and Functions**: Use `snake_case` for method and function names
|
||||||
|
```php
|
||||||
|
function my_function_name() {}
|
||||||
|
public function my_method_name() {}
|
||||||
|
```
|
||||||
|
|
||||||
|
- **Variables**: Use `snake_case` for variable names
|
||||||
|
```php
|
||||||
|
$my_variable_name = 'value';
|
||||||
|
```
|
||||||
|
|
||||||
|
- **Constants**: Use `UPPERCASE_WITH_UNDERSCORES` for constants
|
||||||
|
```php
|
||||||
|
define('MY_CONSTANT', 'value');
|
||||||
|
const MY_CLASS_CONSTANT = 'value';
|
||||||
|
```
|
||||||
|
|
||||||
|
- **Namespaces**: Use `PascalCase` for namespace segments
|
||||||
|
```php
|
||||||
|
namespace WPALLSTARS\PluginStarterTemplate;
|
||||||
|
```
|
||||||
|
|
||||||
|
- **Hooks**: Prefix hooks with the plugin's prefix
|
||||||
|
```php
|
||||||
|
do_action('wpst_hook_name');
|
||||||
|
apply_filters('wpst_filter_name', $value);
|
||||||
|
```
|
||||||
|
|
||||||
|
### Indentation and Formatting
|
||||||
|
|
||||||
|
- Use 4 spaces for indentation (not tabs)
|
||||||
|
- Opening braces for classes and functions should be on the same line
|
||||||
|
- Control structures should have one space between the statement and the opening parenthesis
|
||||||
|
- Each line should be no longer than 100 characters
|
||||||
|
|
||||||
|
```php
|
||||||
|
if ($condition) {
|
||||||
|
// Code here
|
||||||
|
} elseif ($another_condition) {
|
||||||
|
// More code
|
||||||
|
} else {
|
||||||
|
// Default code
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Documentation
|
||||||
|
|
||||||
|
- All classes, methods, and functions should be documented using PHPDoc
|
||||||
|
- Include a description, parameters, return values, and exceptions
|
||||||
|
|
||||||
|
```php
|
||||||
|
/**
|
||||||
|
* Short description of the function.
|
||||||
|
*
|
||||||
|
* Longer description if needed.
|
||||||
|
*
|
||||||
|
* @param string $param1 Description of the parameter.
|
||||||
|
* @param int $param2 Description of the parameter.
|
||||||
|
* @return bool Description of the return value.
|
||||||
|
* @throws Exception When something goes wrong.
|
||||||
|
*/
|
||||||
|
function my_function($param1, $param2) {
|
||||||
|
// Function code
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Object-Oriented Programming
|
||||||
|
|
||||||
|
- Each class should have a single responsibility
|
||||||
|
- Use visibility declarations for all properties and methods (public, protected, private)
|
||||||
|
- Use type hints for parameters and return types when possible
|
||||||
|
|
||||||
|
```php
|
||||||
|
class MyClass {
|
||||||
|
/**
|
||||||
|
* Property description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $property;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description.
|
||||||
|
*
|
||||||
|
* @param string $param Description of the parameter.
|
||||||
|
* @return bool Description of the return value.
|
||||||
|
*/
|
||||||
|
public function my_method(string $param): bool {
|
||||||
|
// Method code
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## JavaScript Coding Standards
|
||||||
|
|
||||||
|
This plugin follows the [WordPress JavaScript Coding Standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/javascript/).
|
||||||
|
|
||||||
|
### Naming Conventions
|
||||||
|
|
||||||
|
- **Variables and Functions**: Use `camelCase` for variable and function names
|
||||||
|
```javascript
|
||||||
|
var myVariableName = 'value';
|
||||||
|
function myFunctionName() {}
|
||||||
|
```
|
||||||
|
|
||||||
|
- **Constants**: Use `UPPERCASE_WITH_UNDERSCORES` for constants
|
||||||
|
```javascript
|
||||||
|
var MY_CONSTANT = 'value';
|
||||||
|
```
|
||||||
|
|
||||||
|
### Indentation and Formatting
|
||||||
|
|
||||||
|
- Use 4 spaces for indentation (not tabs)
|
||||||
|
- Opening braces should be on the same line as the statement
|
||||||
|
- Each line should be no longer than 100 characters
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
if (condition) {
|
||||||
|
// Code here
|
||||||
|
} else if (anotherCondition) {
|
||||||
|
// More code
|
||||||
|
} else {
|
||||||
|
// Default code
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Documentation
|
||||||
|
|
||||||
|
- Use JSDoc for documenting functions and objects
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
/**
|
||||||
|
* Short description of the function.
|
||||||
|
*
|
||||||
|
* @param {string} param1 - Description of the parameter.
|
||||||
|
* @param {number} param2 - Description of the parameter.
|
||||||
|
* @returns {boolean} Description of the return value.
|
||||||
|
*/
|
||||||
|
function myFunction(param1, param2) {
|
||||||
|
// Function code
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## CSS Coding Standards
|
||||||
|
|
||||||
|
This plugin follows the [WordPress CSS Coding Standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/css/).
|
||||||
|
|
||||||
|
### Naming Conventions
|
||||||
|
|
||||||
|
- Use lowercase for selectors
|
||||||
|
- Use hyphens to separate words in class and ID names
|
||||||
|
- Prefix classes and IDs with the plugin's prefix
|
||||||
|
|
||||||
|
```css
|
||||||
|
.wpst-container {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#wpst-header {
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Indentation and Formatting
|
||||||
|
|
||||||
|
- Use 4 spaces for indentation (not tabs)
|
||||||
|
- Each property should be on its own line
|
||||||
|
- Include a space after the colon in property declarations
|
||||||
|
- End each declaration with a semicolon
|
||||||
|
- Use single quotes for attribute selectors and property values
|
||||||
|
|
||||||
|
```css
|
||||||
|
.wpst-container {
|
||||||
|
margin: 0;
|
||||||
|
padding: 10px;
|
||||||
|
font-family: 'Helvetica', sans-serif;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Automated Code Checking
|
||||||
|
|
||||||
|
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
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **PHP Code Beautifier and Fixer (PHPCBF)**: Automatically fixes some coding standard violations
|
||||||
|
```bash
|
||||||
|
composer run phpcbf
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **ESLint**: Checks JavaScript code against the WordPress Coding Standards
|
||||||
|
```bash
|
||||||
|
npm run lint:js
|
||||||
|
```
|
||||||
|
|
||||||
|
4. **Stylelint**: Checks CSS code against the WordPress Coding Standards
|
||||||
|
```bash
|
||||||
|
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.
|
||||||
180
wiki/Contributing.md
Normal file
180
wiki/Contributing.md
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
# Contributing
|
||||||
|
|
||||||
|
Thank you for considering contributing to this project! This document provides guidelines and instructions for contributing.
|
||||||
|
|
||||||
|
## Code of Conduct
|
||||||
|
|
||||||
|
By participating in this project, you agree to abide by our code of conduct:
|
||||||
|
|
||||||
|
- Be respectful and inclusive
|
||||||
|
- Be patient and welcoming
|
||||||
|
- Be considerate
|
||||||
|
- Be collaborative
|
||||||
|
- Be open-minded
|
||||||
|
|
||||||
|
## How to Contribute
|
||||||
|
|
||||||
|
### Reporting Bugs
|
||||||
|
|
||||||
|
If you find a bug, please report it by creating an issue on GitHub:
|
||||||
|
|
||||||
|
1. Go to the [Issues](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/issues) page
|
||||||
|
2. Click "New Issue"
|
||||||
|
3. Select "Bug Report"
|
||||||
|
4. Fill out the template with as much detail as possible
|
||||||
|
5. Submit the issue
|
||||||
|
|
||||||
|
Please include:
|
||||||
|
|
||||||
|
- A clear, descriptive title
|
||||||
|
- Steps to reproduce the bug
|
||||||
|
- Expected behavior
|
||||||
|
- Actual behavior
|
||||||
|
- Screenshots (if applicable)
|
||||||
|
- Your environment (WordPress version, PHP version, browser, etc.)
|
||||||
|
|
||||||
|
### Suggesting Enhancements
|
||||||
|
|
||||||
|
If you have an idea for an enhancement:
|
||||||
|
|
||||||
|
1. Go to the [Issues](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/issues) page
|
||||||
|
2. Click "New Issue"
|
||||||
|
3. Select "Feature Request"
|
||||||
|
4. Fill out the template with as much detail as possible
|
||||||
|
5. Submit the issue
|
||||||
|
|
||||||
|
Please include:
|
||||||
|
|
||||||
|
- A clear, descriptive title
|
||||||
|
- A detailed description of the enhancement
|
||||||
|
- Why this enhancement would be useful
|
||||||
|
- Any relevant examples or mockups
|
||||||
|
|
||||||
|
### Pull Requests
|
||||||
|
|
||||||
|
If you want to contribute code:
|
||||||
|
|
||||||
|
1. Fork the repository
|
||||||
|
2. Create a new branch for your feature or bugfix
|
||||||
|
3. Make your changes
|
||||||
|
4. Run tests to ensure your changes don't break anything
|
||||||
|
5. Submit a pull request
|
||||||
|
|
||||||
|
#### Pull Request Process
|
||||||
|
|
||||||
|
1. Fork the repository on [GitHub](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/) or [Gitea](https://gitea.wpallstars.com/wpallstars/wp-plugin-starter-template-for-ai-coding/)
|
||||||
|
2. Clone your fork: `git clone https://github.com/YOUR-USERNAME/wp-plugin-starter-template-for-ai-coding.git`
|
||||||
|
3. Create your feature branch: `git checkout -b feature/amazing-feature`
|
||||||
|
4. Make your changes
|
||||||
|
5. Commit your changes: `git commit -m 'Add some amazing feature'`
|
||||||
|
6. Push to the branch: `git push origin feature/amazing-feature`
|
||||||
|
7. Submit a pull request
|
||||||
|
|
||||||
|
#### Pull Request Guidelines
|
||||||
|
|
||||||
|
- Follow the coding standards (see [Coding Standards](Coding-Standards))
|
||||||
|
- Write tests for your changes
|
||||||
|
- Update documentation as needed
|
||||||
|
- 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
|
||||||
|
|
||||||
|
To set up your development environment:
|
||||||
|
|
||||||
|
1. Clone the repository: `git clone https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding.git`
|
||||||
|
2. Install dependencies: `composer install && npm install`
|
||||||
|
3. Start the development environment: `npm run start`
|
||||||
|
|
||||||
|
### Testing
|
||||||
|
|
||||||
|
Before submitting a pull request, make sure to run the tests:
|
||||||
|
|
||||||
|
- PHP Unit Tests: `npm run test:php`
|
||||||
|
- 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:
|
||||||
|
|
||||||
|
- Update the README.md file if necessary
|
||||||
|
- Update the readme.txt file if necessary
|
||||||
|
- Update or create wiki pages as needed
|
||||||
|
- Update code comments
|
||||||
|
|
||||||
|
## Community
|
||||||
|
|
||||||
|
Join our community to discuss the project:
|
||||||
|
|
||||||
|
- [GitHub Discussions](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/discussions)
|
||||||
|
- [Gitea Issues](https://gitea.wpallstars.com/wpallstars/wp-plugin-starter-template-for-ai-coding/issues)
|
||||||
|
|
||||||
|
## Recognition
|
||||||
|
|
||||||
|
Contributors will be recognized in the following ways:
|
||||||
|
|
||||||
|
- Added to the contributors list in readme.txt
|
||||||
|
- Mentioned in release notes for significant contributions
|
||||||
|
- Thanked in the Changelog for specific contributions
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
By contributing to this project, you agree that your contributions will be licensed under the project's [GPL-2.0+ License](https://www.gnu.org/licenses/gpl-2.0.html).
|
||||||
|
|
||||||
|
## Questions?
|
||||||
|
|
||||||
|
If you have any questions about contributing, please open an issue or contact the maintainers.
|
||||||
|
|
||||||
|
Thank you for your contributions!
|
||||||
Reference in New Issue
Block a user