VOOZH about

URL: https://deepwiki.com/WordPress/mcp-adapter/7.2-code-quality

⇱ Code Quality | WordPress/mcp-adapter | DeepWiki


Loading...
Menu

Code Quality

This document covers the code quality standards, tools, and processes used in the MCP Adapter plugin. It provides detailed information about static analysis configuration, code style enforcement, and quality assurance workflows that ensure consistent, maintainable code across the project.

For information about running tests, see Testing. For details about the CI/CD pipeline that enforces these standards, see CI/CD Pipeline.

Code Quality Overview

The MCP Adapter plugin implements a comprehensive code quality strategy using multiple automated tools that enforce WordPress coding standards, perform static analysis, and maintain consistent code formatting. The quality assurance process is integrated into both local development workflows and continuous integration pipelines.

Quality Assurance Tools Architecture


Sources: phpstan.neon.dist1-36 phpcs.xml.dist1-223 CONTRIBUTING.md84-96

Static Analysis with PHPStan

PHPStan performs comprehensive static analysis to detect type errors, undefined variables, and other potential issues before runtime. The configuration enforces the highest analysis level with strict type checking.

PHPStan Configuration

The static analysis is configured through phpstan.neon.dist with the following key settings:

ConfigurationValuePurpose
Level8Highest strictness level
PHP Version7.4-8.4Compatibility range
Bootstrap Filemcp-adapter.phpPlugin entry point
Scan Pathssrc/Source code analysis
External Dependencies../abilities-apiWordPress Abilities API

Static Analysis Rules


Sources: phpstan.neon.dist3-13 phpstan.neon.dist15-31

Code Style Enforcement with PHPCS

PHP CodeSniffer enforces WordPress coding standards along with additional modern PHP practices through multiple rulesets and custom configurations.

PHPCS Ruleset Configuration

The code style enforcement uses a layered approach with multiple rulesets:

RulesetPurposeKey Features
WordPress-VIP-GoVIP hosting complianceSecurity and performance rules
WordPress-ExtraWordPress coding standardsWordPress-specific conventions
PHPCompatibilityWPPHP version compatibilityCross-version compatibility checks
SlevomatCodingStandardModern PHP practicesType hints, arrays, control structures
PluginCheckPlugin-specific rulesWordPress plugin guidelines

Code Style Rules Hierarchy


Sources: phpcs.xml.dist40-50 phpcs.xml.dist57-76 phpcs.xml.dist112-187

Development Workflow Commands

The quality assurance tools are integrated into the development workflow through NPM scripts that provide consistent interfaces for all quality checks.

Quality Assurance Commands

CommandToolPurposeConfiguration
npm run lint:phpPHPCSCheck code style violationsphpcs.xml.dist
npm run lint:php:fixPHPCSAuto-fix style violationsphpcs.xml.dist
npm run formatPrettierFormat non-PHP filespackage.json
npm run test:phpPHPUnitRun unit testsphpunit.xml

Quality Check Integration


Sources: CONTRIBUTING.md84-96 phpcs.xml.dist23-36

Configuration File Details

PHPStan Configuration Structure

The phpstan.neon.dist file defines comprehensive static analysis parameters:


PHPCS Exclusions and Customizations

The code style configuration includes specific exclusions for modern PHP development:

ExclusionReasonImpact
WordPress.Files.FileNamePSR-4 naming conventionAllows modern class naming
WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedNamespaceFoundNamespace usageEnables proper namespacing
Universal.Operators.DisallowShortTernaryModern PHP syntaxAllows ?: operator
Generic.CodeAnalysis.UnusedFunctionParameterInterface implementationsPermits unused params in interfaces

Sources: phpstan.neon.dist15-31 phpcs.xml.dist63-76

Quality Metrics and Enforcement

The code quality system enforces specific metrics and thresholds to maintain consistent code standards across the project.

Static Analysis Metrics


Sources: phpstan.neon.dist3-13 CONTRIBUTING.md98-106 phpcs.xml.dist57-82