Skip to content

Commit fadddd0

Browse files
Amoifrclaude
andcommitted
Add configurable thresholds and Symfony Profiler integration
- Add threshold configuration via config/packages/php_quality.yaml - Add Symfony Profiler DataCollector for request-time analysis - Add ThresholdsConfig DTO with framework defaults merging - Add Symfony Flex recipe for automatic configuration - Add CHANGELOG.md with full version history Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent aefbab8 commit fadddd0

12 files changed

Lines changed: 756 additions & 1 deletion

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Enable Profiler integration in development environment
2+
php_quality:
3+
profiler:
4+
enabled: true
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
php_quality:
2+
# Report language (en, fr, es, de, etc.)
3+
default_lang: '%kernel.default_locale%'
4+
5+
# Quality thresholds (null = use framework-specific defaults)
6+
thresholds:
7+
ccn: ~ # Maximum cyclomatic complexity (default: 10)
8+
lcom: ~ # Maximum lack of cohesion (default: 0.8)
9+
mi: ~ # Minimum maintainability index (default: 20)
10+
11+
# Symfony Profiler integration
12+
profiler:
13+
enabled: false
14+
exclude_paths:
15+
- 'vendor/'
16+
- 'var/'
17+
- 'cache/'
18+
- 'tests/'
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"bundles": {
3+
"PhpQuality\\PhpQualityBundle": ["all"]
4+
},
5+
"copy-from-recipe": {
6+
"config/": "%CONFIG_DIR%/"
7+
}
8+
}

CHANGELOG.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
## [1.5.0] - 2026-03-26
11+
12+
### Added
13+
- Configuration file support for quality thresholds via `config/packages/php_quality.yaml`
14+
- Symfony Profiler integration with dedicated panel showing metrics for files loaded during request
15+
- `ThresholdsConfig` DTO for threshold management with framework defaults merging
16+
- Symfony Flex recipe for automatic bundle configuration on install
17+
- Development environment config enabling profiler by default
18+
19+
### Changed
20+
- Thresholds can now be overridden per-project while keeping framework-specific defaults for non-configured values
21+
22+
## [1.4.1] - 2026-03-26
23+
24+
### Fixed
25+
- Memory limit handling for large project analysis
26+
27+
## [1.4.0] - 2026-03-26
28+
29+
### Added
30+
- Multi-architecture Docker build support (amd64 + arm64)
31+
32+
### Fixed
33+
- Docker build with correct package name
34+
35+
## [1.3.0] - 2026-03-25
36+
37+
### Added
38+
- Interactive wizard mode for command configuration (`--wizard` or `-w` option)
39+
40+
## [1.2.2] - 2026-03-25
41+
42+
### Fixed
43+
- JSON report generation with proper error handling
44+
45+
## [1.2.1] - 2026-03-25
46+
47+
### Fixed
48+
- Twig template paths to use bundle namespace
49+
50+
## [1.2.0] - 2026-03-25
51+
52+
### Added
53+
- Symfony Bundle architecture (package renamed to `amoifr/phpquality-bundle`)
54+
- README translated to English
55+
56+
### Changed
57+
- Refactored entire codebase to Symfony Bundle structure
58+
- Package renamed from standalone tool to Symfony bundle
59+
60+
## [1.1.0] - 2026-03-25
61+
62+
### Added
63+
- Code Coverage Analysis feature from Clover XML reports (`--coverage` option)
64+
- Architecture Analysis inspired by Deptrac/PHP Insights (layer detection, SOLID principles)
65+
- Hall of Fame/Shame feature using git blame (`--git-blame` option)
66+
- Comprehensive PHPUnit test suite
67+
- Translations for coverage and recommendations sections
68+
- 17 language translations for reports
69+
70+
### Changed
71+
- Git blame analysis now optional (disabled by default)
72+
73+
### Fixed
74+
- Docker Hub image name to `amoifr13/phpquality`
75+
76+
## [1.0.0] - 2026-03-19
77+
78+
### Added
79+
- Initial release of PhpQuality PHP Code Analyzer
80+
- Cyclomatic Complexity (CCN) analysis per method and file
81+
- Maintainability Index (MI) calculation with ratings (A-F)
82+
- Lines of Code metrics (LOC, LLOC, CLOC, comment ratio)
83+
- Halstead metrics (Volume, Difficulty, Effort, Bugs)
84+
- Lack of Cohesion of Methods (LCOM) analysis
85+
- HTML report generation with interactive charts
86+
- Console report output with tables and summaries
87+
- Multiple project type detection (Symfony, Laravel, WordPress, Magento, Drupal, etc.)
88+
- Docker support for containerized analysis
89+
- GitHub Actions workflow for Docker image publishing
90+
91+
### Fixed
92+
- Allow running Docker container with any user (`--user` flag)
93+
94+
[Unreleased]: https://github.com/amoifr/PhpQuality/compare/v1.5.0...HEAD
95+
[1.5.0]: https://github.com/amoifr/PhpQuality/compare/v1.4.1...v1.5.0
96+
[1.4.1]: https://github.com/amoifr/PhpQuality/compare/v1.4.0...v1.4.1
97+
[1.4.0]: https://github.com/amoifr/PhpQuality/compare/1.3.0...v1.4.0
98+
[1.3.0]: https://github.com/amoifr/PhpQuality/compare/1.2.2...1.3.0
99+
[1.2.2]: https://github.com/amoifr/PhpQuality/compare/1.2.1...1.2.2
100+
[1.2.1]: https://github.com/amoifr/PhpQuality/compare/v1.2.0...1.2.1
101+
[1.2.0]: https://github.com/amoifr/PhpQuality/compare/v1.1.0...v1.2.0
102+
[1.1.0]: https://github.com/amoifr/PhpQuality/compare/v1.0.0...v1.1.0
103+
[1.0.0]: https://github.com/amoifr/PhpQuality/releases/tag/v1.0.0

docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ FROM php:8.3-cli-alpine
3838

3939
LABEL org.opencontainers.image.title="PhpQuality"
4040
LABEL org.opencontainers.image.description="PHP Static Code Analyzer - Metrics & Quality Reports"
41-
LABEL org.opencontainers.image.version="1.4.1"
41+
LABEL org.opencontainers.image.version="1.5.0"
4242
LABEL org.opencontainers.image.vendor="amoifr"
4343
LABEL org.opencontainers.image.source="https://github.com/amoifr/PhpQuality"
4444
LABEL org.opencontainers.image.authors="Pascal CESCON <pascal.cescon@gmail.com>"

src/Config/ThresholdsConfig.php

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace PhpQuality\Config;
6+
7+
readonly class ThresholdsConfig
8+
{
9+
public function __construct(
10+
public ?int $ccn = null,
11+
public ?float $lcom = null,
12+
public ?int $mi = null,
13+
) {}
14+
15+
/**
16+
* Merge configured thresholds with framework defaults.
17+
* Configured values take priority over framework defaults.
18+
*
19+
* @param array{ccn: int, lcom: float, mi: int} $frameworkThresholds
20+
* @return array{ccn: int, lcom: float, mi: int}
21+
*/
22+
public function merge(array $frameworkThresholds): array
23+
{
24+
return [
25+
'ccn' => $this->ccn ?? $frameworkThresholds['ccn'],
26+
'lcom' => $this->lcom ?? $frameworkThresholds['lcom'],
27+
'mi' => $this->mi ?? $frameworkThresholds['mi'],
28+
];
29+
}
30+
31+
/**
32+
* Check if any threshold is configured.
33+
*/
34+
public function hasOverrides(): bool
35+
{
36+
return $this->ccn !== null || $this->lcom !== null || $this->mi !== null;
37+
}
38+
39+
/**
40+
* Create from configuration array.
41+
*
42+
* @param array{ccn?: int|null, lcom?: float|null, mi?: int|null} $config
43+
*/
44+
public static function fromArray(array $config): self
45+
{
46+
return new self(
47+
ccn: $config['ccn'] ?? null,
48+
lcom: $config['lcom'] ?? null,
49+
mi: $config['mi'] ?? null,
50+
);
51+
}
52+
}

0 commit comments

Comments
 (0)