From 3c99c06d48f9813b156dcd45a10091ff42bdfcd9 Mon Sep 17 00:00:00 2001 From: Sebastiaan Stok Date: Sat, 4 Nov 2023 21:00:55 +0100 Subject: [PATCH 1/5] Normalize composer.json --- composer.json | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/composer.json b/composer.json index 9e61af8..7f29291 100644 --- a/composer.json +++ b/composer.json @@ -1,9 +1,13 @@ { "name": "rollerworks/password-common-list", "description": "Password CommonList validator for Symfony", - "keywords": ["password", "validator", "symfony"], - "type": "library", "license": "MIT", + "type": "library", + "keywords": [ + "password", + "validator", + "symfony" + ], "authors": [ { "name": "Sebastiaan Stok", @@ -26,29 +30,32 @@ "symfony/framework-bundle": "^5.3 || ^6.0 || ^7.0", "symfony/phpunit-bridge": "^5.3 || ^6.0 || ^7.0" }, + "minimum-stability": "dev", + "prefer-stable": true, "autoload": { "psr-4": { - "Rollerworks\\Component\\PasswordCommonList\\": "src/", - "Rollerworks\\Bundle\\PasswordCommonListBundle\\": "src/Bundle" + "Rollerworks\\Bundle\\PasswordCommonListBundle\\": "src/Bundle", + "Rollerworks\\Component\\PasswordCommonList\\": "src/" }, - "exclude-from-classmap": ["test/", "Resources/"] + "exclude-from-classmap": [ + "test/", + "Resources/" + ] }, "autoload-dev": { "psr-4": { "Rollerworks\\Component\\PasswordCommonList\\Tests\\": "tests/" } }, - "extra": { - "branch-alias": { - "dev-main": "1.0-dev" - } - }, "config": { "preferred-install": { "*": "dist" }, "sort-packages": true }, - "minimum-stability": "dev", - "prefer-stable": true + "extra": { + "branch-alias": { + "dev-main": "1.0-dev" + } + } } From 9e8f95c5c156e36d7e3c6de5d1c504cfcbc1ef1f Mon Sep 17 00:00:00 2001 From: Sebastiaan Stok Date: Sat, 4 Nov 2023 21:02:11 +0100 Subject: [PATCH 2/5] Update workflow versions --- .github/workflows/ci.yaml | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 464be35..2b08757 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -22,7 +22,7 @@ jobs: steps: - name: 'Check out' - uses: 'actions/checkout@v2' + uses: 'actions/checkout@v4' - name: 'Set up PHP' @@ -34,23 +34,23 @@ jobs: - name: 'Get Composer cache directory' id: 'composer-cache' - run: 'echo "::set-output name=cache-dir::$(composer config cache-files-dir)"' + run: 'echo "cache_dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT' - name: 'Cache dependencies' - uses: 'actions/cache@v2' + uses: 'actions/cache@v3' with: - path: '${{ steps.composer-cache.outputs.cache-dir }}' + path: '${{ steps.composer-cache.outputs.cache_dir }}' key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}" restore-keys: 'php-${{ matrix.php-version }}-composer-locked-' - name: 'Install dependencies' - run: 'composer update --no-progress --prefer-stable' + run: 'composer install --no-progress' - name: 'Check the code style' - run: 'make cs-full' + run: 'make cs' phpstan: name: 'PhpStan' @@ -65,7 +65,7 @@ jobs: steps: - name: 'Check out' - uses: 'actions/checkout@v2' + uses: 'actions/checkout@v4' - name: 'Set up PHP' @@ -77,19 +77,19 @@ jobs: - name: 'Get Composer cache directory' id: 'composer-cache' - run: 'echo "::set-output name=cache-dir::$(composer config cache-files-dir)"' + run: 'echo "cache_dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT' - name: 'Cache dependencies' - uses: 'actions/cache@v2' + uses: 'actions/cache@v3' with: - path: '${{ steps.composer-cache.outputs.cache-dir }}' + path: '${{ steps.composer-cache.outputs.cache_dir }}' key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}" restore-keys: 'php-${{ matrix.php-version }}-composer-locked-' - name: 'Install dependencies' - run: 'composer update --no-progress --prefer-stable' + run: 'composer install --no-progress' - name: 'Run PhpStan' @@ -104,14 +104,9 @@ jobs: matrix: include: - - php-version: '8.0' + php-version: '8.1' composer-options: '--prefer-stable' - symfony-version: '5.4' - - - - php-version: '8.0' - composer-options: '--prefer-stable' - symfony-version: '6.0' + symfony-version: '6.3' - php-version: '8.2' composer-options: '--prefer-stable' @@ -125,7 +120,7 @@ jobs: steps: - name: 'Check out' - uses: 'actions/checkout@v2' + uses: 'actions/checkout@v4' - name: 'Set up PHP' @@ -137,13 +132,13 @@ jobs: - name: 'Get Composer cache directory' id: 'composer-cache' - run: 'echo "::set-output name=cache-dir::$(composer config cache-files-dir)"' + run: 'echo "cache_dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT' - name: 'Cache dependencies' - uses: 'actions/cache@v2' + uses: 'actions/cache@v3' with: - path: '${{ steps.composer-cache.outputs.cache-dir }}' + path: '${{ steps.composer-cache.outputs.cache_dir }}' key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}" restore-keys: 'php-${{ matrix.php-version }}-composer-locked-' From 1800beb1d787ad2a749ca564bbcd43195f68af61 Mon Sep 17 00:00:00 2001 From: Sebastiaan Stok Date: Sat, 4 Nov 2023 21:07:14 +0100 Subject: [PATCH 3/5] Switch to rollerscapes/standards Used for PHP-CS-Fixer, PHPStan, Makefile --- .github/workflows/ci.yaml | 7 +-- .php-cs-fixer.dist.php | 63 ++----------------- Makefile | 30 +-------- composer.json | 1 + phpstan.neon | 8 ++- .../NotInPasswordCommonListTest.php | 3 + 6 files changed, 17 insertions(+), 95 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2b08757..cb9a946 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -152,11 +152,6 @@ jobs: composer global require --no-progress --no-scripts --no-plugins symfony/flex composer update --no-progress $COMPOSER_OPTIONS - - - name: 'Install PHPUnit' - run: 'vendor/bin/simple-phpunit install' - - name: 'Run tests' - run: | - vendor/bin/simple-phpunit + run: make phpunit diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index f44a4b4..c005201 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -19,64 +19,11 @@ $config = new PhpCsFixer\Config(); $config ->setRiskyAllowed(true) - ->setRules([ - '@PhpCsFixer' => true, - '@PhpCsFixer:risky' => true, - '@Symfony' => true, - '@Symfony:risky' => true, - '@PHP73Migration' => true, - '@PHPUnit84Migration:risky' => true, - '@DoctrineAnnotation' => true, - 'blank_line_before_statement' => [ - 'statements' => [ - 'break', - 'case', - 'continue', - 'declare', - 'default', - 'do', - 'exit', - 'for', - 'foreach', - 'goto', - 'if', - 'include', - 'include_once', - 'require', - 'require_once', - 'return', - 'switch', - 'throw', - 'try', - 'while', - ], - ], - 'comment_to_phpdoc' => ['ignored_tags' => ['codeCoverageIgnoreStart', 'codeCoverageIgnoreEnd']], - 'concat_space' => ['spacing' => 'one'], - 'doctrine_annotation_array_assignment' => ['operator' => '='], - 'general_phpdoc_annotation_remove' => ['annotations' => ['author', 'since', 'package', 'subpackage']], - 'header_comment' => ['header' => $header], - 'list_syntax' => ['syntax' => 'short'], - 'mb_str_functions' => true, - 'method_argument_space' => ['on_multiline' => 'ignore'], - 'method_chaining_indentation' => false, - 'no_extra_blank_lines' => ['tokens' => ['extra', 'use_trait']], - 'no_superfluous_phpdoc_tags' => ['remove_inheritdoc' => true], - 'not_operator_with_successor_space' => true, - 'ordered_class_elements' => false, - 'ordered_imports' => true, - 'php_unit_method_casing' => ['case' => 'snake_case'], - 'php_unit_strict' => false, - 'php_unit_test_annotation' => ['style' => 'annotation'], - 'php_unit_test_class_requires_covers' => false, - 'phpdoc_to_comment' => false, - 'phpdoc_var_without_name' => false, - 'self_static_accessor' => true, - 'single_line_throw' => false, - 'static_lambda' => true, - 'strict_comparison' => false, - 'yoda_style' => ['equal' => false, 'identical' => false], - ]) + ->setRules( + array_merge( + require __DIR__ . '/vendor/rollerscapes/standards/php-cs-fixer-rules.php', + ['header_comment' => ['header' => $header]]) + ) ->setFinder($finder); return $config; diff --git a/Makefile b/Makefile index ce59175..7af6b83 100644 --- a/Makefile +++ b/Makefile @@ -1,29 +1 @@ -QA_DOCKER_IMAGE=jakzal/phpqa:1.59.1-php7.4-alpine -QA_DOCKER_COMMAND=docker run --init -t --rm --user "$(shell id -u):$(shell id -g)" --volume /tmp/tmp-phpqa-$(shell id -u):/tmp --volume "$(shell pwd):/project" --workdir /project ${QA_DOCKER_IMAGE} - -dist: install cs-full phpstan test-full -lint: install cs-full phpstan - -install: - composer install --no-progress --no-interaction --no-suggest --optimize-autoloader --prefer-dist --ansi - -test: - ./vendor/bin/phpunit --verbose - -# Linting tools -phpstan: ensure - sh -c "${QA_DOCKER_COMMAND} phpstan analyse --configuration phpstan.neon" - -cs: ensure - sh -c "${QA_DOCKER_COMMAND} php-cs-fixer fix -vvv --diff" - -cs-full: ensure - sh -c "${QA_DOCKER_COMMAND} php-cs-fixer fix -vvv --using-cache=false --diff" - -cs-full-check: ensure - sh -c "${QA_DOCKER_COMMAND} php-cs-fixer fix -vvv --using-cache=false --diff --dry-run" - -ensure: - mkdir -p ${HOME}/.composer /tmp/tmp-phpqa-$(shell id -u) - -.PHONY: install test phpstan cs cs-full cs-full-check +include vendor/rollerscapes/standards/Makefile diff --git a/composer.json b/composer.json index 7f29291..f7aa2a5 100644 --- a/composer.json +++ b/composer.json @@ -27,6 +27,7 @@ "phpstan/phpstan": "^1.10.39", "phpstan/phpstan-phpunit": "1.3.15", "phpunit/phpunit": "^9.5", + "rollerscapes/standards": "^1.0", "symfony/framework-bundle": "^5.3 || ^6.0 || ^7.0", "symfony/phpunit-bridge": "^5.3 || ^6.0 || ^7.0" }, diff --git a/phpstan.neon b/phpstan.neon index 4737151..b377b7f 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,11 +1,15 @@ includes: - - vendor/phpstan/phpstan-phpunit/extension.neon + - vendor/rollerscapes/standards/phpstan.neon + #- phpstan-baseline.neon parameters: level: 5 + #reportUnmatchedIgnoredErrors: false + paths: - ./src + - ./tests excludePaths: - ./src/Resources - ignoreErrors: + #ignoreErrors: diff --git a/tests/Constraints/NotInPasswordCommonListTest.php b/tests/Constraints/NotInPasswordCommonListTest.php index 555eda4..e9368f8 100644 --- a/tests/Constraints/NotInPasswordCommonListTest.php +++ b/tests/Constraints/NotInPasswordCommonListTest.php @@ -105,6 +105,9 @@ public function __toString(): string ; } + /** + * @return iterable + */ public function provide_unsafe_passwords(): iterable { yield ['hunter']; From f8dd9584a008f389867386d09028155b788bd921 Mon Sep 17 00:00:00 2001 From: Sebastiaan Stok Date: Sat, 4 Nov 2023 21:13:02 +0100 Subject: [PATCH 4/5] Fix contribution links in README.md --- README.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 9193c7e..97e7681 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,8 @@ To install this package, add `rollerworks/password-common-list` to your composer $ php composer.phar require rollerworks/password-common-list ``` -Now, [Composer] will automatically download all required files, and install them -for you. +Now, [Composer][composer] will automatically download all required files, +and install them for you. **Note:** To use this library with a Symfony Application make sure the `\Rollerworks\Bundle\PasswordCommonListBundle\RollerworksPasswordCommonListBundle` is enabled. @@ -62,11 +62,12 @@ This library is released under the [MIT license](LICENSE). ## Contributing This is an open source project. If you'd like to contribute, -please read the [Contributing Guidelines]. If you're submitting -a pull request, please follow the guidelines in the [Submitting a Patch] section. +please read the [Contributing Guidelines][contributing]. If you're submitting +a pull request, please follow the guidelines in the [Submitting a Patch][patches] section. [Symfony Validator]: (http://symfony.com/doc/current/components/validator.html [xato-net-10-million-passwords-1000000]: https://github.com/danielmiessler/SecLists/tree/master/Passwords -[Composer]: https://getcomposer.org/doc/00-intro.md -[Contributing Guidelines]: https://github.com/rollerworks/contributing -[Submitting a Patch]: https://contributing.readthedocs.org/en/latest/code/patches.html +[composer]: https://getcomposer.org/doc/00-intro.md +[flex]: https://symfony.com/doc/current/setup/flex.html +[contributing]: https://contributing.rollerscapes.net/ +[patches]: https://contributing.rollerscapes.net/latest/patches.html From 62c3ed4771c7d80221967f586e8f5dc9a0554032 Mon Sep 17 00:00:00 2001 From: Sebastiaan Stok Date: Sat, 4 Nov 2023 21:15:05 +0100 Subject: [PATCH 5/5] Fix CS --- .../NotInPasswordCommonListTest.php | 26 +++++-------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/tests/Constraints/NotInPasswordCommonListTest.php b/tests/Constraints/NotInPasswordCommonListTest.php index e9368f8..7fe3328 100644 --- a/tests/Constraints/NotInPasswordCommonListTest.php +++ b/tests/Constraints/NotInPasswordCommonListTest.php @@ -30,8 +30,7 @@ protected function createValidator(): ConstraintValidatorInterface return new NotInPasswordCommonListValidator(); } - /** @test */ - public function it_ignores_empty_values(): void + public function test_it_ignores_empty_values(): void { $this->validator->validate(null, new NotInPasswordCommonList()); $this->assertNoViolation(); @@ -51,8 +50,7 @@ public function __toString(): string $this->assertNoViolation(); } - /** @test */ - public function no_violation_for_unlisted_password(): void + public function test_no_violation_for_unlisted_password(): void { $this->validator->validate('#*Xqz%<*8wHi', new NotInPasswordCommonList()); $this->assertNoViolation(); @@ -61,12 +59,8 @@ public function no_violation_for_unlisted_password(): void $this->assertNoViolation(); } - /** - * @test - * - * @dataProvider provide_unsafe_passwords - */ - public function it_raises_a_violation_for_common_used_password_as_string(string $password): void + /** @dataProvider provide_unsafe_passwords */ + public function test_it_raises_a_violation_for_common_used_password_as_string(string $password): void { $this->validator->validate($password, $constraint = new NotInPasswordCommonList()); @@ -76,12 +70,8 @@ public function it_raises_a_violation_for_common_used_password_as_string(string ; } - /** - * @test - * - * @dataProvider provide_unsafe_passwords - */ - public function it_raises_a_violation_for_common_used_password_as_stringable(string $password): void + /** @dataProvider provide_unsafe_passwords */ + public function test_it_raises_a_violation_for_common_used_password_as_stringable(string $password): void { $value = new class($password) implements \Stringable { private string $password; @@ -105,9 +95,7 @@ public function __toString(): string ; } - /** - * @return iterable - */ + /** @return iterable */ public function provide_unsafe_passwords(): iterable { yield ['hunter'];