From 398d24ed90f965e5a540bb23216ea43d983b3f60 Mon Sep 17 00:00:00 2001 From: marcusquinn <6428977+marcusquinn@users.noreply.github.com> Date: Mon, 21 Apr 2025 14:57:19 +0100 Subject: [PATCH] Fix code quality issues - Fix phpstan.neon file structure - Fix Markdown formatting in docs/code-quality-setup.md - Add proper language specifier to .env code block in README.md - Add blank lines around code blocks in README.md - Add newline at end of GitHub workflow file --- .github/workflows/code-quality.yml | 2 +- README.md | 11 ++++++++++- docs/code-quality-setup.md | 2 ++ phpstan.neon | 6 +++--- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index 302ad02..e595b55 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -149,4 +149,4 @@ jobs: uses: github/codeql-action/upload-sarif@v3 with: sarif_file: results.sarif - continue-on-error: true \ No newline at end of file + continue-on-error: true diff --git a/README.md b/README.md index 03a4a80..69001dd 100644 --- a/README.md +++ b/README.md @@ -333,31 +333,37 @@ For code quality tools like SonarCloud, organization secrets are recommended if To run code quality tools locally before committing to GitHub: 1. **Install dependencies**: + ```bash composer install ``` 2. **Run PHP CodeSniffer**: + ```bash composer phpcs ``` 3. **Fix coding standards automatically**: + ```bash composer phpcbf ``` 4. **Run PHPStan static analysis**: + ```bash composer phpstan ``` 5. **Run PHP Mess Detector**: + ```bash composer phpmd ``` 6. **Run all linters at once**: + ```bash composer lint ``` @@ -386,19 +392,21 @@ To run code quality tools locally before committing to GitHub: 8. **Create a .env file** (alternative approach): - ```bash + ```env # .env (already included in .gitignore to prevent committing secrets) SONAR_TOKEN=your_sonar_token CODACY_PROJECT_TOKEN=your_codacy_token ``` Then load these variables: + ```bash # Using a tool like dotenv source .env ``` 9. **Run SonarCloud locally**: + ```bash # Install SonarScanner npm install -g sonarqube-scanner @@ -413,6 +421,7 @@ To run code quality tools locally before committing to GitHub: ``` 10. **Run Codacy locally**: + ```bash # Install Codacy CLI npm install -g codacy-coverage diff --git a/docs/code-quality-setup.md b/docs/code-quality-setup.md index 443ed51..167d185 100644 --- a/docs/code-quality-setup.md +++ b/docs/code-quality-setup.md @@ -10,12 +10,14 @@ This document explains how to set up and use the code quality tools for this pro ## Installation 1. Clone the repository: + ```bash git clone https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding.git cd wp-plugin-starter-template-for-ai-coding ``` 2. Install dependencies: + ```bash composer install ``` diff --git a/phpstan.neon b/phpstan.neon index dbfd063..07a5cbe 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -16,10 +16,10 @@ parameters: - '#Function apply_filters invoked with [0-9]+ parameters, 2 required.#' - '#Function [a-zA-Z0-9_]+ not found.#' - '#Call to static method [a-zA-Z0-9_:()]+ on an unknown class [a-zA-Z0-9_]+.#' - -includes: - - vendor/szepeviktor/phpstan-wordpress/extension.neon - '#Function do_action invoked with [0-9]+ parameters, 1 required.#' - '#Function add_action invoked with [0-9]+ parameters, 2 required.#' - '#Function add_filter invoked with [0-9]+ parameters, 2 required.#' reportUnmatchedIgnoredErrors: false + +includes: + - vendor/szepeviktor/phpstan-wordpress/extension.neon