Skip to content

Commit 55f1a4e

Browse files
committed
Merge branch 'main' of github.com:wunderio/code-quality into feature/72-Re-add-code-complexity
2 parents 7f74443 + c72e6ff commit 55f1a4e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+228
-104
lines changed

.github/pull_request_template.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
## Overview
2+
3+
4+
5+
## Screenshots
6+
7+
8+
9+
## Testing
10+
11+

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ This repository currently has the following checks:
1717

1818
* Shell script exec bits - [check_file_permissions](src/Task/CheckFilePermissions/README.md)
1919
* PHP Drupal CS and PHP Code security - [phpcs](src/Task/Phpcs/README.md)
20-
* PHP 8.0 Compatibility - [php_compatibility](src/Task/PhpCompatibility/README.md)
20+
* PHP 8.1 Compatibility - [php_compatibility](src/Task/PhpCompatibility/README.md)
2121
* PHP syntax - [php_check_syntax](src/Task/PhpCheckSyntax/README.md)
2222
* Cognitive complexity and other ecs sniffs - [ecs](src/Task/Ecs/README.md)
2323
* Yaml syntax - [yaml_lint](src/Task/YamlLint/README.md)
@@ -27,7 +27,7 @@ This repository currently has the following checks:
2727
## Pre-requisites
2828

2929
* Composer
30-
* PHP >= 7.3
30+
* PHP >= 8.1
3131

3232
## Installation
3333

composer.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"bin": ["bin/check_perms"],
3737
"require": {
3838
"symfony/polyfill-iconv": "^1",
39-
"phpro/grumphp": "^1",
39+
"phpro/grumphp": "^2.5",
4040
"drupal/coder": "^8",
4141
"phpcompatibility/php-compatibility": "^9.3",
4242
"pheromone/phpcs-security-audit": "^2.0",
@@ -45,9 +45,7 @@
4545
"mglaman/phpstan-drupal": "^1.1",
4646
"phpstan/extension-installer": "^1.1",
4747
"phpstan/phpstan-deprecation-rules": "^1.0",
48-
"vimeo/psalm": "^4",
4948
"nette/finder": "^2.5",
50-
"symfony/finder": "^4.4 || ^5.3 || ^6",
5149
"tomasvotruba/cognitive-complexity": "^0.1.1",
5250
"webflo/drupal-finder": "^1.3"
5351
},

grumphp.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ grumphp:
1515
json_lint: ~
1616
phpunit: ~
1717
php_check_syntax: ~
18-
psalm: ~
18+
#psalm: ~
1919
extensions:
2020
- Wunderio\GrumPHP\Task\PhpCompatibility\PhpCompatibilityExtensionLoader
2121
- Wunderio\GrumPHP\Task\PhpCheckSyntax\PhpCheckSyntaxExtensionLoader
@@ -25,4 +25,4 @@ grumphp:
2525
- Wunderio\GrumPHP\Task\PhpStan\PhpStanExtensionLoader
2626
- Wunderio\GrumPHP\Task\YamlLint\YamlLintExtensionLoader
2727
- Wunderio\GrumPHP\Task\JsonLint\JsonLintExtensionLoader
28-
- Wunderio\GrumPHP\Task\Psalm\PsalmExtensionLoader
28+
#- Wunderio\GrumPHP\Task\Psalm\PsalmExtensionLoader

src/Drupal/DrupalAutoloader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
use DrupalFinder\DrupalFinderComposerRuntime;
88
use Drush\Drush;
9+
use mglaman\PHPStanDrupal\Drupal\Extension;
10+
use mglaman\PHPStanDrupal\Drupal\ExtensionDiscovery;
911
use Nette\Utils\Finder;
1012
use PHPUnit\Framework\Test;
1113
use Symfony\Component\Yaml\Yaml;
12-
use mglaman\PHPStanDrupal\Drupal\Extension;
13-
use mglaman\PHPStanDrupal\Drupal\ExtensionDiscovery;
1414

1515
/**
1616
* Drupal autoloader for allowing Psalm to scan code.

src/Drupal/DrupalAutoloaderBase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
namespace Wunderio\GrumPHP\Drupal;
66

77
use Drupal\Core\DependencyInjection\ContainerNotInitializedException;
8-
use Nette\Utils\Finder;
98
use mglaman\PHPStanDrupal\Drupal\Extension;
9+
use Nette\Utils\Finder;
1010

1111
/**
1212
* Drupal autoloader base class for allowing Psalm to scan code.
Lines changed: 5 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
<?php
22

3-
declare(strict_types = 1);
3+
declare(strict_types=1);
44

55
namespace Wunderio\GrumPHP\Task;
66

77
use GrumPHP\Extension\ExtensionInterface;
8-
use Symfony\Component\DependencyInjection\ContainerBuilder;
9-
use Symfony\Component\DependencyInjection\Reference;
10-
use Symfony\Component\Yaml\Yaml;
118

129
/**
1310
* Class AbstractExternalExtensionLoader.
@@ -18,54 +15,13 @@
1815
*/
1916
abstract class AbstractExternalExtensionLoader implements ExtensionInterface {
2017

21-
/**
22-
* Name.
23-
*
24-
* @var string
25-
*/
26-
public $name;
27-
28-
/**
29-
* Construction arguments.
30-
*
31-
* @var array
32-
*/
33-
public $arguments;
34-
35-
/**
36-
* Task class.
37-
*
38-
* @var string
39-
*/
40-
public $class;
41-
42-
/**
43-
* AbstractExternalExtensionLoader constructor.
44-
*/
45-
public function __construct() {
46-
$tasks = Yaml::parseFile(__DIR__ . '/tasks.yml');
47-
$class_name = str_replace('ExtensionLoader', '', static::class);
48-
$this->class = $class_name . 'Task';
49-
$default_configuration = $tasks['default'];
50-
unset($default_configuration['name']);
51-
$configurations = $tasks[$this->class] ?? $default_configuration;
52-
$class_name = explode('\\', $class_name);
53-
$default_name = strtolower(preg_replace('/\B([A-Z])/', '_$1', end($class_name)));
54-
$this->name = $configurations['name'] ?? $default_name;
55-
$this->arguments = $configurations['arguments'] ?? $default_configuration['arguments'];
56-
}
57-
5818
/**
5919
* {@inheritdoc}
6020
*/
61-
public function load(ContainerBuilder $container): void {
62-
$task = $container->register('task.' . $this->name, $this->class);
63-
if (!empty($this->arguments)) {
64-
foreach ($this->arguments as $argument) {
65-
$task->addArgument(new Reference($argument));
66-
}
67-
}
68-
$task->addTag('grumphp.task', ['task' => $this->name]);
21+
public function imports(): iterable {
22+
$class_name = str_replace('ExtensionLoader', '', static::class);
23+
$class_exploded = explode('\\', $class_name);
24+
yield dirname(__DIR__) . '/Task/' . end($class_exploded) . '/services.yaml';
6925
}
7026

7127
}

src/Task/AbstractLintTask.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
declare(strict_types = 1);
3+
declare(strict_types=1);
44

55
namespace Wunderio\GrumPHP\Task;
66

src/Task/AbstractMultiPathProcessingTask.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
declare(strict_types = 1);
3+
declare(strict_types=1);
44

55
namespace Wunderio\GrumPHP\Task;
66

src/Task/AbstractProcessingTask.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
declare(strict_types = 1);
3+
declare(strict_types=1);
44

55
namespace Wunderio\GrumPHP\Task;
66

0 commit comments

Comments
 (0)