Skip to content
Open
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
49 changes: 0 additions & 49 deletions .circleci/config.yml

This file was deleted.

8 changes: 8 additions & 0 deletions .ddev/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: code-quality
type: php
docroot: ""
php_version: "8.4"
webserver_type: nginx-fpm
xdebug_enabled: false
composer_root: ""
web_environment: []
23 changes: 23 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: CI

on:
push:
branches: [main]
pull_request:

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v5

- name: Setup DDEV
uses: ddev/github-action-setup-ddev@v1

- name: Install dependencies
run: ddev composer install

- name: Run GrumPHP
run: ddev exec vendor/bin/grumphp run
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@ composer.lock
# Test results
coverage.xml
.phpunit.result.cache
.phpunit.cache/

# Other
.DS_Store

# DDEV
.ddev/.dbimageBuild
.ddev/.webimageBuild
.ddev/db-build
.ddev/web-build
.ddev/.global_commands
.ddev/.ddev-docker-compose-base.yaml*
.ddev/.ddev-docker-compose-full.yaml*
.ddev/.homeadditions
.ddev/.sshimageBuild
.ddev/apache
.ddev/import-db
.ddev/xhprof
21 changes: 0 additions & 21 deletions .lando.yml

This file was deleted.

11 changes: 0 additions & 11 deletions .lando/tooling-grumphp.sh

This file was deleted.

14 changes: 0 additions & 14 deletions .lando/tooling-phpunit.sh

This file was deleted.

26 changes: 24 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Code Quality

[![CircleCI](https://circleci.com/gh/wunderio/code-quality.svg?style=svg)](https://circleci.com/gh/wunderio/code-quality)
[![CI](https://github.com/wunderio/code-quality/actions/workflows/ci.yml/badge.svg)](https://github.com/wunderio/code-quality/actions/workflows/ci.yml)

This composer package will provide some basic code quality checks before committing
code by using https://github.com/phpro/grumphp.
Expand All @@ -27,7 +27,7 @@ This repository currently has the following checks:
## Pre-requisites

* Composer
* PHP >= 8.1
* PHP >= 8.4

## Installation

Expand All @@ -42,6 +42,28 @@ cp vendor/wunderio/code-quality/config/psalm.xml ./psalm.xml

The commit hook for GrumPHP is automatically installed on composer require.

## Local development

This repository uses [DDEV](https://ddev.com/) for local development.

```sh
ddev start
ddev composer install
```

Run the test suite:

```sh
ddev exec vendor/bin/phpunit
```

Run the full GrumPHP suite against this repository's own code (the same check that
runs in CI):

```sh
ddev exec vendor/bin/grumphp run
```

## Customization

### Configuration
Expand Down
22 changes: 11 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@
],
"bin": ["bin/check_perms"],
"require": {
"symfony/polyfill-iconv": "^1",
"phpro/grumphp": "^2.5",
"drupal/coder": "^8",
"php": "^8.4",
"symfony/polyfill-iconv": "^1.37",
"phpro/grumphp": "^2.22",
"drupal/coder": "^8.3",
"phpcompatibility/php-compatibility": "^9.3",
"pheromone/phpcs-security-audit": "^2.0",
"squizlabs/php_codesniffer": "^3.4",
"dealerdirect/phpcodesniffer-composer-installer": "*",
"mglaman/phpstan-drupal": "^1.1",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan-deprecation-rules": "^1.0",
"nette/finder": "^2.5",
"tomasvotruba/cognitive-complexity": "^0.1.1",
"squizlabs/php_codesniffer": "^3.13",
"dealerdirect/phpcodesniffer-composer-installer": ">=1.2.1",
"mglaman/phpstan-drupal": "^2.1",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan-deprecation-rules": "^2.0",
"tomasvotruba/cognitive-complexity": "^1.2",
"webflo/drupal-finder": "^1.3"
},
"autoload": {
Expand All @@ -55,7 +55,7 @@
}
},
"require-dev": {
"phpunit/phpunit": "^8.3"
"phpunit/phpunit": "^10.5"
},
"config": {
"allow-plugins": {
Expand Down
2 changes: 2 additions & 0 deletions grumphp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ grumphp:
- Wunderio\GrumPHP\Task\YamlLint\YamlLintExtensionLoader
- Wunderio\GrumPHP\Task\JsonLint\JsonLintExtensionLoader
#- Wunderio\GrumPHP\Task\Psalm\PsalmExtensionLoader
git_hook_variables:
EXEC_GRUMPHP_COMMAND: ddev php
42 changes: 17 additions & 25 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,27 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit colors="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutChangesToGlobalState="true">

<php>
<!-- Set error reporting to E_ALL. -->
<ini name="error_reporting" value="32767"/>
<!-- Do not limit the amount of memory tests take to run. -->
<ini name="memory_limit" value="-1"/>
</php>
<!-- Filter for coverage reports. -->
<filter>
<whitelist>
<directory>./src</directory>
</whitelist>
</filter>
<testsuites>
<testsuite name="Unit">
<directory>tests/</directory>
</testsuite>
</testsuites>
<logging>
<log type="coverage-clover" target="./coverage.xml"/>
</logging>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" beStrictAboutTestsThatDoNotTestAnything="true" beStrictAboutOutputDuringTests="true" beStrictAboutChangesToGlobalState="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache">
<php>
<!-- Set error reporting to E_ALL. -->
<ini name="error_reporting" value="32767"/>
<!-- Do not limit the amount of memory tests take to run. -->
<ini name="memory_limit" value="-1"/>
</php>
<testsuites>
<testsuite name="Unit">
<directory>tests/</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory>./src</directory>
</include>
</source>
</phpunit>
4 changes: 2 additions & 2 deletions src/Drupal/DrupalAutoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
use Drush\Drush;
use mglaman\PHPStanDrupal\Drupal\Extension;
use mglaman\PHPStanDrupal\Drupal\ExtensionDiscovery;
use Nette\Utils\Finder;
use PHPUnit\Framework\Test;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Yaml\Yaml;

/**
Expand Down Expand Up @@ -90,7 +90,7 @@ public function register(string $drupalRoot): void {
}
$drushDir = dirname($reflect->getFileName(), $levels);
/** @var \SplFileInfo $file */
foreach (Finder::findFiles('*.inc')->in($drushDir . '/includes') as $file) {
foreach (Finder::create()->files()->name('*.inc')->in($drushDir . '/includes') as $file) {
// phpcs:ignore PHPCS_SecurityAudit.Misc.IncludeMismatch.ErrMiscIncludeMismatchNoExt
require_once $file->getPathname();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Drupal/DrupalAutoloaderBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Drupal\Core\DependencyInjection\ContainerNotInitializedException;
use mglaman\PHPStanDrupal\Drupal\Extension;
use Nette\Utils\Finder;
use Symfony\Component\Finder\Finder;

/**
* Drupal autoloader base class for allowing Psalm to scan code.
Expand Down Expand Up @@ -83,7 +83,7 @@ class DrupalAutoloaderBase {
*/
protected function loadLegacyIncludes(): void {
/** @var \SplFileInfo $file */
foreach (Finder::findFiles('*.inc')->in($this->drupalRoot . '/core/includes') as $file) {
foreach (Finder::create()->files()->name('*.inc')->in($this->drupalRoot . '/core/includes') as $file) {
// phpcs:ignore PHPCS_SecurityAudit.Misc.IncludeMismatch.ErrMiscIncludeMismatchNoExt
require_once $file->getPathname();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/AbstractExternalExtensionLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ final class AbstractExternalExtensionLoaderTest extends TestCase {
/**
* Test imports method.
*
* @covers \Wunderio\GrumPHP\Task\AbstractExternalExtensionLoader::import()
* @covers \Wunderio\GrumPHP\Task\AbstractExternalExtensionLoader::imports
*/
public function testImports(): void {
$customLoader = new CustomTestExtensionLoader();
Expand Down
10 changes: 5 additions & 5 deletions tests/AbstractLintTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function testPassesTaskIfProcessSuccessful(): void {
->setConstructorArgs([
$this->createMock(LinterInterface::class),
])
->setMethodsExcept(['run'])
->onlyMethods(['getPathsOrResult', 'configureLint', 'runLint'])
->getMockForAbstractClass();
$context = $this->createMock(ContextInterface::class);
$files = new FilesCollection(['file.php']);
Expand All @@ -73,7 +73,7 @@ public function testSkipsIfNoFilesFound(): void {
->setConstructorArgs([
$this->createMock(LinterInterface::class),
])
->setMethodsExcept(['run'])
->onlyMethods(['getPathsOrResult', 'configureLint', 'runLint'])
->getMockForAbstractClass();
$context = $this->createMock(ContextInterface::class);
$stub->expects($this->once())
Expand All @@ -98,7 +98,7 @@ public function testReturnsFailedResultOnException(): void {
->setConstructorArgs([
$lint,
])
->setMethodsExcept(['runLint'])
->onlyMethods(['configureLint', 'getConfig'])
->getMockForAbstractClass();
$files = new FilesCollection([]);

Expand All @@ -119,7 +119,7 @@ public function testReturnsFailedResultOnLintError(): void {
->setConstructorArgs([
$lint,
])
->setMethodsExcept(['runLint'])
->onlyMethods(['configureLint', 'getConfig'])
->getMockForAbstractClass();
$taskConfig = $this->createMock(TaskConfigInterface::class);

Expand Down Expand Up @@ -148,7 +148,7 @@ public function testReturnsSuccessResultOnSuccess(): void {
->setConstructorArgs([
$lint,
])
->setMethodsExcept(['runLint'])
->onlyMethods(['configureLint', 'getConfig'])
->getMockForAbstractClass();
$taskConfig = $this->createMock(TaskConfigInterface::class);

Expand Down
4 changes: 2 additions & 2 deletions tests/AbstractMultiPathProcessingTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function testSkipsTaskIfNoFilesFound(): void {
$processBuilder,
$processFormatterInterface,
])
->setMethodsExcept(['run'])
->onlyMethods(['getPathsOrResult', 'buildArguments', 'getTaskResult'])
->getMockForAbstractClass();
$context = $this->createMock(RunContext::class);

Expand Down Expand Up @@ -71,7 +71,7 @@ public function testReturnsTaskResultIfFileFoundAndProcessUnsuccessful(): void {
$processBuilder,
$this->createMock(ProcessFormatterInterface::class),
])
->setMethodsExcept(['run'])
->onlyMethods(['getPathsOrResult', 'buildArguments', 'getTaskResult'])
->getMockForAbstractClass();
$message = 'Test message...';

Expand Down
Loading