Files
wp-plugin-starter-template-…/docs/code-quality-setup.md
marcusquinn 398d24ed90 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
2025-04-21 14:57:19 +01:00

1.9 KiB

Code Quality Tools Setup

This document explains how to set up and use the code quality tools for this project.

Prerequisites

  • PHP 7.4 or higher
  • Composer

Installation

  1. Clone the repository:

    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:

    composer install
    

Available Tools

PHP CodeSniffer (PHPCS)

PHPCS checks your code against the WordPress Coding Standards.

# Run PHPCS
composer phpcs

# Run PHPCS with a simplified ruleset
composer phpcs:simple

PHP Code Beautifier and Fixer (PHPCBF)

PHPCBF automatically fixes coding standard violations.

# Run PHPCBF to fix coding standard violations
composer phpcbf

# Run PHPCBF with a simplified ruleset
composer phpcbf:simple

PHPStan

PHPStan performs static analysis to find bugs in your code.

# Run PHPStan
composer phpstan

PHP Mess Detector (PHPMD)

PHPMD detects potential problems in your code.

# Run PHPMD
composer phpmd

Running All Linters

# Run all linters (PHPCS, PHPStan, PHPMD)
composer lint

Running All Fixers

# Run all fixers (PHPCBF)
composer fix

Environment Variables

For SonarCloud and Codacy integration, you need to set up the following environment variables:

SonarCloud

export SONAR_TOKEN=your_sonar_token

Codacy

export CODACY_PROJECT_TOKEN=your_codacy_token

CI/CD Integration

The project includes GitHub Actions workflows for running these tools automatically on each push and pull request. See the .github/workflows/code-quality.yml file for details.

Customization

  • PHPCS rules can be customized in phpcs.xml
  • PHPStan configuration is in phpstan.neon
  • SonarCloud configuration is in sonar-project.properties