Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration overhaul #860

Merged
merged 1 commit into from
Apr 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
47 changes: 47 additions & 0 deletions .deptrac/ast.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
parameters:
paths:
- ../src

layers:
- name: AstLoader
collectors:
- type: className
value: ^Qossmic\\Deptrac\\Ast\\AstLoader
- name: AstMap
collectors:
- type: className
value: ^Qossmic\\Deptrac\\Ast\\AstMap
- name: Parser
collectors:
- type: className
value: ^Qossmic\\Deptrac\\Ast\\Parser
- name: PhpParser
collectors:
- type: bool
must:
- type: className
value: ^PhpParser\\
must_not:
- type: className
value: ^PhpParser\\Error$
- name: PhpDocParser
collectors:
- type: className
value: ^PHPStan\\PhpDocParser\\
- name: PhpDocumentor
collectors:
- type: className
value: ^phpDocumentor\\

ruleset:
AstMap: ~

Parser:
- AstMap
- PhpParser
- PhpDocParser
- PhpDocumentor

AstLoader:
- AstMap
- Parser
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,28 +110,28 @@ jobs:
coverage: none

- name: "Run deptrac phar without cache"
run: php deptrac.phar analyse docs/examples/Fixture.depfile.yaml --no-cache
run: php deptrac.phar analyse --config-file=docs/examples/Fixture.depfile.yaml --no-cache

- name: "Cache file should not exist"
run: "[ ! -f '.deptrac.cache' ]"

- name: "Run deptrac phar with cache enabled"
run: php deptrac.phar analyse docs/examples/Fixture.depfile.yaml
run: php deptrac.phar analyse --config-file=docs/examples/Fixture.depfile.yaml

- name: "Cache file should exist"
run: "[ -f '.deptrac.cache' ]"

- name: "Run deptrac phar again with cache enabled to be sure the cache file could be reused"
run: php deptrac.phar analyse docs/examples/Fixture.depfile.yaml
run: php deptrac.phar analyse --config-file=docs/examples/Fixture.depfile.yaml

- name: "Run deptrac phar with custom cache file output"
run: php deptrac.phar analyse docs/examples/Fixture.depfile.yaml --cache-file=.deptrac.cache2
run: php deptrac.phar analyse --config-file=docs/examples/Fixture.depfile.yaml --cache-file=.deptrac.cache2

- name: "Custom cache file should exist"
run: "[ -f '.deptrac.cache2' ]"

- name: "Run deptrac phar using transitive dependencies example"
run: php deptrac.phar analyse docs/examples/Transitive.depfile.yaml
run: php deptrac.phar analyse --config-file=docs/examples/Transitive.depfile.yaml

- name: "Run deptrac phar with --fail-on-uncovered"
run: sh .github/workflows/test-flag-fail-on-uncovered.sh
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ composer-install:

tests: composer-install
$(PHPUNIT_BIN) -c .
$(PHP_BIN) deptrac.php analyse docs/examples/Fixture.depfile.yaml --no-cache
$(PHP_BIN) deptrac.php analyse --config-file=docs/examples/Fixture.depfile.yaml --no-cache

tests-coverage: composer-install
$(PHPUNIT_BIN) -c . --coverage-html coverage
Expand Down
19 changes: 19 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Upgrade from 0.19 to 0.20

## Commands

### What?

* You must now use the new `--config-file` option instead of providing the
configuration file (Depfile) as command argument

## Depfile (Configuration File)

### What?

* The `baseline` parameter was removed. You can use `imports` instead.
* The `ruleset` is no longer checked for undefined layers. They will be
silently ignored instead.
* The parameter `use_relative_path_from_depfile` no longer exists. It is
replaced by a `projectDirectory` parameter, which by default points to
`%depfileDirectory%` and can be changed to `%currentWorkingDirectory%` or any
other base directory you want to use as reference for relative paths.

## Baseline Formatter

### What?
Expand Down
258 changes: 2 additions & 256 deletions baseline.xml
Original file line number Diff line number Diff line change
@@ -1,268 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.x-dev@">
<file src="src/AstRunner/AstParser/NikicPhpParser/FileReferenceVisitor.php">
<file src="src/Ast/Parser/NikicPhpParser/FileReferenceVisitor.php">
<RedundantConditionGivenDocblockType occurrences="2">
<code>isset($node-&gt;namespacedName)</code>
<code>isset($node-&gt;namespacedName)</code>
</RedundantConditionGivenDocblockType>
</file>
<file src="src/AstRunner/AstParser/NikicPhpParser/NikicPhpParser.php">
<file src="src/Ast/Parser/NikicPhpParser/NikicPhpParser.php">
<RedundantConditionGivenDocblockType occurrences="1">
<code>isset($classLikeNode-&gt;namespacedName)</code>
</RedundantConditionGivenDocblockType>
</file>
<file src="src/Collector/ClassNameCollector.php">
<TooManyArguments occurrences="1">
<code>trigger_deprecation('qossmic/deptrac', '0.20.0', 'ClassNameCollector should use the "value" key from this version')</code>
</TooManyArguments>
<UnusedFunctionCall occurrences="1">
<code>trigger_deprecation</code>
</UnusedFunctionCall>
</file>
<file src="src/Collector/ClassNameRegexCollector.php">
<TooManyArguments occurrences="1">
<code>trigger_deprecation('qossmic/deptrac', '0.20.0', 'ClassNameRegexCollector should use the "value" key from this version')</code>
</TooManyArguments>
<UnusedFunctionCall occurrences="1">
<code>trigger_deprecation</code>
</UnusedFunctionCall>
</file>
<file src="src/Collector/DirectoryCollector.php">
<TooManyArguments occurrences="1">
<code>trigger_deprecation('qossmic/deptrac', '0.20.0', 'ClassNameCollector should use the "value" key from this version')</code>
</TooManyArguments>
<UnusedFunctionCall occurrences="1">
<code>trigger_deprecation</code>
</UnusedFunctionCall>
</file>
<file src="src/Collector/ExtendsCollector.php">
<MixedAssignment occurrences="1">
<code>$configuration['value']</code>
</MixedAssignment>
<TooManyArguments occurrences="1">
<code>trigger_deprecation('qossmic/deptrac', '0.20.0', 'ExtendsCollector should use the "value" key from this version')</code>
</TooManyArguments>
<UnusedFunctionCall occurrences="1">
<code>trigger_deprecation</code>
</UnusedFunctionCall>
</file>
<file src="src/Collector/FunctionNameCollector.php">
<TooManyArguments occurrences="1">
<code>trigger_deprecation('qossmic/deptrac', '0.20.0', 'FunctionNameCollector should use the "value" key from this version')</code>
</TooManyArguments>
<UnusedFunctionCall occurrences="1">
<code>trigger_deprecation</code>
</UnusedFunctionCall>
</file>
<file src="src/Collector/ImplementsCollector.php">
<MixedAssignment occurrences="1">
<code>$configuration['value']</code>
</MixedAssignment>
<TooManyArguments occurrences="1">
<code>trigger_deprecation('qossmic/deptrac', '0.20.0', 'ImplementsCollector should use the "value" key from this version')</code>
</TooManyArguments>
<UnusedFunctionCall occurrences="1">
<code>trigger_deprecation</code>
</UnusedFunctionCall>
</file>
<file src="src/Collector/InheritanceLevelCollector.php">
<TooManyArguments occurrences="1">
<code>trigger_deprecation('qossmic/deptrac', '0.20.0', 'InheritanceLevelCollector should use the "value" key from this version')</code>
</TooManyArguments>
<UnusedFunctionCall occurrences="1">
<code>trigger_deprecation</code>
</UnusedFunctionCall>
</file>
<file src="src/Collector/InheritsCollector.php">
<MixedAssignment occurrences="1">
<code>$configuration['value']</code>
</MixedAssignment>
<TooManyArguments occurrences="1">
<code>trigger_deprecation('qossmic/deptrac', '0.20.0', 'InheritsCollector should use the "value" key from this version')</code>
</TooManyArguments>
<UnusedFunctionCall occurrences="1">
<code>trigger_deprecation</code>
</UnusedFunctionCall>
</file>
<file src="src/Collector/LayerCollector.php">
<PossiblyUndefinedArrayOffset occurrences="1">
<code>$configuration['value']</code>
</PossiblyUndefinedArrayOffset>
<TooManyArguments occurrences="2">
<code>trigger_deprecation('qossmic/deptrac', '0.20.0', 'LayerCollector should use the "value" key from this version')</code>
<code>trigger_deprecation('qossmic/deptrac', '0.20.0', 'LayerCollector should use the "value" key from this version')</code>
</TooManyArguments>
<UnusedFunctionCall occurrences="2">
<code>trigger_deprecation</code>
<code>trigger_deprecation</code>
</UnusedFunctionCall>
</file>
<file src="src/Collector/MethodCollector.php">
<TooManyArguments occurrences="1">
<code>trigger_deprecation('qossmic/deptrac', '0.20.0', 'MethodCollector should use the "value" key from this version')</code>
</TooManyArguments>
<UnusedFunctionCall occurrences="1">
<code>trigger_deprecation</code>
</UnusedFunctionCall>
</file>
<file src="src/Collector/SuperglobalCollector.php">
<RedundantCastGivenDocblockType occurrences="1">
<code>(string) $name</code>
</RedundantCastGivenDocblockType>
<TooManyArguments occurrences="1">
<code>trigger_deprecation('qossmic/deptrac', '0.20.0', 'SuperglobalCollector should use the "value" key from this version')</code>
</TooManyArguments>
<UnusedFunctionCall occurrences="1">
<code>trigger_deprecation</code>
</UnusedFunctionCall>
</file>
<file src="src/Collector/UsesCollector.php">
<MixedAssignment occurrences="1">
<code>$configuration['value']</code>
</MixedAssignment>
<TooManyArguments occurrences="1">
<code>trigger_deprecation('qossmic/deptrac', '0.20.0', 'UsesCollector should use the "value" key from this version')</code>
</TooManyArguments>
<UnusedFunctionCall occurrences="1">
<code>trigger_deprecation</code>
</UnusedFunctionCall>
</file>
<file src="src/Configuration/Configuration.php">
<RedundantCastGivenDocblockType occurrences="2">
<code>(array) $rules</code>
<code>(bool) $options['ignore_uncovered_internal_classes']</code>
</RedundantCastGivenDocblockType>
</file>
<file src="src/Configuration/Definition.php">
<MixedMethodCall occurrences="78">
<code>append</code>
<code>append</code>
<code>append</code>
<code>append</code>
<code>arrayNode</code>
<code>arrayNode</code>
<code>arrayNode</code>
<code>arrayNode</code>
<code>arrayNode</code>
<code>arrayNode</code>
<code>arrayPrototype</code>
<code>arrayPrototype</code>
<code>arrayPrototype</code>
<code>arrayPrototype</code>
<code>booleanNode</code>
<code>booleanNode</code>
<code>booleanNode</code>
<code>cannotBeEmpty</code>
<code>children</code>
<code>defaultFalse</code>
<code>defaultTrue</code>
<code>defaultTrue</code>
<code>end</code>
<code>end</code>
<code>end</code>
<code>end</code>
<code>end</code>
<code>end</code>
<code>end</code>
<code>end</code>
<code>end</code>
<code>end</code>
<code>end</code>
<code>end</code>
<code>end</code>
<code>end</code>
<code>end</code>
<code>end</code>
<code>end</code>
<code>end</code>
<code>end</code>
<code>end</code>
<code>end</code>
<code>end</code>
<code>end</code>
<code>end</code>
<code>end</code>
<code>end</code>
<code>end</code>
<code>end</code>
<code>end</code>
<code>end</code>
<code>end</code>
<code>end</code>
<code>end</code>
<code>end</code>
<code>end</code>
<code>end</code>
<code>end</code>
<code>end</code>
<code>ignoreExtraKeys</code>
<code>isRequired</code>
<code>isRequired</code>
<code>requiresAtLeastOneElement</code>
<code>requiresAtLeastOneElement</code>
<code>scalarNode</code>
<code>scalarNode</code>
<code>scalarPrototype</code>
<code>scalarPrototype</code>
<code>scalarPrototype</code>
<code>scalarPrototype</code>
<code>scalarPrototype</code>
<code>scalarPrototype</code>
<code>scalarPrototype</code>
<code>scalarPrototype</code>
<code>useAttributeAsKey</code>
<code>useAttributeAsKey</code>
<code>useAttributeAsKey</code>
</MixedMethodCall>
<PossiblyNullReference occurrences="6">
<code>arrayNode</code>
<code>arrayNode</code>
<code>arrayNode</code>
<code>booleanNode</code>
<code>end</code>
<code>end</code>
</PossiblyNullReference>
<PossiblyUndefinedMethod occurrences="6">
<code>arrayNode</code>
<code>arrayNode</code>
<code>arrayNode</code>
<code>booleanNode</code>
<code>end</code>
<code>end</code>
</PossiblyUndefinedMethod>
<UnusedMethodCall occurrences="1">
<code>end</code>
</UnusedMethodCall>
<UnusedVariable occurrences="1">
<code>$remove</code>
</UnusedVariable>
</file>
<file src="src/Configuration/Loader.php">
<LessSpecificReturnStatement occurrences="1">
<code>array_filter(array_merge($config, $normalized), static fn ($value) =&gt; null !== $value)</code>
</LessSpecificReturnStatement>
<MixedArgument occurrences="1">
<code>$mergedConfig['paths']</code>
</MixedArgument>
<MixedArrayAssignment occurrences="2">
<code>$mergedConfig['parameters']['currentWorkingDirectory']</code>
<code>$mergedConfig['parameters']['depfileDirectory']</code>
</MixedArrayAssignment>
<MoreSpecificReturnType occurrences="1"/>
<RedundantCastGivenDocblockType occurrences="2">
<code>(array) $mainConfig['imports']</code>
<code>(string) $mainConfig['baseline']</code>
</RedundantCastGivenDocblockType>
</file>
<file src="src/Configuration/ParameterResolver.php">
<InvalidReturnStatement occurrences="1">
<code>$this-&gt;replace($values, $keys, $parameters)</code>
</InvalidReturnStatement>
<InvalidReturnType occurrences="1">
<code>T</code>
</InvalidReturnType>
<MixedArgumentTypeCoercion occurrences="1">
<code>$values</code>
</MixedArgumentTypeCoercion>
</file>
</files>
4 changes: 2 additions & 2 deletions box.json.dist
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"files": [
"config/cache.php",
"config/parameters.php",
"config/services.php",
"config/cache.php"
"config/services.php"
],
"compression": "GZ",
"main": "deptrac.php",
Expand Down