Skip to content
This repository has been archived by the owner on Aug 14, 2021. It is now read-only.

Commit

Permalink
update coding standard (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
mimmi20 committed Aug 3, 2021
1 parent e0120f7 commit a8936dd
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 37 deletions.
6 changes: 4 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ updates:
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "daily"
interval: "weekly"
day: "wednesday"
time: "04:00"
timezone: "Europe/Berlin"
open-pull-requests-limit: 10
Expand All @@ -31,7 +32,8 @@ updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
interval: "weekly"
day: "wednesday"
time: "04:00"
timezone: "Europe/Berlin"
open-pull-requests-limit: 10
Expand Down
92 changes: 66 additions & 26 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
run: "composer-normalize --dry-run"

install:
name: "Check dependencies"
name: "Install dependencies"

needs: "validate"

Expand Down Expand Up @@ -100,7 +100,7 @@ jobs:
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"

- name: "Update dependencies with composer"
run: "composer update --optimize-autoloader --prefer-dist --prefer-stable --no-progress --no-interaction -vv --ansi ${{ matrix.dependencies }}"
run: "composer update --optimize-autoloader --prefer-dist --prefer-stable --no-progress --no-interaction -v --ansi ${{ matrix.dependencies }}"

- name: "Check dependencies with composer"
run: "composer outdated --direct --strict"
Expand Down Expand Up @@ -152,7 +152,7 @@ jobs:
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"

- name: "Update dependencies with composer"
run: "composer update --optimize-autoloader --prefer-dist --prefer-stable --no-progress --no-interaction -vv --ansi ${{ matrix.dependencies }}"
run: "composer update --optimize-autoloader --prefer-dist --prefer-stable --no-progress --no-interaction -v --ansi ${{ matrix.dependencies }}"

- name: "Run friendsofphp/php-cs-fixer"
run: "vendor/bin/php-cs-fixer fix --dry-run -vv"
Expand Down Expand Up @@ -204,7 +204,7 @@ jobs:
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"

- name: "Update dependencies with composer"
run: "composer update --optimize-autoloader --prefer-dist --prefer-stable --no-progress --no-interaction -vv --ansi ${{ matrix.dependencies }}"
run: "composer update --optimize-autoloader --prefer-dist --prefer-stable --no-progress --no-interaction -v --ansi ${{ matrix.dependencies }}"

- name: "Run squizlabs/php_codesniffer"
uses: "chekalsky/[email protected]"
Expand Down Expand Up @@ -257,11 +257,63 @@ jobs:
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"

- name: "Update dependencies with composer"
run: "composer update --optimize-autoloader --prefer-dist --prefer-stable --no-progress --no-interaction -vv --ansi ${{ matrix.dependencies }}"
run: "composer update --optimize-autoloader --prefer-dist --prefer-stable --no-progress --no-interaction -v --ansi ${{ matrix.dependencies }}"

- name: "Run phpstan/phpstan"
run: "vendor/bin/phpstan analyse -c phpstan.neon --memory-limit=768M --no-progress"

phpmd:
name: "Check Rules with PHPMD"

needs: "install"

runs-on: "${{ matrix.operating-system }}"

continue-on-error: false

strategy:
fail-fast: false

matrix:
operating-system:
- "ubuntu-20.04"

php-version:
- "7.4"

dependencies:
- ""

steps:
- name: "Checkout"
uses: "actions/[email protected]"

- name: "Install PHP"
uses: "shivammathur/[email protected]"
with:
php-version: "${{ matrix.php-version }}"
extensions: "${{ env.PHP_EXTENSIONS }}"
ini-values: "${{ env.PHP_INI_VALUES }}"
coverage: "none"
tools: "composer:v2"

- name: "Determine composer cache directory"
id: "determine-composer-cache-directory"
run: "echo \"::set-output name=directory::$(composer config cache-dir)\""

- name: "Cache dependencies installed with composer"
uses: "actions/[email protected]"
with:
path: "${{ steps.determine-composer-cache-directory.outputs.directory }}"
key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}"
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"

- name: "Update dependencies with composer"
run: "composer update --optimize-autoloader --prefer-dist --prefer-stable --no-progress --no-interaction -v --ansi ${{ matrix.dependencies }}"

- name: "Run phpmd/phpmd"
run: "vendor/bin/phpmd src github phpmd.ruleset.xml"

tests:
name: "UnitTests with PHPUnit"

Expand All @@ -278,29 +330,17 @@ jobs:
operating-system:
- "ubuntu-18.04"
- "ubuntu-20.04"
- "windows-2019"
- "macos-10.15"

php-version:
- "7.4"
- "8.0"

dependencies:
- ""

continue-on-error:
- false

include:
- operating-system: "ubuntu-20.04"
php-version: "8.0"
continue-on-error: true
- operating-system: "windows-2019"
php-version: "8.0"
continue-on-error: true
- operating-system: "macos-10.15"
php-version: "8.0"
continue-on-error: true

steps:
- name: "Checkout"
uses: "actions/[email protected]"
Expand All @@ -326,10 +366,10 @@ jobs:
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"

- name: "Update dependencies with composer"
run: "composer update --optimize-autoloader --prefer-dist --prefer-stable --no-progress --no-interaction -vv --ansi ${{ matrix.dependencies }}"
run: "composer update --optimize-autoloader --prefer-dist --prefer-stable --no-progress --no-interaction -v --ansi ${{ matrix.dependencies }}"

- name: "Run unit tests with phpunit/phpunit"
run: "vendor/bin/phpunit -c phpunit.xml --colors --no-coverage"
run: "vendor/bin/phpunit -c phpunit.xml --verbose --no-coverage"

code-coverage:
name: "Code Coverage with PHPUnit"
Expand Down Expand Up @@ -367,7 +407,7 @@ jobs:
extensions: "${{ env.PHP_EXTENSIONS }}"
ini-values: "${{ env.PHP_INI_VALUES }}"
coverage: "${{ matrix.coverage-drivers }}"
tools: "composer:v2"
tools: "composer:v2, infection"

- name: "Determine composer cache directory"
id: "determine-composer-cache-directory"
Expand All @@ -381,20 +421,20 @@ jobs:
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"

- name: "Update dependencies with composer"
run: "composer update --optimize-autoloader --prefer-dist --prefer-stable --no-progress --no-interaction -vv --ansi ${{ matrix.dependencies }}"
run: "composer update --optimize-autoloader --prefer-dist --prefer-stable --no-progress --no-interaction -v --ansi ${{ matrix.dependencies }}"

- name: "Create cache directory for phpunit/phpunit"
run: "mkdir -p .build/coverage"

- name: "Collect code coverage with Xdebug and phpunit/phpunit"
run: "vendor/bin/phpunit -c phpunit.xml --colors --coverage-clover=.build/coverage/clover.xml --coverage-text --coverage-xml=.build/coverage/coverage-xml --log-junit=.build/coverage/phpunit.junit.xml"
run: "vendor/bin/phpunit -c phpunit.xml --verbose --coverage-clover=.build/coverage/clover.xml --coverage-text --coverage-xml=.build/coverage/coverage-xml --log-junit=.build/coverage/phpunit.junit.xml"

- name: "Upload coverage to Codecov"
uses: "codecov/[email protected]"
with:
file: ".build/coverage/clover.xml"
flags: "phpunit,php-${{ matrix.php-version }},${{ matrix.coverage-drivers }}"
verbose: true
flags: "phpunit,php-${{ matrix.php-version }},${{ matrix.coverage-drivers }},${{ matrix.php-version }},${{ matrix.operating-system }}"
verbose: false

- name: "Run mutation tests with infection/infection"
run: "vendor/bin/infection --min-covered-msi=83 --min-msi=83 --git-diff-filter=AM --git-diff-base=origin/$GITHUB_BASE_REF --coverage=.build/coverage --logger-github"
run: "infection -s --min-covered-msi=83 --min-msi=83 --coverage=.build/coverage --logger-github"
9 changes: 4 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,20 @@
"laminas/laminas-json": "^3.2.0",
"laminas/laminas-log": "^2.13.1",
"mezzio/mezzio-laminasviewrenderer": "^2.3.0",
"mimmi20/laminasviewrenderer-helper-htmlelement": "^1.0.0",
"mimmi20/mezzio-generic-authorization": "^2.0.3",
"mimmi20/mezzio-navigation": "^2.0.5"
"mimmi20/laminasviewrenderer-helper-htmlelement": "^1.0.1",
"mimmi20/mezzio-generic-authorization": "^2.0.4",
"mimmi20/mezzio-navigation": "^2.0.6"
},
"conflict": {
"container-interop/container-interop": "<1.2.0",
"mezzio/mezzio-authorization": "*"
},
"require-dev": {
"ext-intl": "*",
"infection/infection": "^0.24.0",
"laminas/laminas-config": "^3.5.0",
"laminas/laminas-i18n": "^2.11.1",
"laminas/laminas-servicemanager": "^3.7.0",
"mimmi20/coding-standard": "^2.2.3",
"mimmi20/coding-standard": "^2.3.0",
"pepakriz/phpstan-exception-rules": "^0.11.7",
"phpstan/extension-installer": "^1.1.0",
"phpstan/phpstan": "^0.12.94",
Expand Down
29 changes: 29 additions & 0 deletions phpmd.ruleset.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0"?>
<ruleset name="mimmi20-cs"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
<description>The coding standard.</description>

<rule ref="rulesets/cleancode.xml">
<exclude name="BooleanArgumentFlag"/>
<exclude name="ElseExpression"/>
<exclude name="MissingImport"/>
<exclude name="StaticAccess"/>
</rule>

<rule ref="rulesets/codesize.xml">
<exclude name="CyclomaticComplexity"/>
<exclude name="NPathComplexity"/>
</rule>

<rule ref="rulesets/controversial.xml"/>
<rule ref="rulesets/design.xml"/>

<rule ref="rulesets/naming.xml/ConstantNamingConventions"/>

<rule ref="rulesets/unusedcode.xml">
<exclude name="UnusedFormalParameter"/>
</rule>
</ruleset>
4 changes: 0 additions & 4 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,4 @@
<directory suffix=".php">src/</directory>
</include>
</coverage>

<logging>
<text outputFile="php://stdout"/>
</logging>
</phpunit>

0 comments on commit a8936dd

Please sign in to comment.