Skip to content

Commit c90ac95

Browse files
committed
Applied php coding standards and cleaned up config files
1 parent 2f8b308 commit c90ac95

File tree

10 files changed

+51
-394
lines changed

10 files changed

+51
-394
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,4 +201,5 @@ yarn-error.log
201201
.DS_Store
202202

203203
.env*.local
204+
.env.task
204205
.twig-cs-fixer.cache

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
config/

package.json

Lines changed: 0 additions & 16 deletions
This file was deleted.

phpcs.xml.dist

100755100644
Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,33 @@
11
<?xml version="1.0"?>
2+
<!-- This file is copied from config/drupal/php/.phpcs.xml.dist in https://github.com/itk-dev/devops_itkdev-docker. -->
3+
<!-- Feel free to edit the file, but consider making a pull request if you find a general issue with the file. -->
4+
25
<ruleset name="PHP_CodeSniffer">
36
<description>The coding standard.</description>
47

5-
<file>web/profiles/custom/os2loop/</file>
8+
<file>web/profiles/custom/os2loop/modules/</file>
9+
<file>web/profiles/custom/os2loop/themes/</file>
610

711
<!-- Exclude generated files -->
8-
<exclude-pattern>web/profiles/custom/os2loop/themes/os2loop_theme/node_modules/*</exclude-pattern>
9-
<exclude-pattern>web/profiles/custom/os2loop/themes/os2loop_theme/build/*</exclude-pattern>
10-
<!-- Show progress of the run -->
12+
<exclude-pattern>node_modules</exclude-pattern>
13+
<exclude-pattern>vendor</exclude-pattern>
14+
<exclude-pattern>web/*/custom/*/build/</exclude-pattern>
15+
<exclude-pattern>*.css</exclude-pattern>
16+
<exclude-pattern>*.js</exclude-pattern>
17+
1118
<arg value="p"/>
1219

1320
<arg name="extensions" value="php,module,inc,install,test,profile,theme,css,info,txt,yml"/>
14-
<config name="drupal_core_version" value="9"/>
21+
22+
<config name="drupal_core_version" value="11"/>
1523

1624
<rule ref="Drupal">
1725
<!-- <exclude name="Drupal.Files.TxtFileLineLength.TooLong"/> -->
1826
<!-- We want to be able to use "package" and "version" in our custom modules -->
1927
<exclude name="Drupal.InfoFiles.AutoAddedKeys.Project"/>
2028
<exclude name="Drupal.InfoFiles.AutoAddedKeys.Version"/>
29+
<exclude name="Drupal.NamingConventions.ValidEnumCase.NoUpperAcronyms" />
30+
<exclude name="Drupal.NamingConventions.ValidEnumCase.NoUnderscores" />
2131
</rule>
22-
23-
<rule ref="DrupalPractice"/>
32+
<rule ref="Squiz.Strings.DoubleQuoteUsage.NotRequired"/>
2433
</ruleset>

phpstan.neon

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
parameters:
22
paths:
3-
- web/profiles/custom/os2loop
3+
- web/profiles/custom/os2loop/modules
44
level: 0
55
customRulesetUsed: true
6-
ignoreErrors:
7-
- '#\Drupal calls should be avoided in classes, use dependency injection instead#'
8-
- '#Missing cache backend declaration for performance.#'
9-
- '#Plugin manager has cache backend specified but does not declare cache tags.#'
106
reportUnmatchedIgnoredErrors: false
7+
ignoreErrors:
8+
-
9+
message: '#\Drupal calls should be avoided in classes, use dependency injection instead#'

task/Taskfile.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ vars:
55
COMPOSER_INSTALL_ARGUMENTS:
66

77
tasks:
8+
compose:
9+
desc: Run docker compose or itkdev-docker-compose if TASK_DOCKER_COMPOSE is set in .task.env
10+
cmds:
11+
- "{{ .DOCKER_COMPOSE }} {{ .CLI_ARGS }}"
12+
silent: true
13+
814
up:
915
desc: Update (pull and up) docker compose setup and run composer install
1016
cmds:
@@ -61,3 +67,22 @@ tasks:
6167
DRUSH_OPTIONS_URI: 'http://{{default .DOCKER_COMPOSE_SITE_DOMAIN .COMPOSE_SERVER_DOMAIN}}'
6268
cmds:
6369
- "{{.DOCKER_COMPOSE}} exec --env DRUSH_OPTIONS_URI=$DRUSH_OPTIONS_URI phpfpm vendor/bin/drush {{.CLI_ARGS}}"
70+
71+
code:check:
72+
desc: Check php, twig and markdown files and analyze php code
73+
cmds:
74+
- task dev:compose -- exec phpfpm vendor/bin/phpcs --standard=phpcs.xml.dist
75+
- task dev:compose -- exec phpfpm vendor/bin/phpstan analyse --configuration=phpstan.neon
76+
- task dev:compose -- exec phpfpm vendor/bin/twig-cs-fixer lint web/profiles/custom/os2loop/themes/*/templates
77+
- docker compose run --rm prettier '**/*.{yml,yaml}' --check
78+
- docker compose run --rm prettier 'web/profiles/custom/os2loop/themes/**/css/**/*.{css,scss}' --check
79+
- docker run --rm --volume "$PWD:/md" itkdev/markdownlint '**/*.md'
80+
81+
code:apply-standards:
82+
desc: Apply coding standards to php, twig and markdown files
83+
cmds:
84+
- task dev:compose -- exec phpfpm vendor/bin/phpcbf --standard=phpcs.xml.dist
85+
- task dev:compose -- exec phpfpm vendor/bin/twig-cs-fixer lint web/themes/custom/*/templates --fix
86+
- docker compose run --rm prettier '**/*.{yml,yaml}' --write
87+
- docker compose run --rm prettier 'web/profiles/custom/os2loop/themes/**/css/**/*.{css,scss}' --write
88+
- docker run --rm --volume "$PWD:/md" itkdev/markdownlint '**/*.md' --fix

web/profiles/custom/os2loop/modules/os2loop_documents/src/Controller/EntityPrintController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Drupal\os2loop_documents\Controller;
44

5-
use Drupal\Console\Core\Utils\NestedArray;
5+
use Drupal\Component\Utility\NestedArray;
66
use Drupal\Core\Controller\ControllerBase;
77
use Drupal\Core\Entity\EntityStorageInterface;
88
use Drupal\Core\File\FileUrlGeneratorInterface;

web/profiles/custom/os2loop/modules/os2loop_question/src/Helper/Helper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ private function handleTextFormats(array &$form, FormStateInterface $form_state,
6464
if ($useRichText) {
6565
$form['os2loop_question_content']['widget'][0]['#better_formats']['settings']['allowed_formats'] =
6666
['os2loop_question_rich_text' => 'os2loop_question_rich_text'];
67-
$form["os2loop_question_content"]["widget"][0]["#format"] = 'os2loop_question_rich_text';
67+
$form['os2loop_question_content']['widget'][0]['#format'] = 'os2loop_question_rich_text';
6868
}
6969
else {
7070
$form['os2loop_question_content']['widget'][0]['#better_formats']['settings']['allowed_formats'] =
7171
['os2loop_question_plain_text' => 'os2loop_question_plain_text'];
72-
$form["os2loop_question_content"]["widget"][0]["#format"] = 'os2loop_question_plain_text';
72+
$form['os2loop_question_content']['widget'][0]['#format'] = 'os2loop_question_plain_text';
7373
}
7474

7575
// We must use a static callback here to prevent “LogicException: The

web/profiles/custom/os2loop/modules/os2loop_revision_date/src/Plugin/Action/SetRevisionDate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function execute($node = NULL) {
3434
if ($node) {
3535
/** @var \Drupal\node\NodeInterface $node */
3636
if (!$node->hasField('os2loop_shared_rev_date')) {
37-
throw new \RuntimeException("Revisioning date field not found on node.");
37+
throw new \RuntimeException('Revisioning date field not found on node.');
3838
}
3939
$node->set('os2loop_shared_rev_date', $this->getNextRevisionDate()->format('Y-m-d'));
4040
$node->save();

0 commit comments

Comments
 (0)