Skip to content

Remove composer dependency, insights, and tests #575

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

Merged
merged 2 commits into from
May 3, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"ext-json": "*",
"ext-mbstring": "*",
"ext-tokenizer": "*",
"composer/composer": "^2.0",
"composer/semver": "^3.3",
"friendsofphp/php-cs-fixer": "^3.0.0",
"justinrainbow/json-schema": "^5.1",
"league/container": "^3.2|^4.2",
Expand Down
37 changes: 0 additions & 37 deletions docs/insights/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
The following insights are organised in different metrics :

* `NunoMaduro\PhpInsights\Domain\Metrics\Architecture\Classes` <Badge text="Architecture\Classes" type="warn" vertical="middle"/>
* `NunoMaduro\PhpInsights\Domain\Metrics\Architecture\Composer` <Badge text="Architecture\Composer" type="warn" vertical="middle"/>
* `NunoMaduro\PhpInsights\Domain\Metrics\Architecture\Constants` <Badge text="Architecture\Constants" type="warn" vertical="middle"/>
* `NunoMaduro\PhpInsights\Domain\Metrics\Architecture\Files` <Badge text="Architecture\Files" type="warn" vertical="middle"/>
* `NunoMaduro\PhpInsights\Domain\Metrics\Architecture\Functions` <Badge text="Architecture\Functions" type="warn" vertical="middle"/>
Expand Down Expand Up @@ -95,42 +94,6 @@ This sniff reports use of superfluous prefix or suffix "Abstract" for abstract c

**Insight Class**: `SlevomatCodingStandard\Sniffs\Classes\SuperfluousAbstractClassNamingSniff`

## `composer.json` must exist <Badge text="^1.0"/> <Badge text="Architecture\Composer" type="warn"/>

This insight verifies there is `composer.json`.

**Insight Class**: `NunoMaduro\PhpInsights\Domain\Insights\Composer\ComposerMustExist`

## The name property in the `composer.json` <Badge text="^1.0"/> <Badge text="Architecture\Composer" type="warn"/>

This insight checks if the name section in `composer.json` contains default values (e.g. `laravel/laravel` or `symfony/symfony`).

**Insight Class**: `NunoMaduro\PhpInsights\Domain\Insights\Composer\ComposerMustContainName`

## Composer.json must be valid <Badge text="^1.7"/> <Badge text="Architecture\Composer" type="warn"/>

This insight checks if the `composer.json` is valid.

**Insight Class**: `NunoMaduro\PhpInsights\Domain\Insights\Composer\ComposerMustBeValid`

<details>
<summary>Configuration</summary>

```php
ComposerMustBeValid::class => [
//optional configuration value for composer version 2 only
//you can allow 'version' in your composer.json and disable the check of it so that you don't get an error
'composerVersionCheck' => 0,
]
```
</details>

## Composer.lock must be fresh <Badge text="^1.7"/> <Badge text="Architecture\Composer" type="warn"/>

This insight verifies that the `composer.lock` is not outdated.

**Insight Class**: `NunoMaduro\PhpInsights\Domain\Insights\Composer\ComposerLockMustBeFresh`

## Define `globals` is prohibited <Badge text="^1.0"/> <Badge text="Architecture\Constants" type="warn"/>

This insight disallows defining `globals`.
Expand Down
23 changes: 0 additions & 23 deletions src/Application/Composer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@

namespace NunoMaduro\PhpInsights\Application;

use Composer\Semver\Semver;

/**
* @internal
*
* @see \Tests\Application\ComposerTest
*/
final class Composer
{
Expand Down Expand Up @@ -51,23 +47,4 @@ public function getName(): string
{
return $this->config['name'] ?? '';
}

public function hasPhpVersion(): bool
{
return isset($this->getRequirements()['php']);
}

public function lowestPhpVersionIsGreaterThenOrEqualTo(string $version): bool
{
$composerVersion = $this->getPhpVersion();
preg_match("/\d+(\.\d+)/", $composerVersion, $matches);
$composerVersion = $matches[0];

return Semver::satisfies($composerVersion, $version);
}

private function getPhpVersion(): string
{
return $this->getRequirements()['php'];
}
}
4 changes: 1 addition & 3 deletions src/Application/DefaultPreset.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ public static function get(Composer $composer): array
'ignoreUnusedValuesWhenOnlyKeysAreUsedInForeach' => true,
],
PropertyTypeHintSniff::class => [
'enableNativeTypeHint' => $composer->hasPhpVersion()
? $composer->lowestPhpVersionIsGreaterThenOrEqualTo('7.4')
: PHP_VERSION_ID >= 70_400,
'enableNativeTypeHint' => PHP_VERSION_ID >= 70_400,
],
],
];
Expand Down
29 changes: 0 additions & 29 deletions src/Domain/ComposerFinder.php

This file was deleted.

53 changes: 0 additions & 53 deletions src/Domain/ComposerLoader.php

This file was deleted.

50 changes: 0 additions & 50 deletions src/Domain/Insights/Composer/ComposerLockMustBeFresh.php

This file was deleted.

72 changes: 0 additions & 72 deletions src/Domain/Insights/Composer/ComposerMustBeValid.php

This file was deleted.

48 changes: 0 additions & 48 deletions src/Domain/Insights/Composer/ComposerMustContainName.php

This file was deleted.

Loading