Skip to content

Commit

Permalink
Merge pull request #383 from mimmi20/updates
Browse files Browse the repository at this point in the history
add config for composer-dependency-analyser
  • Loading branch information
mimmi20 authored Dec 30, 2024
2 parents b8a9eeb + f85584d commit 5bcc8d6
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 1 deletion.
1 change: 0 additions & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ jobs:
skip-phpcs: false
skip-phpstan: false
skip-rector: false
skip-phpmd: true
skip-eslint: true
skip-stylelint: true
skip-prettier: true
Expand Down
1 change: 1 addition & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
->in(__DIR__ . '/src')
->in(__DIR__ . '/tests')
->append([__DIR__ . '/rector.php'])
->append([__DIR__ . '/composer-dependency-analyser.php'])
->append([__FILE__]);

$rules = require 'vendor/mimmi20/coding-standard/src/php-cs-fixer.config.php';
Expand Down
45 changes: 45 additions & 0 deletions composer-dependency-analyser.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

/**
* This file is part of the mimmi20/contact package.
*
* Copyright (c) 2022-2024, Thomas Mueller <mimmi20@live.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types = 1);

use ShipMonk\ComposerDependencyAnalyser\Config\Configuration;
use ShipMonk\ComposerDependencyAnalyser\Config\ErrorType;

$config = new Configuration();

$config
// Adjusting scanned paths
->addPathToScan(__DIR__ . '/src', isDev: false)
->addPathToScan(__DIR__ . '/tests', isDev: true)
->addPathToScan(__DIR__ . '/vendor', isDev: false)
->addPathToExclude(__DIR__ . '/vendor/rector/rector')
->addPathToExclude(__DIR__ . '/vendor/phpstan/phpstan')
// applies only to directory scanning, not directly listed files
->setFileExtensions(['php'])

// Ignoring errors in vendor directory
->ignoreErrorsOnPath(__DIR__ . '/vendor', [ErrorType::SHADOW_DEPENDENCY])
->ignoreErrorsOnPath(__DIR__ . '/vendor', [ErrorType::UNKNOWN_FUNCTION])
->ignoreErrorsOnPath(__DIR__ . '/vendor', [ErrorType::UNKNOWN_CLASS])
->ignoreErrorsOnPath(__DIR__ . '/vendor', [ErrorType::DEV_DEPENDENCY_IN_PROD])

// do not complain about some modules
->ignoreErrorsOnPackage('mimmi20/coding-standard', [ErrorType::UNUSED_DEPENDENCY])
->ignoreErrorsOnPackage('phpstan/extension-installer', [ErrorType::UNUSED_DEPENDENCY])
->ignoreErrorsOnPackage('phpstan/phpstan-phpunit', [ErrorType::UNUSED_DEPENDENCY])
->ignoreErrorsOnPackage('phpstan/phpstan-deprecation-rules', [ErrorType::UNUSED_DEPENDENCY])

// Adjust analysis
// dev packages are often used only in CI, so this is not enabled by default
->enableAnalysisOfUnusedDevDependencies();

return $config;
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"phpunit/phpunit": "^11.5.2",
"rector/rector": "^1.2.10",
"rector/type-perfect": "^1.0.0",
"shipmonk/composer-dependency-analyser": "^1.8.1",
"symfony/process": "^7.2.0",
"symplify/phpstan-rules": "^13.0.1",
"tomasvotruba/cognitive-complexity": "^0.2.3",
Expand Down
1 change: 1 addition & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@
<file>tests</file>
<file>.php-cs-fixer.php</file>
<file>rector.php</file>
<file>composer-dependency-analyser.php</file>
</ruleset>

0 comments on commit 5bcc8d6

Please sign in to comment.