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
5 changes: 3 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@
"requireReturn": false
}],
"no-unused-vars": ["warn"],
"operator-linebreak": ["error", "after", { "overrides": { "?": "ignore", ":": "ignore" } }]
"operator-linebreak": ["error", "after", { "overrides": { "?": "ignore", ":": "ignore" } }],
"no-multiple-empty-lines": ["error"]
},
"ignorePatterns": [
"vendor/*",
"config/*",
"resources/docker",
"tests/fixtures"
"tests/fixtures/samples/sample-docker*.yml"
],
"overrides": [
{
Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Toolkit change log

## Version 10.29.1
- DQA-0000: Add xdebug_break() to the list of forbidden functions.
- DQA-14193: Gitleaks improvements

## Version 10.28.0
- DQA-13950: Remove dependency on ec-europa/qa-automation and add support to coder 9.
- DQA-13914: Validate SHA256 of gitleaks binary after download.
- DQA-13914: Verify SHA1 after dump is downloaded and retry in case of issues during download.
- DQA-14171: Improvements run-tests commands.

## Version 10.27.0
- DQA-13733: Set new gitlab & nextcloud urls.
- DQA-13747: Support Coder 9.0.
- DQA-13741: PHP 8.5 compatibility.
- DQA-13613: Check composer-patches v2.
- DQA-13523: Adapt DQA for new gitlab instance.
- DQA-13626: Improve database default values.
- DQA-13253: Prevent usage of eslint >=9, to align with drupal/core.

## Version 10.26.2
- DROPSEC-16324: Fix opts.yml loader default.
- DQA-13173: Added dependency required by Drupal 11.3.x.
Expand Down
11 changes: 6 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
"dantleech/gherkin-lint": "^0.2.3",
"drupal/coder": "^8.3.10",
"drush/drush": "^11.0.4 || ^12.0 || ^13.0",
"ec-europa/qa-automation": "^9.4.0",
"ec-europa/toolkit-composer-plugin": "^0.0.1",
"guzzlehttp/guzzle": "^6.3 || ^7.0",
"jakeasmith/http_build_url": "^1.0",
Expand All @@ -56,11 +55,13 @@
"moodlehq/moodle-plugin-ci": "^4.5",
"pear/archive_tar": "^1.4",
"php-parallel-lint/php-parallel-lint": "^1.3",
"phpcompatibility/php-compatibility": "^9.3 || ^10.0@alpha",
"phpmd/phpmd": "^2.12",
"phpstan/phpstan": "^1.12.15 || ^2.1",
"phpstan/phpstan-deprecation-rules": "^1.0 || ^2.0",
"phpunit/phpunit": "^9.5 || ^10.0 || ^11.0",
"squizlabs/php_codesniffer": "^3.7",
"squizlabs/php_codesniffer": "^3.7 || ^4.0",
"symfony/yaml": "^5.0 || ^6.0 || ^7.0",
"vlucas/phpdotenv": "^5.6"
},
"suggest": {
Expand Down Expand Up @@ -89,13 +90,13 @@
}
},
"scripts": {
"toolkit-update-phpcs-config": "$(pwd)/vendor/bin/phpcs --config-set installed_paths '../../drupal/coder/coder_sniffer,../../phpcompatibility/php-compatibility,../../ec-europa/qa-automation/phpcs'",
"toolkit-update-phpcs-config": "$(pwd)/vendor/bin/phpcs --config-set installed_paths '../../drupal/coder/coder_sniffer,../../phpcompatibility/php-compatibility'",
"post-install-cmd": [
"./vendor/bin/phpcs --config-set installed_paths '../../drupal/coder/coder_sniffer,../../phpcompatibility/php-compatibility,phpcs,../../ec-europa/qa-automation/phpcs'",
"./vendor/bin/phpcs --config-set installed_paths '../../drupal/coder/coder_sniffer,../../phpcompatibility/php-compatibility,phpcs'",
"php -r \"file_exists('vendor/bin/run') || (copy('run', 'vendor/bin/run') && chmod('vendor/bin/run', fileperms('run')));\""
],
"post-update-cmd": [
"./vendor/bin/phpcs --config-set installed_paths '../../drupal/coder/coder_sniffer,../../phpcompatibility/php-compatibility,phpcs,../../ec-europa/qa-automation/phpcs'",
"./vendor/bin/phpcs --config-set installed_paths '../../drupal/coder/coder_sniffer,../../phpcompatibility/php-compatibility,phpcs'",
"php -r \"file_exists('vendor/bin/run') || (copy('run', 'vendor/bin/run') && chmod('vendor/bin/run', fileperms('run')));\""
]
}
Expand Down
5 changes: 1 addition & 4 deletions config/commands/code-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,4 @@ command:
requirements: false
run-tests:
options:
phpunit: false
behat: false
blackfire: false
components: false
type: ${toolkit.run-tests.type}
3 changes: 3 additions & 0 deletions config/commands/gitleaks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@ command:
run-gitleaks:
options:
tag: ${gitleaks.tag}
sha256: ${gitleaks.sha256}
os: ${gitleaks.os}
options: ${gitleaks.options}
ignore-file: ${gitleaks.ignore-file}
report-to-file: ${gitleaks.report-to-file}
7 changes: 7 additions & 0 deletions config/runner/gitleaks.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
gitleaks:
repo: https://github.com/gitleaks/gitleaks
tag: 8.27.2
sha256: 141c3b2dede46d8b3a53b47116da756bd223decc0374797559a6b50ecba5590c
os: linux_x64
options: '--no-banner -v --no-git --follow-symlinks'
ignore-file: '.leaksignore'
report-to-file: false
fields:
- File
- Fingerprint
- ToolkitFingerprint
13 changes: 12 additions & 1 deletion config/runner/toolkit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ toolkit:
standards:
- ./vendor/drupal/coder/coder_sniffer/Drupal
- ./vendor/drupal/coder/coder_sniffer/DrupalPractice
- ./vendor/ec-europa/qa-automation/phpcs/QualityAssurance
- ./vendor/ec-europa/toolkit/phpcs/QualityAssurance
ignore_patterns:
- ${toolkit.build.dist.root}/
- .cache/
Expand Down Expand Up @@ -126,3 +126,14 @@ toolkit:
allow-list: axe-scan-allowlist.csv
run-summary: true
summary-result-file: axe-scan-summary.csv
run-tests:
type: clone
phpunit:
clone: false
clean: false
behat:
clone: true
clean: true
blackfire:
clone: false
clean: false
3 changes: 2 additions & 1 deletion config/runner/toolkit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ toolkit:
mydumper: '/scripts/backupdb.sh'
type: 'nextcloud'
show_progress: false
download_retries: 3
nextcloud:
# Nextcloud supports the following services: mysql, virtuoso, solr.
services: 'mysql'
url: 'files.fpfis.tech.ec.europa.eu/remote.php/dav/files'
url: 'files.dhs.tech.ec.europa.eu/remote.php/dav/files'
admin: false
vendor: 'ec-europa'
source: 'reference'
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
web:
image: registry.fpfis.eu/digit/devsecops/httpd-php:8.3-ci
image: registry.dhs.tech.ec.europa.eu/digit/devsecops/httpd-php:8.3-ci
working_dir: /__w/toolkit/toolkit
ports:
# Use port "8080:8080" to access the mock in the browser OR to use xdebug.
Expand Down
4 changes: 2 additions & 2 deletions docs/guide/testing-project.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ This will enforce the usage of the following standards:

vendor/drupal/coder/coder_sniffer/Drupal
vendor/drupal/coder/coder_sniffer/DrupalPractice
vendor/ec-europa/qa-automation/phpcs/QualityAssurance
vendor/ec-europa/toolkit/phpcs/QualityAssurance

These are the default configurations that can be overridden in the `runner.yml.dist and/or runner.yml <runner-yml_>`_ file.

Expand All @@ -126,7 +126,7 @@ These are the default configurations that can be overridden in the `runner.yml.d
standards:
- ./vendor/drupal/coder/coder_sniffer/Drupal
- ./vendor/drupal/coder/coder_sniffer/DrupalPractice
- ./vendor/ec-europa/qa-automation/phpcs/QualityAssurance
- ./vendor/ec-europa/toolkit/phpcs/QualityAssurance
ignore_patterns:
- vendor/
- web/
Expand Down
30 changes: 2 additions & 28 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
<exclude-pattern>tests/fixtures/</exclude-pattern>
<exclude-pattern>tests/sandbox/</exclude-pattern>

<rule ref="MySource.Debug.DebugCode"/>

<!-- Generic. -->
<rule ref="Generic">
<exclude name="Generic.Arrays.ArrayIndent.CloseBraceNotNewLine"/>
Expand All @@ -37,12 +35,14 @@
<exclude name="Generic.Commenting.DocComment.ContentAfterOpen"/>
<exclude name="Generic.Commenting.DocComment.MissingShort"/>
<exclude name="Generic.Commenting.DocComment.SpacingBetween"/>
<exclude name="Generic.Commenting.DocComment.TagsNotGrouped"/>
<exclude name="Generic.Files.EndFileNoNewline.Found"/>
<exclude name="Generic.Files.LowercasedFilename.NotFound"/>
<exclude name="Generic.Files.LineLength.TooLong"/>
<exclude name="Generic.Functions.OpeningFunctionBraceKernighanRitchie.BraceOnNewLine"/>
<exclude name="Generic.Functions.OpeningFunctionBraceBsdAllman.BraceOnSameLine"/>
<exclude name="Generic.Formatting.MultipleStatementAlignment.NotSameWarning"/>
<exclude name="Generic.Formatting.MultipleStatementAlignment.NotSame"/>
<exclude name="Generic.Formatting.NoSpaceAfterCast.SpaceFound"/>
<exclude name="Generic.Formatting.SpaceBeforeCast.NoSpace"/>
<exclude name="Generic.PHP.ClosingPHPTag.NotFound"/>
Expand Down Expand Up @@ -241,26 +241,6 @@
<severity>0</severity>
</rule>

<rule ref="Squiz.CSS.ClassDefinitionClosingBraceSpace"/>
<rule ref="Squiz.CSS.ClassDefinitionClosingBraceSpace.SpacingAfterClose">
<severity>0</severity>
</rule>
<rule ref="Squiz.CSS.ClassDefinitionOpeningBraceSpace"/>
<rule ref="Squiz.CSS.ClassDefinitionOpeningBraceSpace.AfterNesting">
<severity>0</severity>
</rule>
<rule ref="Squiz.CSS.ColonSpacing"/>
<rule ref="Squiz.CSS.DisallowMultipleStyleDefinitions"/>
<rule ref="Squiz.CSS.EmptyClassDefinition"/>
<rule ref="Squiz.CSS.EmptyStyleDefinition"/>
<rule ref="Squiz.CSS.Indentation">
<properties>
<property name="indent" value="2"/>
</properties>
</rule>
<rule ref="Squiz.CSS.MissingColon"/>
<rule ref="Squiz.CSS.SemicolonSpacing"/>

<rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing">
<properties>
<property name="equalsSpacing" value="1"/>
Expand Down Expand Up @@ -300,7 +280,6 @@
<property name="spacing" value="1"/>
</properties>
</rule>
<rule ref="Squiz.WhiteSpace.LanguageConstructSpacing"/>
<rule ref="Squiz.WhiteSpace.OperatorSpacing">
<properties>
<property name="ignoreNewlines" value="true"/>
Expand All @@ -312,9 +291,6 @@

<!-- Drupal. -->
<rule ref="Drupal.Classes.FullyQualifiedNamespace"/>
<rule ref="Drupal.Classes.UnusedUseStatement"/>
<rule ref="Drupal.Classes.UseLeadingBackslash"/>
<rule ref="Drupal.Commenting.DataTypeNamespace"/>
<rule ref="Drupal.Commenting.DocComment"/>
<rule ref="Drupal.Commenting.DocCommentAlignment.SpaceAfterStar"/>
<rule ref="Drupal.Commenting.DocCommentStar"/>
Expand All @@ -332,9 +308,7 @@
<rule ref="Drupal.NamingConventions"/>
<rule ref="Drupal.Scope"/>
<rule ref="Drupal.Semantics"/>
<rule ref="Drupal.Strings"/>

<rule ref="DrupalPractice.CodeAnalysis"/>
<rule ref="DrupalPractice.Commenting"/>
<rule ref="DrupalPractice.Constants"/>
<rule ref="DrupalPractice.FunctionCalls"/>
Expand Down
76 changes: 76 additions & 0 deletions phpcs/QualityAssurance/Sniffs/Functions/DrupalDeprecatedSniff.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php
/**
* \QualityAssurance\Sniffs\Functions\DrupalDeprecatedSniff.
*
* @category PHP
* @package PHP_CodeSniffer
* @link http://pear.php.net/package/PHP_CodeSniffer
*/

namespace QualityAssurance\Sniffs\Functions;

use PHP_CodeSniffer\Files\File;
use PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\DeprecatedFunctionsSniff;

/**
* \QualityAssurance\Sniffs\Functions\DrupalDeprecatedSniff.
*
* Discourage the use of functions that are marked as deprecated.
*
* @category PHP
* @package PHP_CodeSniffer
* @link http://pear.php.net/package/PHP_CodeSniffer
*/
class DrupalDeprecatedSniff extends DeprecatedFunctionsSniff
{

/**
* A list of deprecated functions with their alternatives.
*
* The value is NULL if no alternative exists, i.e., the function should
* just not be used.
*
* @var array|null
*/
public $forbiddenFunctions = ['debug' => 'dump'];

/**
* If true, an error will be thrown; otherwise a warning.
*
* @var boolean
*/
public $error = true;


/**
* Generates the error or warning for this sniff.
*
* @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
* @param int $stackPtr The position of the forbidden function
* in the token array.
* @param string $function The name of the forbidden function.
* @param string $pattern The pattern used for the match.
*
* @return void
*/
protected function addError($phpcsFile, $stackPtr, $function, $pattern=null)
{
$data = [$function];
$error = 'Function %s() has been deprecated';
$type = 'Deprecated';

if (empty($this->forbiddenFunctions[$function]) === false) {
$data[] = $this->forbiddenFunctions[$function];
$error .= '; use %s() instead';
}

if ($this->error === true) {
$phpcsFile->addError($error, $stackPtr, $type, $data);
} else {
$phpcsFile->addWarning($error, $stackPtr, $type, $data);
}

}//end addError()


}//end class
Loading
Loading