Skip to content

Commit

Permalink
[#146] Repalced TwigCS with Twig CS Fixer.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexSkrypnyk committed May 5, 2024
1 parent 10493ea commit 0a906f1
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 43 deletions.
10 changes: 9 additions & 1 deletion .ahoy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ commands:
vendor/bin/phpstan
vendor/bin/rector --clear-cache --dry-run
vendor/bin/phpmd . text phpmd.xml
vendor/bin/twigcs
vendor/bin/twig-cs-fixer
popd >/dev/null || exit 1
lint-fix:
Expand Down Expand Up @@ -71,6 +71,14 @@ commands:
vendor/bin/phpunit --testsuite functional
popd >/dev/null || exit 1
reset:
usage: Reset the project.
cmd: |
killall -9 php >/dev/null 2>&1 || true
chmod -Rf 777 build > /dev/null
rm -Rf build > /dev/null || true
rm -Rf .logs > /dev/null || true
# Override entrypoint to alter default behaviour of Ahoy.
entrypoint:
- bash
Expand Down
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ job-test: &job-test
working_directory: build

- run:
name: Lint code with Twigcs
command: vendor/bin/twigcs || [ "${CI_TWIGCS_IGNORE_FAILURE:-0}" -eq 1 ]
name: Lint code with Twig CS Fixer
command: vendor/bin/twig-cs-fixer || [ "${CI_TWIGCSFIXER_IGNORE_FAILURE:-0}" -eq 1 ]
working_directory: build

- run:
Expand Down
2 changes: 1 addition & 1 deletion .devtools/build-codebase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ for composer_suggest in $composer_suggests; do
done

echo "> Copy tools configuration files."
cp phpcs.xml phpstan.neon phpmd.xml rector.php .twig_cs.php phpunit.xml "build/"
cp phpcs.xml phpstan.neon phpmd.xml rector.php .twig-cs-fixer.php phpunit.xml "build/"

echo "> Symlink extension's code."
rm -rf "build/web/${type}/custom" >/dev/null && mkdir -p "build/web/${type}/custom/${extension}"
Expand Down
30 changes: 15 additions & 15 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# Ignore files for distribution archives.

# Uncomment the lines below in your project.
# .ahoy.yml export-ignore
# .circleci export-ignore
# .devtools export-ignore
# .editorconfig export-ignore
# .gitattributes export-ignore
# .github export-ignore
# .gitignore export-ignore
# .twig_cs.php export-ignore
# composer.dev.json export-ignore
# phpcs.xml export-ignore
# phpmd.xml export-ignore
# phpstan.neon export-ignore
# rector.php export-ignore
# renovate.json export-ignore
# tests export-ignore
# .ahoy.yml export-ignore
# .circleci export-ignore
# .devtools export-ignore
# .editorconfig export-ignore
# .gitattributes export-ignore
# .github export-ignore
# .gitignore export-ignore
# .twig-cs-fixer.php export-ignore
# composer.dev.json export-ignore
# phpcs.xml export-ignore
# phpmd.xml export-ignore
# phpstan.neon export-ignore
# rector.php export-ignore
# renovate.json export-ignore
# tests export-ignore

# Remove the lines below in your project.
.github/FUNDING.yml export-ignore
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ jobs:
working-directory: build
run: vendor/bin/phpmd . text phpmd.xml || [ "${CI_PHPMD_IGNORE_FAILURE:-0}" -eq 1 ]

- name: Lint code with Twigcs
- name: Lint code with Twig CS Fixer
working-directory: build
run: vendor/bin/twigcs || [ "${CI_TWIGCS_IGNORE_FAILURE:-0}" -eq 1 ]
run: vendor/bin/twig-cs-fixer || [ "${CI_TWIGCSFIXER_IGNORE_FAILURE:-0}" -eq 1 ]

- name: Run tests
working-directory: build
Expand Down
2 changes: 1 addition & 1 deletion .scaffold/tests/bats/_assert_init.bash
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ assert_workflow() {
vendor/bin/phpstan
vendor/bin/rector --clear-cache --dry-run
vendor/bin/phpmd . text phpmd.xml
vendor/bin/twigcs
vendor/bin/twig-cs-fixer

popd >/dev/null || exit 1

Expand Down
16 changes: 16 additions & 0 deletions .twig-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types = 1);

$ruleset = new TwigCsFixer\Ruleset\Ruleset();
$ruleset->addStandard(new TwigCsFixer\Standard\Twig());

$finder = new TwigCsFixer\File\Finder();
$finder->in(__DIR__ . '/web/modules/custom');
$finder->in(__DIR__ . '/web/themes/custom');

$config = new TwigCsFixer\Config\Config();
$config->setRuleset($ruleset);
$config->setFinder($finder);

return $config;
15 changes: 0 additions & 15 deletions .twig_cs.php

This file was deleted.

4 changes: 2 additions & 2 deletions README.dist.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ vendor/bin/phpcs
vendor/bin/phpstan
vendor/bin/rector --clear-cache --dry-run
vendor/bin/phpmd . text phpmd.xml
vendor/bin/twigcs
vendor/bin/twig-cs-fixer
```

- PHPCS config: [`phpcs.xml`](phpcs.xml)
- PHPStan config: [`phpstan.neon`](phpstan.neon)
- PHPMD config: [`phpmd.xml`](phpmd.xml)
- Rector config: [`rector.php`](rector.php)
- TwigCS config: [`.twig_cs.php`](.twig_cs.php)
- Twig CS Fixer config: [`.twig-cs-fixer.php`](.twig-cs-fixer.php)

### Tests

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ to [drupal.org](https://drupal.org).
with PHPStan (including [PHPStan Drupal](https://github.com/mglaman/phpstan-drupal)).
- PHP deprecated code analysis
with [Drupal Rector](https://github.com/palantirnet/drupal-rector).
- Twig code analysis with [TwigCS](https://github.com/friendsoftwig/twigcs).
- Twig code analysis with [Twig CS Fixer](https://github.com/VincentLanglet/Twig-CS-Fixer).
![Lint process](https://user-images.githubusercontent.com/378794/253732548-9403e4cc-db03-4696-b114-32517ab0a571.gif)
- Drupal's Simpletest testing support - runs tests in the same way as
[drupal.org](https://drupal.org)'s Drupal CI
Expand Down
4 changes: 2 additions & 2 deletions composer.dev.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
"friendsoftwig/twigcs": "^6.2",
"jangregor/phpstan-prophecy": "^1.0",
"mglaman/phpstan-drupal": "^1.2",
"palantirnet/drupal-rector": "^0.18",
"phpcompatibility/php-compatibility": "^9.3",
"phpmd/phpmd": "^2.15",
"phpspec/prophecy-phpunit": "^2",
"phpstan/extension-installer": "^1.3"
"phpstan/extension-installer": "^1.3",
"vincentlanglet/twig-cs-fixer": "^2.8"
},
"config": {
"allow-plugins": {
Expand Down
2 changes: 1 addition & 1 deletion init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ process_internal() {
uncomment_line ".gitattributes" ".gitattributes"
uncomment_line ".gitattributes" ".github"
uncomment_line ".gitattributes" ".gitignore"
uncomment_line ".gitattributes" ".twig_cs.php"
uncomment_line ".gitattributes" ".twig-cs-fixer.php"
uncomment_line ".gitattributes" "composer.dev.json"
uncomment_line ".gitattributes" "phpcs.xml"
uncomment_line ".gitattributes" "phpmd.xml"
Expand Down

0 comments on commit 0a906f1

Please sign in to comment.