-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6a242e4
Showing
58 changed files
with
2,105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_size = 4 | ||
indent_style = space | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[*.yaml] | ||
indent_size = 2 | ||
|
||
[Makefile] | ||
indent_style = tab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Directories to ignore for export | ||
/.github export-ignore | ||
/tests export-ignore | ||
|
||
# Files to ignore for export | ||
.editorconfig export-ignore | ||
.gitattributes export-ignore | ||
.gitignore export-ignore | ||
Makefile export-ignore | ||
panaly.dist.yaml export-ignore | ||
phpcs.xml.dist export-ignore | ||
phpstan.neon export-ignore | ||
phpunit.xml export-ignore | ||
README.md export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "composer" | ||
directory: "/" | ||
schedule: | ||
interval: "monthly" | ||
versioning-strategy: "increase-if-necessary" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: CI | ||
|
||
on: | ||
pull_request: ~ | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
ci: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
php: [ '8.3' ] | ||
|
||
name: PHP ${{ matrix.php }} | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
|
||
- uses: "ramsey/composer-install@v1" | ||
with: | ||
composer-options: ${{ matrix.composer-options }} | ||
|
||
- name: Linting PHP | ||
run: make lint-php | ||
continue-on-error: ${{ matrix.experimental }} | ||
|
||
- name: PHPCS Code Style Check | ||
run: make check-cs | ||
continue-on-error: ${{ matrix.experimental }} | ||
|
||
- name: PHPStan Static Analyses | ||
run: make static-analysis | ||
continue-on-error: ${{ matrix.experimental }} | ||
|
||
- name: PHPUnit | ||
run: make phpunit | ||
continue-on-error: ${{ matrix.experimental }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/.phpunit.cache/ | ||
/vendor/ | ||
.phpcs-cache | ||
.project-analyzer-cache | ||
composer.lock | ||
metric_storage.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Denis Zunke | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
.PHONY: * | ||
|
||
OPTS= | ||
|
||
help: | ||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' | ||
|
||
check-cs: ## check coding standards | ||
vendor/bin/phpcs -n | ||
|
||
fix-cs: ## auto-fix coding standards | ||
vendor/bin/phpcbf -n | ||
|
||
static-analysis: ## runs static analysis | ||
vendor/bin/phpstan analyse -c phpstan.neon | ||
|
||
lint-php: ## linting php files | ||
if find src -name "*.php" -exec php -l {} \; | grep -v "No syntax errors detected"; then exit 1; fi | ||
if find tests -name "*.php" -exec php -l {} \; | grep -v "No syntax errors detected"; then exit 1; fi | ||
|
||
phpunit: ## executing all test files | ||
vendor/bin/phpunit --bootstrap=vendor/autoload.php --colors tests | ||
|
||
build: lint-php check-cs static-analysis phpunit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# Panaly - Project Analyzer | ||
|
||
This project targets to deliver an extendable tool to analyze a projects sourcecode for some metrics. Have a code | ||
coverage report? Some baselines for static analyzer that you want to keep in mind? Just file system metrics? Get | ||
them all together based on your custom configuration and get a reporting of your mind for it. | ||
|
||
The plugin system ensures that it is possible to customize every step from the configuration to the collection of | ||
the metrics and over to storage and reporting. Later on even more access with active event listening will be enabled | ||
so that every plugin can form the way a projects analyzer tools bring their numbers together. | ||
|
||
## Setup | ||
|
||
> :warning: Open TODO - Work in Progress Project | ||
## Usage | ||
|
||
In default the CLI Command will search for a config file `panaly.dist.yaml` which can be overwritten by giving the | ||
config file with the CLI Command like `vendor/bin/panaly -c my-own-config.yaml`. | ||
|
||
## Example Configuration | ||
|
||
```yaml | ||
plugins: # Registered plugins that deliver single metrics that could be utilized for metric groups | ||
- Namespace/Of/The/Project/FilesystemPlugin # registers a "filesystem_directory_count" and a "fielsystem_file_count" metric | ||
- Namespace/Of/Another/Project/PHPStanBaselinePlugin # registers a simple "phpstan_baseline_total_count" metric | ||
- I/Have/A/Storage/Engine/LocalJsonStoragePlugin # registers a "local_json" storage and also a "metric_history_timeframe" metric that shows from / to string of alltime metric reading | ||
- My/Own/Plugin/HtmlReportPlugin # registers the "my_own_html_reporting" reporting that takes the result collection of the metrics and does something with it | ||
|
||
groups: | ||
group1: | ||
title: "My Metrics" | ||
metrics: | ||
metric_history_timeframe: | ||
title: "Metrics in Storage (Timeframe)" | ||
storage: local_json | ||
group2: | ||
title: "Filesystem Metrics" | ||
metrics: | ||
filesystem_directory_count: ~ | ||
fielsystem_file_count: | ||
title: "Total project files" | ||
paths: | ||
- src | ||
- tests | ||
group3: | ||
title: Static Analysis Metrics" | ||
metrics: | ||
phpstan_baseline_total_count: | ||
title: "PHPStan Debts" | ||
baseline: .baselines/phpstan-baseline.neon | ||
|
||
storage: | ||
local_json: | ||
path: var/metric_storage | ||
|
||
reporting: | ||
my_own_html_reporting: ~ | ||
``` | ||
## Events | ||
The event section is work in progress as there is currently no real way to register an event listener but that will | ||
become available later so that plugins are also enabled to hook into the events instead of delivering metrics, | ||
reporting or storages to the process. | ||
| Event | Description | | ||
|---------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ||
| ConfigurationLoaded | The event is dispatched directly after the `ConfigurationFile` was loaded. It allows to overwrite the full configuration by delivering a new instance that will then be taken for the process. | | ||
| RuntimeLoaded | After the configuration was fully loaded and converted to the `RuntimeConfiguration` this event is triggered, it is the last possibility to change the metric running process. | | ||
|
||
## Thanks and License | ||
|
||
**Panaly - Project Analyzer** © 2024+, Denis Zunke. Released utilizing the [MIT License](https://mit-license.org/). | ||
|
||
Inspired By [PHPMetrics](https://phpmetrics.github.io/website/) - Thanks for your Tool! | ||
|
||
> GitHub [@dzunke](https://github.com/DZunke) · | ||
> Twitter [@DZunke](https://twitter.com/DZunke) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Panaly\Configuration; | ||
use Panaly\Event\ConfigurationLoaded; | ||
use Panaly\Event\RuntimeLoaded; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Component\Console\SingleCommandApplication; | ||
use Symfony\Component\Console\Style\SymfonyStyle; | ||
use Panaly\Collector\Collector; | ||
use Panaly\Reporting\Handler as ReportingHandler; | ||
use Panaly\Storage\Handler as StorageHandler; | ||
|
||
require __DIR__ . '/../vendor/autoload.php'; | ||
|
||
(new SingleCommandApplication()) | ||
->setName('Panaly - Project Analyzer') | ||
->setVersion('0.1') | ||
->addOption( | ||
'config', | ||
'c', | ||
InputOption::VALUE_REQUIRED, | ||
'Path to an existing config file', | ||
dirname('.') . DIRECTORY_SEPARATOR . 'panaly.dist.yaml', | ||
) | ||
->setCode(static function (InputInterface $input, OutputInterface $output): int { | ||
$io = new SymfonyStyle($input, $output); | ||
$io->title('Project Analyzer'); | ||
|
||
$runtimeConfiguration = new Configuration\RuntimeConfiguration(); | ||
$configurationFile = (new Configuration\ConfigurationFileLoader())->loadFromFile($input->getOption('config')); | ||
|
||
$runtimeConfiguration->getEventDispatcher()->dispatch($event = new ConfigurationLoaded($configurationFile)); | ||
(new Configuration\PluginLoader())->load($event->getConfigurationFile(), $runtimeConfiguration); | ||
// TODO: Add a validation thingy here ... so the full configuration is validated against the runtime | ||
$runtimeConfiguration->getEventDispatcher()->dispatch(new RuntimeLoaded($runtimeConfiguration)); | ||
|
||
$collectionResult = (new Collector($configurationFile, $runtimeConfiguration))->collect(); | ||
|
||
(new StorageHandler($configurationFile, $runtimeConfiguration))->handle($collectionResult); | ||
(new ReportingHandler($configurationFile, $runtimeConfiguration))->handle($collectionResult); | ||
|
||
$io->success('Panaly has finished collecting your metrics ...'); | ||
|
||
return Command::SUCCESS; | ||
})->run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{ | ||
"name": "dzunke/panaly", | ||
"description": "Project Analyzer Tool - Get different sources of quality tools together into a single source of results", | ||
"type": "project", | ||
"license": "MIT", | ||
"minimum-stability": "dev", | ||
"prefer-stable": true, | ||
"autoload": { | ||
"psr-4": { | ||
"Panaly\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Panaly\\Test\\": "tests/" | ||
} | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "Denis Zunke", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"config": { | ||
"sort-packages": true, | ||
"allow-plugins": { | ||
"dealerdirect/phpcodesniffer-composer-installer": true | ||
} | ||
}, | ||
"bin": [ | ||
"bin/panaly" | ||
], | ||
"require": { | ||
"php": "^8.3", | ||
"psr/log": "^3.0", | ||
"symfony/console": "^7.0", | ||
"symfony/event-dispatcher": "^7.0", | ||
"symfony/yaml": "^7.0" | ||
}, | ||
"require-dev": { | ||
"doctrine/coding-standard": "^12.0", | ||
"phpstan/phpstan": "^1.10", | ||
"phpstan/phpstan-deprecation-rules": "^1.1", | ||
"phpstan/phpstan-strict-rules": "^1.5", | ||
"phpunit/phpunit": "^11.0", | ||
"symfony/var-dumper": "^7.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
plugins: | ||
- Panaly\Test\Fixtures\Plugin\TestPlugin | ||
|
||
groups: | ||
home: | ||
title: "My Metrics" | ||
metrics: | ||
a_static_integer: ~ | ||
|
||
storage: | ||
single_json: | ||
file: metric_storage.json | ||
|
||
reporting: | ||
symfony_dump: ~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0"?> | ||
<ruleset name="Project Analyzer"> | ||
<arg value="p"/> | ||
<arg value="s"/> | ||
<arg name="colors"/> | ||
<arg name="cache" value=".phpcs-cache"/> | ||
|
||
<file>bin</file> | ||
<file>src</file> | ||
<file>tests</file> | ||
|
||
<rule ref="Doctrine"> | ||
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingTraversableTypeHintSpecification"/> | ||
</rule> | ||
</ruleset> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
includes: | ||
- vendor/phpstan/phpstan-strict-rules/rules.neon | ||
- vendor/phpstan/phpstan-deprecation-rules/rules.neon | ||
|
||
parameters: | ||
checkMissingIterableValueType: false | ||
level: 8 | ||
paths: | ||
- bin | ||
- src | ||
- tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.0/phpunit.xsd" colors="true" | ||
executionOrder="random" failOnWarning="true" failOnRisky="true" failOnEmptyTestSuite="true" | ||
beStrictAboutOutputDuringTests="true" cacheDirectory=".phpunit.cache"> | ||
<php> | ||
<ini name="display_errors" value="On"/> | ||
<ini name="error_reporting" value="-1"/> | ||
</php> | ||
<testsuites> | ||
<testsuite name="Tests"> | ||
<directory>tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
<source> | ||
<include> | ||
<directory suffix=".php">src/</directory> | ||
</include> | ||
</source> | ||
</phpunit> |
Oops, something went wrong.