Merge pull request #11 from wpallstars/fix-code-quality-issues

Fix code quality issues from PR feedback
This commit is contained in:
2025-04-21 04:45:41 +01:00
committed by GitHub
12 changed files with 143 additions and 106 deletions

View File

@@ -99,8 +99,8 @@ When you receive feedback from these code review tools, you can use AI assistant
1. Copy the output from the code review tool 1. Copy the output from the code review tool
2. Paste it into your AI assistant chat 2. Paste it into your AI assistant chat
3. Ask the AI to help you understand and fix the issues 3. Ask the AI to help you understand and resolve the issues
4. Implement the suggested fixes 4. Apply the suggested fixes
5. Commit the changes and verify that the issues are resolved 5. Commit the changes and verify that the issues are resolved
### Markdown Formatting Standards ### Markdown Formatting Standards
@@ -115,8 +115,8 @@ When writing or updating Markdown files in this project, follow these standards:
Example prompt for AI assistants: Example prompt for AI assistants:
``` ```text
I received the following feedback from [Tool Name]. Please help me understand these issues and suggest fixes: I received the following feedback from [Tool Name]. Please help me understand and resolve these issues:
[Paste the tool output here] [Paste the tool output here]
``` ```
@@ -192,7 +192,7 @@ After the code has been updated:
### Good Feedback Example ### Good Feedback Example
``` ```markdown
In function `handle_remove_reference()`: In function `handle_remove_reference()`:
1. The nonce check is missing, which could lead to CSRF vulnerabilities. 1. The nonce check is missing, which could lead to CSRF vulnerabilities.
@@ -225,6 +225,6 @@ In function `handle_remove_reference()`:
### Poor Feedback Example ### Poor Feedback Example
``` ```text
This code has security issues and doesn't follow best practices. Fix it. This code has security issues and doesn't follow best practices. Fix it.
``` ```

13
.codacy.yml Normal file
View File

@@ -0,0 +1,13 @@
---
engines:
markdownlint:
enabled: true
config_file: .markdownlint.json
exclude_paths:
- "vendor/**"
- "node_modules/**"
- "build/**"
- "dist/**"
- "bin/**"
- ".github/**"
- "tests/**"

View File

@@ -36,44 +36,8 @@ jobs:
composer run phpcbf -- --dry-run composer run phpcbf -- --dry-run
continue-on-error: true continue-on-error: true
sonarcloud: # SonarCloud job temporarily removed due to Java version compatibility issues
name: SonarCloud Analysis # Will be re-added in a future PR with proper configuration
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: SonarCloud Scan # Codacy job temporarily removed due to GitHub Actions compatibility issues
uses: SonarSource/sonarcloud-github-action@master # Will be re-added in a future PR with proper configuration
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
codacy:
name: Codacy Analysis
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Run Codacy Analysis CLI
uses: codacy/codacy-analysis-cli-action@master
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
verbose: true
output: results.sarif
format: sarif
# Adjust the below patterns based on your project structure
gh-code-scanning-compat: true
max-allowed-issues: 2147483647
continue-on-error: true
- name: Upload SARIF results file
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: results.sarif
continue-on-error: true

15
.markdownlint.json Normal file
View File

@@ -0,0 +1,15 @@
{
"MD004": {
"style": "asterisk"
},
"MD007": {
"indent": 2
},
"MD013": false,
"MD033": false,
"MD040": true,
"MD041": false,
"MD046": {
"style": "fenced"
}
}

16
.markdownlintrc Normal file
View File

@@ -0,0 +1,16 @@
{
"default": true,
"MD004": {
"style": "asterisk"
},
"MD007": {
"indent": 2
},
"MD013": false,
"MD033": false,
"MD040": true,
"MD041": false,
"MD046": {
"style": "fenced"
}
}

View File

@@ -271,8 +271,14 @@ To ensure your code passes the quality checks from these tools, follow these gui
3. **Using AI Assistants with Code Quality Tools** 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 * 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 * 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 * Ask the AI to help you understand and resolve 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]" * Example prompt:
```text
I received the following feedback from [Tool Name]. Please help me understand and resolve these issues:
[Paste the tool output here]
```
4. **Iterative Improvement** 4. **Iterative Improvement**
* Address issues one at a time, starting with the most critical * Address issues one at a time, starting with the most critical

View File

@@ -106,14 +106,14 @@ When you receive feedback from these code quality tools, you can use AI assistan
1. Copy the output from the code quality tool 1. Copy the output from the code quality tool
2. Paste it into your AI assistant chat 2. Paste it into your AI assistant chat
3. Ask the AI to help you understand and fix the issues 3. Ask the AI to help you understand and resolve the issues
4. Implement the suggested fixes 4. Apply the suggested fixes
5. Commit the changes and verify that the issues are resolved 5. Commit the changes and verify that the issues are resolved
Example prompt for AI assistants: Example prompt for AI assistants:
``` ```text
I received the following feedback from [Tool Name]. Please help me understand these issues and suggest fixes: I received the following feedback from [Tool Name]. Please help me understand and resolve these issues:
[Paste the tool output here] [Paste the tool output here]
``` ```
@@ -130,18 +130,18 @@ To set up your development environment:
Before submitting a pull request, make sure to run the tests: Before submitting a pull request, make sure to run the tests:
- PHP Unit Tests: `npm run test:php` * PHP Unit Tests: `npm run test:php`
- 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 #### Code Quality Checks
To ensure your code meets the quality standards, run these commands before submitting a pull request: To ensure your code meets the quality standards, run these commands before submitting a pull request:
- Check coding standards: `composer run phpcs` * Check coding standards: `composer run phpcs`
- Fix coding standards automatically: `composer run phpcbf` * Fix coding standards automatically: `composer run phpcbf`
- Check JavaScript coding standards: `npm run lint:js` * Check JavaScript coding standards: `npm run lint:js`
- Check CSS coding standards: `npm run lint:css` * 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. These checks will help identify and fix issues before they are caught by the automated code quality tools in the pull request process.
@@ -149,25 +149,25 @@ These checks will help identify and fix issues before they are caught by the aut
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:
- Update the README.md file if necessary * Update the README.md file if necessary
- Update the readme.txt file if necessary * Update the readme.txt file if necessary
- Update or create wiki pages as needed * Update or create wiki pages as needed
- Update code comments * Update code comments
## Community ## Community
Join our community to discuss the project: Join our community to discuss the project:
- [GitHub Discussions](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/discussions) * [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) * [Gitea Issues](https://gitea.wpallstars.com/wpallstars/wp-plugin-starter-template-for-ai-coding/issues)
## Recognition ## Recognition
Contributors will be recognized in the following ways: Contributors will be recognized in the following ways:
- Added to the contributors list in readme.txt * Added to the contributors list in readme.txt
- Mentioned in release notes for significant contributions * Mentioned in release notes for significant contributions
- Thanked in the Changelog for specific contributions * Thanked in the Changelog for specific contributions
## License ## License

View File

@@ -242,20 +242,20 @@ For more detailed information, see the [Contributing Guide](.wiki/Contributing.m
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: 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 1. **CodeRabbit**: AI-powered code review tool
- [Website](https://www.coderabbit.ai/) * [Website](https://www.coderabbit.ai/)
- Provides automated feedback on pull requests * Provides automated feedback on pull requests
2. **CodeFactor**: Continuous code quality monitoring 2. **CodeFactor**: Continuous code quality monitoring
- [Website](https://www.codefactor.io/) * [Website](https://www.codefactor.io/)
- Provides a grade for your codebase * Provides a grade for your codebase
3. **Codacy**: Code quality and static analysis 3. **Codacy**: Code quality and static analysis
- [Website](https://www.codacy.com/) * [Website](https://www.codacy.com/)
- Identifies issues related to code style, security, and performance * Identifies issues related to code style, security, and performance
4. **SonarCloud**: Code quality and security analysis 4. **SonarCloud**: Code quality and security analysis
- [Website](https://sonarcloud.io/) * [Website](https://sonarcloud.io/)
- Provides detailed analysis of code quality and security * Provides detailed analysis of code quality and security
### Using AI Assistants with Code Quality Tools ### Using AI Assistants with Code Quality Tools
@@ -263,8 +263,8 @@ When you receive feedback from these code quality tools, you can use AI assistan
1. Copy the output from the code quality tool 1. Copy the output from the code quality tool
2. Paste it into your AI assistant chat 2. Paste it into your AI assistant chat
3. Ask the AI to help you understand and fix the issues 3. Ask the AI to help you understand and resolve the issues
4. Implement the suggested fixes 4. Apply the suggested fixes
5. Commit the changes and verify that the issues are resolved 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). For more information on coding standards and how to pass code quality checks, see the [Coding Standards Guide](.wiki/Coding-Standards.md).

View File

@@ -139,10 +139,10 @@ For more detailed information, see the [Contributing Guide](https://github.com/w
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: 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 1. **[CodeRabbit](https://www.coderabbit.ai/)**: 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 2. **[CodeFactor](https://www.codefactor.io/)**: 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 3. **[Codacy](https://www.codacy.com/)**: 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 4. **[SonarCloud](https://sonarcloud.io/)**: Code quality and security analysis that provides detailed analysis of code quality and security
= Using AI Assistants with Code Quality Tools = = Using AI Assistants with Code Quality Tools =
@@ -150,8 +150,8 @@ When you receive feedback from these code quality tools, you can use AI assistan
1. Copy the output from the code quality tool 1. Copy the output from the code quality tool
2. Paste it into your AI assistant chat 2. Paste it into your AI assistant chat
3. Ask the AI to help you understand and fix the issues 3. Ask the AI to help you understand and resolve the issues
4. Implement the suggested fixes 4. Apply the suggested fixes
5. Commit the changes and verify that the issues are resolved 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. 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.

17
sonar-project.properties Normal file
View File

@@ -0,0 +1,17 @@
sonar.projectKey=wpallstars_wp-plugin-starter-template-for-ai-coding
sonar.organization=wpallstars
# This is the name and version displayed in the SonarCloud UI.
sonar.projectName=wp-plugin-starter-template-for-ai-coding
sonar.projectVersion=0.1.10
# Path is relative to the sonar-project.properties file
sonar.sources=.
sonar.php.coverage.reportPaths=coverage.xml
sonar.php.tests.reportPath=test-report.xml
# Encoding of the source code. Default is default system encoding
sonar.sourceEncoding=UTF-8
# Exclude directories
sonar.exclusions=vendor/**,node_modules/**,tests/**,bin/**,build/**,dist/**

View File

@@ -271,8 +271,14 @@ To ensure your code passes the quality checks from these tools, follow these gui
3. **Using AI Assistants with Code Quality Tools** 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 * 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 * 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 * Ask the AI to help you understand and resolve 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]" * Example prompt:
```text
I received the following feedback from [Tool Name]. Please help me understand and resolve these issues:
[Paste the tool output here]
```
4. **Iterative Improvement** 4. **Iterative Improvement**
* Address issues one at a time, starting with the most critical * Address issues one at a time, starting with the most critical

View File

@@ -106,14 +106,14 @@ When you receive feedback from these code quality tools, you can use AI assistan
1. Copy the output from the code quality tool 1. Copy the output from the code quality tool
2. Paste it into your AI assistant chat 2. Paste it into your AI assistant chat
3. Ask the AI to help you understand and fix the issues 3. Ask the AI to help you understand and resolve the issues
4. Implement the suggested fixes 4. Apply the suggested fixes
5. Commit the changes and verify that the issues are resolved 5. Commit the changes and verify that the issues are resolved
Example prompt for AI assistants: Example prompt for AI assistants:
``` ```text
I received the following feedback from [Tool Name]. Please help me understand these issues and suggest fixes: I received the following feedback from [Tool Name]. Please help me understand and resolve these issues:
[Paste the tool output here] [Paste the tool output here]
``` ```
@@ -130,18 +130,18 @@ To set up your development environment:
Before submitting a pull request, make sure to run the tests: Before submitting a pull request, make sure to run the tests:
- PHP Unit Tests: `npm run test:php` * PHP Unit Tests: `npm run test:php`
- 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 #### Code Quality Checks
To ensure your code meets the quality standards, run these commands before submitting a pull request: To ensure your code meets the quality standards, run these commands before submitting a pull request:
- Check coding standards: `composer run phpcs` * Check coding standards: `composer run phpcs`
- Fix coding standards automatically: `composer run phpcbf` * Fix coding standards automatically: `composer run phpcbf`
- Check JavaScript coding standards: `npm run lint:js` * Check JavaScript coding standards: `npm run lint:js`
- Check CSS coding standards: `npm run lint:css` * 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. These checks will help identify and fix issues before they are caught by the automated code quality tools in the pull request process.
@@ -149,25 +149,25 @@ These checks will help identify and fix issues before they are caught by the aut
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:
- Update the README.md file if necessary * Update the README.md file if necessary
- Update the readme.txt file if necessary * Update the readme.txt file if necessary
- Update or create wiki pages as needed * Update or create wiki pages as needed
- Update code comments * Update code comments
## Community ## Community
Join our community to discuss the project: Join our community to discuss the project:
- [GitHub Discussions](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/discussions) * [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) * [Gitea Issues](https://gitea.wpallstars.com/wpallstars/wp-plugin-starter-template-for-ai-coding/issues)
## Recognition ## Recognition
Contributors will be recognized in the following ways: Contributors will be recognized in the following ways:
- Added to the contributors list in readme.txt * Added to the contributors list in readme.txt
- Mentioned in release notes for significant contributions * Mentioned in release notes for significant contributions
- Thanked in the Changelog for specific contributions * Thanked in the Changelog for specific contributions
## License ## License