Skip to content

Commit efa9729

Browse files
committed
Cleaned up code
# Conflicts: # .github/workflows/pr.yml # CHANGELOG.md
1 parent 12effae commit efa9729

File tree

21 files changed

+162
-182
lines changed

21 files changed

+162
-182
lines changed

.github/workflows/pr.yml

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
runs-on: ubuntu-latest
2424
strategy:
2525
matrix:
26-
php-versions: [ '8.1' ]
26+
php-versions: [ '8.3' ]
2727
dependency-version: [ prefer-lowest, prefer-stable ]
2828
steps:
2929
- uses: actions/checkout@master
@@ -47,16 +47,21 @@ jobs:
4747
- name: Validate composer files
4848
run: |
4949
composer config --no-plugins allow-plugins.mglaman/composer-drupal-lenient true
50-
composer validate --strict composer.json
50+
# The --strict flag on validate has been removed due to the package drupal/config_entity_revisions 2.0.x-dev
51+
# being considered a version cf. https://getcomposer.org/doc/articles/versions.md#branches
52+
composer validate composer.json
5153
# Check that dependencies resolve.
5254
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
55+
- name: Check that composer file is normalized
56+
run: |
57+
composer normalize --dry-run
5358
5459
php-coding-standards:
5560
name: PHP coding standards
5661
runs-on: ubuntu-latest
5762
strategy:
5863
matrix:
59-
php-versions: [ '8.1' ]
64+
php-versions: [ '8.3' ]
6065
steps:
6166
- uses: actions/checkout@master
6267
- name: Setup PHP, with composer and extensions
@@ -89,7 +94,7 @@ jobs:
8994
runs-on: ubuntu-latest
9095
strategy:
9196
matrix:
92-
php-versions: [ '8.1' ]
97+
php-versions: [ '8.3' ]
9398
steps:
9499
- uses: actions/checkout@master
95100
- name: Setup PHP, with composer and extensions
@@ -113,27 +118,13 @@ jobs:
113118
run: |
114119
./scripts/code-analysis
115120
116-
markdownlint:
121+
coding-standards-markdown:
122+
name: Markdown coding standards
117123
runs-on: ubuntu-latest
118-
name: markdownlint
119124
steps:
120125
- name: Checkout
121-
uses: actions/checkout@v4
122-
- name: Get yarn cache directory path
123-
id: yarn-cache-dir-path
124-
run: echo "::set-output name=dir::$(yarn cache dir)"
125-
- name: Cache yarn packages
126-
uses: actions/cache@v4
127-
id: yarn-cache
128-
with:
129-
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
130-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
131-
restore-keys: |
132-
${{ runner.os }}-yarn-
133-
- name: Yarn install
134-
uses: actions/setup-node@v2
135-
with:
136-
node-version: '20'
137-
- run: yarn install
138-
- name: markdownlint
139-
run: yarn coding-standards-check/markdownlint
126+
uses: actions/checkout@master
127+
128+
- name: Coding standards
129+
run: |
130+
docker run --rm --volume $PWD:/md peterdavehello/markdownlint markdownlint '**/*.md'

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,3 @@
44
composer.lock
55
vendor
66

7-
node_modules/
8-
yarn.lock

.markdownlint.jsonc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"default": true,
3+
// https://github.com/DavidAnson/markdownlint/blob/main/doc/md013.md
4+
"line-length": {
5+
"line_length": 120,
6+
"code_blocks": false,
7+
"tables": false
8+
},
9+
// https://github.com/DavidAnson/markdownlint/blob/main/doc/md024.md
10+
"no-duplicate-heading": {
11+
"siblings_only": true
12+
}
13+
}

.markdownlintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# https://github.com/igorshubovych/markdownlint-cli?tab=readme-ov-file#ignoring-files
2+
vendor/

.markdownlintrc

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

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ before starting to add changes. Use example [placed in the end of the page](#exa
1111

1212
## [Unreleased]
1313

14+
- [PR-168](https://github.com/OS2Forms/os2forms/pull/168)
15+
Cleaned up code
1416
- [PR-166](https://github.com/OS2Forms/os2forms/pull/166)
1517
- Fix digital post commands
1618
- Updated versions in GitHub Actions `uses` steps

README.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -121,30 +121,29 @@ run the checks locally.
121121
### PHP
122122

123123
```sh
124-
docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.1-fpm composer install
125-
docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.1-fpm composer coding-standards-check
126-
124+
docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.3-fpm composer install
127125
# Fix (some) coding standards issues.
128-
docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.1-fpm composer coding-standards-apply
126+
docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.3-fpm composer coding-standards-apply
127+
docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.3-fpm composer coding-standards-check
129128
```
130129

131130
### Markdown
132131

133132
```sh
134-
docker run --rm --volume ${PWD}:/app --workdir /app node:20 yarn install
135-
docker run --rm --volume ${PWD}:/app --workdir /app node:20 yarn coding-standards-check/markdownlint
136-
137-
# Fix (some) coding standards issues.
138-
docker run --rm --volume ${PWD}:/app --workdir /app node:20 yarn coding-standards-apply/markdownlint
133+
docker pull peterdavehello/markdownlint
134+
docker run --rm --volume $PWD:/md peterdavehello/markdownlint markdownlint '**/*.md' --fix
135+
docker run --rm --volume $PWD:/md peterdavehello/markdownlint markdownlint '**/*.md'
139136
```
140137

141138
## Code analysis
142139

143140
We use [PHPStan](https://phpstan.org/) for static code analysis.
144141

145-
Running statis code analysis on a standalone Drupal module is a bit tricky, so
146-
we use a helper script to run the analysis:
142+
Running statis code analysis on a standalone Drupal module is a bit tricky, so we use a helper script to run the
143+
analysis:
147144

148-
```sh
149-
./scripts/code-analysis
145+
```shell
146+
docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.3-fpm ./scripts/code-analysis
150147
```
148+
149+
**Note**: Currently the code analysis is only run on the `os2forms_digital_post` sub-module (cf. [`phpstan.neon`](./phpstan.neon)).

composer.json

Lines changed: 57 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,8 @@
11
{
22
"name": "os2forms/os2forms",
3-
"type": "drupal-module",
43
"description": "Drupal 8 OS2Form module provides advanced webform functionality for Danish Municipalities",
5-
"minimum-stability": "dev",
6-
"prefer-stable": true,
74
"license": "EUPL-1.2",
8-
"repositories": {
9-
"drupal": {
10-
"type": "composer",
11-
"url": "https://packages.drupal.org/8"
12-
},
13-
"assets": {
14-
"type": "composer",
15-
"url": "https://asset-packagist.org"
16-
}
17-
},
5+
"type": "drupal-module",
186
"require": {
197
"php": "^8.1",
208
"ext-dom": "*",
@@ -23,10 +11,10 @@
2311
"dompdf/dompdf": "^2.0",
2412
"drupal/admin_toolbar": "^3.0",
2513
"drupal/advancedqueue": "^1.0",
26-
"drupal/cache_control_override": "^1.1|^2.0",
14+
"drupal/cache_control_override": "^1.1 || ^2.0",
2715
"drupal/clientside_validation": "^4.0",
2816
"drupal/coc_forms_auto_export": "^2.0@alpha",
29-
"drupal/config_entity_revisions": "dev-2.0.x",
17+
"drupal/config_entity_revisions": "2.0.x-dev",
3018
"drupal/diff": "^1.0",
3119
"drupal/embed": "^1.4",
3220
"drupal/entity_print": "^2.1",
@@ -42,7 +30,7 @@
4230
"drupal/mailsystem": "^4.1",
4331
"drupal/masquerade": "^2.0@RC",
4432
"drupal/pathauto": "^1.5",
45-
"drupal/permissions_by_term": "^3.1 || ^2.25",
33+
"drupal/permissions_by_term": "^2.25 || ^3.1",
4634
"drupal/queue_mail": "^1.4",
4735
"drupal/r4032login": "^2.1",
4836
"drupal/redirect": "^1.4",
@@ -68,6 +56,7 @@
6856
"http-interop/http-factory-guzzle": "^1.0.0",
6957
"itk-dev/beskedfordeler-drupal": "^1.0",
7058
"itk-dev/serviceplatformen": "^1.5",
59+
"mglaman/composer-drupal-lenient": "^1.0",
7160
"os2web/os2web_audit": "^1.0",
7261
"os2web/os2web_datalookup": "^2.0",
7362
"os2web/os2web_nemlogin": "^1.0",
@@ -77,81 +66,93 @@
7766
"symfony/options-resolver": "^5.4 || ^6.0",
7867
"webmozart/path-util": "^2.3",
7968
"wsdltophp/packagebase": "^5.0",
80-
"zaporylie/composer-drupal-optimizations": "^1.2",
81-
"mglaman/composer-drupal-lenient": "^1.0"
69+
"zaporylie/composer-drupal-optimizations": "^1.2"
8270
},
8371
"require-dev": {
8472
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.1",
8573
"drupal/coder": "^8.3",
74+
"ergebnis/composer-normalize": "^2.47",
8675
"mglaman/phpstan-drupal": "^1.1",
8776
"phpstan/extension-installer": "^1.3",
8877
"phpstan/phpstan-deprecation-rules": "^1.1",
8978
"phpunit/phpunit": "^9.5",
9079
"wsdltophp/packagegenerator": "^4.0"
9180
},
92-
"extra" : {
81+
"repositories": {
82+
"drupal": {
83+
"type": "composer",
84+
"url": "https://packages.drupal.org/8"
85+
},
86+
"assets": {
87+
"type": "composer",
88+
"url": "https://asset-packagist.org"
89+
}
90+
},
91+
"minimum-stability": "dev",
92+
"prefer-stable": true,
93+
"config": {
94+
"allow-plugins": {
95+
"cweagans/composer-patches": true,
96+
"dealerdirect/phpcodesniffer-composer-installer": true,
97+
"ergebnis/composer-normalize": true,
98+
"mglaman/composer-drupal-lenient": true,
99+
"phpstan/extension-installer": true,
100+
"simplesamlphp/composer-module-installer": true,
101+
"vaimo/composer-patches": true,
102+
"zaporylie/composer-drupal-optimizations": true
103+
},
104+
"sort-packages": true
105+
},
106+
"extra": {
93107
"composer-exit-on-patch-failure": false,
94-
"enable-patching" : true,
108+
"drupal-lenient": {
109+
"allowed-list": [
110+
"drupal/coc_forms_auto_export",
111+
"drupal/webform_node_element"
112+
]
113+
},
114+
"enable-patching": true,
95115
"patches": {
116+
"drupal/coc_forms_auto_export": {
117+
"3240592 - Problem with phpseclib requirement in 2.x (https://www.drupal.org/project/coc_forms_auto_export/issues/3240592)": "https://www.drupal.org/files/issues/2021-10-04/requirement-namespace-3240592-1.patch",
118+
"3286562 - Automated Drupal 10 compatibility fixes": "https://www.drupal.org/files/issues/2022-06-15/coc_forms_auto_export.2.0.x-dev.rector.patch",
119+
"3259009 - PHP Warnings/Notices on Download Page": "https://git.drupalcode.org/project/coc_forms_auto_export/-/merge_requests/1.diff"
120+
},
96121
"drupal/entity_print": {
97122
"2733781 - Add Export to Word Support": "https://www.drupal.org/files/issues/2019-11-22/2733781-47.patch"
98123
},
99124
"drupal/webform": {
100125
"Unlock possibility of using Entity print module export to Word": "https://www.drupal.org/files/issues/2020-02-29/3096552-6.patch",
101126
"Webform computed element post save alter": "https://www.drupal.org/files/issues/2024-06-25/webform_computed_post_save_field_alter.patch",
102127
"Add custom hook (hook_webform_post_load_data) for audit logging": "https://gist.githubusercontent.com/cableman/d26898fc8f65ee0a31001bf391583b59/raw/6189dc4c2ceaabb19d25cc4b98b0b3028a6b0e1e/gistfile1.txt"
103-
104-
},
105-
"drupal/coc_forms_auto_export": {
106-
"3240592 - Problem with phpseclib requirement in 2.x (https://www.drupal.org/project/coc_forms_auto_export/issues/3240592)": "https://www.drupal.org/files/issues/2021-10-04/requirement-namespace-3240592-1.patch",
107-
"3286562 - Automated Drupal 10 compatibility fixes" : "https://www.drupal.org/files/issues/2022-06-15/coc_forms_auto_export.2.0.x-dev.rector.patch",
108-
"3259009 - PHP Warnings/Notices on Download Page" : "https://git.drupalcode.org/project/coc_forms_auto_export/-/merge_requests/1.diff"
109-
},
110-
"drupal/webform_node_element": {
111-
"3290637 - Automated Drupal 10 compatibility fixes": "https://www.drupal.org/files/issues/2023-05-12/webform_node_element_d10-3290637-11.patch"
112128
},
113129
"drupal/webform_encrypt": {
114130
"Ensure data is base64 encoded (https://www.drupal.org/project/webform_encrypt/issues/3399414)": "https://git.drupalcode.org/project/webform_encrypt/-/merge_requests/4.patch",
115131
"PHP Warning if unserialize fails (https://www.drupal.org/project/webform_encrypt/issues/3292305)": "https://www.drupal.org/files/issues/2022-06-23/unserialize-php-notice.patch"
132+
},
133+
"drupal/webform_node_element": {
134+
"3290637 - Automated Drupal 10 compatibility fixes": "https://www.drupal.org/files/issues/2023-05-12/webform_node_element_d10-3290637-11.patch"
116135
}
117-
},
118-
"drupal-lenient": {
119-
"allowed-list": [
120-
"drupal/coc_forms_auto_export",
121-
"drupal/webform_node_element"
122-
]
123136
}
124137
},
125138
"scripts": {
126-
"code-analysis/phpstan": [
127-
"phpstan analyse"
128-
],
129139
"code-analysis": [
130140
"@code-analysis/phpstan"
131141
],
132-
"coding-standards-check/phpcs": [
133-
"phpcs --standard=phpcs.xml.dist"
142+
"code-analysis/phpstan": [
143+
"phpstan analyse"
134144
],
135-
"coding-standards-check": [
136-
"@coding-standards-check/phpcs"
145+
"coding-standards-apply": [
146+
"@coding-standards-apply/phpcs"
137147
],
138148
"coding-standards-apply/phpcs": [
139149
"phpcbf --standard=phpcs.xml.dist"
140150
],
141-
"coding-standards-apply": [
142-
"@coding-standards-apply/phpcs"
151+
"coding-standards-check": [
152+
"@coding-standards-check/phpcs"
153+
],
154+
"coding-standards-check/phpcs": [
155+
"phpcs --standard=phpcs.xml.dist"
143156
]
144-
},
145-
"config": {
146-
"sort-packages": true,
147-
"allow-plugins": {
148-
"cweagans/composer-patches": true,
149-
"dealerdirect/phpcodesniffer-composer-installer": true,
150-
"phpstan/extension-installer": true,
151-
"simplesamlphp/composer-module-installer": true,
152-
"vaimo/composer-patches": true,
153-
"zaporylie/composer-drupal-optimizations": true,
154-
"mglaman/composer-drupal-lenient": true
155-
}
156157
}
157158
}

modules/os2forms_attachment/README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
# OS2Forms Attachment Drupal module
22

3-
# Module purpose
3+
## Module purpose
44

55
The aim of this module is to provide an OS2forms attachment element for adding PDF/HTML attachment.
66

77
It also supports creation of reusable headers/footers components which are used when rendering the attachments.
88

9-
# How does it work
9+
## How does it work
1010

11-
To add custom headers/footer ```admin/structure/webform/config/os2forms_attachment_component```
11+
To add custom headers/footer `admin/structure/webform/config/os2forms_attachment_component`
1212

13-
To specify headers/footers that will override the default ones on a global level (**Third party settings** -> **Entity print** section): ```admin/structure/webform/config```
13+
To specify headers/footers that will override the default ones on a global level (**Third party settings** -> **Entity
14+
print** section): `admin/structure/webform/config`
1415

15-
To specify headers/footers that will override the default ones on a form level (**Third party settings** -> **Entity print** section): ```/admin/structure/webform/manage/[webform]/settings```
16+
To specify headers/footers that will override the default ones on a form level (**Third party settings** -> **Entity
17+
print** section): ```/admin/structure/webform/manage/[webform]/settings```
1618

17-
# Overwriting templates
19+
## Overwriting templates
1820

1921
With some setups it might be necessary to overwrite templates
2022
in order to access stylesheets or images.

0 commit comments

Comments
 (0)