Skip to content

Commit 23a6e0c

Browse files
committed
[+]: Allow to execute CS/PHPUnit checks and reports through composer scripts (composer check, composer generate-reports)
1 parent 1d3cbe7 commit 23a6e0c

File tree

9 files changed

+190
-103
lines changed

9 files changed

+190
-103
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ composer.phar
1212
phpunit.phar
1313
/phpunit.xml
1414
.phpunit.result.cache
15-
/build
1615

1716

1817
# --------------------------------------------

.travis.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ os:
44
- linux
55

66
matrix:
7-
allow_failures:
8-
- php: hhvm
9-
107
include:
118
- php: 7.1
129
- php: 7.2
@@ -18,8 +15,8 @@ before_script:
1815
- travis_retry composer install --no-interaction --prefer-source
1916

2017
script:
21-
- php vendor/bin/phpcs
22-
- php vendor/bin/phpunit --coverage-clover=coverage.xml --debug
18+
- composer check
19+
- composer generate-reports
2320

2421
after_script:
25-
- bash <(curl -s https://codecov.io/bash)
22+
- bash <(curl -s https://codecov.io/bash) -f "build/phpunit/coverage/clover/index.xml"

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Accessing PHP Arrays via DOT notation is easy as:
88
```php
99
DotArray::create(['config' => ['some.dotted.key' => 'value']])->get('config.{some.dotted.key}')
1010
```
11-
[![Require `PHP >= 7.1`](https://img.shields.io/badge/Require%20PHP-%3E%3D%207.1-brightgreen.svg)][git-source]
11+
[![Minimum PHP Version `PHP >= 7.1`](https://img.shields.io/badge/php-%3E%3D%207.1-8892BF.svg)][php-site]
1212
[![Latest Stable Version](https://poser.pugx.org/binary-cube/dot-array/version)][packagist]
1313
[![Total Downloads](https://poser.pugx.org/binary-cube/dot-array/downloads)][packagist]
1414
[![Build Status](https://travis-ci.org/binary-cube/dot-array.svg?branch=master)](https://travis-ci.org/binary-cube/dot-array)
@@ -337,6 +337,7 @@ This project is licensed under the MIT License - see the [LICENSE][license] file
337337
[domain]: https://binary-cube.com
338338
[homepage]: https://binary-cube.com
339339
[git-source]: https://github.com/binary-cube/dot-array
340+
[php-site]: https://php.net
340341
[semver]: https://semver.org
341342
[code-of-conduct]: https://github.com/binary-cube/dot-array/blob/master/code-of-conduct.md
342343
[license]: https://github.com/binary-cube/dot-array/blob/master/LICENSE

build/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore

composer.json

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,8 @@
4040

4141
"config": {
4242
"sort-packages": true,
43-
"optimize-autoloader": true
44-
},
45-
46-
"bin": [
47-
],
48-
49-
"scripts": {
43+
"optimize-autoloader": true,
44+
"process-timeout": 300
5045
},
5146

5247
"autoload": {
@@ -66,5 +61,35 @@
6661
"type": "composer",
6762
"url": "https://asset-packagist.org"
6863
}
69-
]
64+
],
65+
66+
"bin": [
67+
],
68+
69+
"scripts": {
70+
71+
"check": [
72+
"@cs-check",
73+
"@tests"
74+
],
75+
76+
"generate-reports": [
77+
"@cs-report",
78+
"@phpmd-report",
79+
"@tests-report-html",
80+
"@tests-report-xml",
81+
"@tests-report-clover"
82+
],
83+
84+
"cs-check": "phpcs",
85+
"cs-fix": "phpcbf",
86+
"phpmd": "phpmd src text phpmd.xml.dist",
87+
"tests": "phpunit",
88+
89+
"cs-report": "phpcs --report=json --report-file=build/phpcs-report.json || exit 0;",
90+
"phpmd-report": "phpmd src xml phpmd.xml.dist --reportfile build/phpmd-report.xml || exit 0;",
91+
"tests-report-html": "phpunit --coverage-html build/phpunit/coverage/html || exit 0;",
92+
"tests-report-xml": "phpunit --coverage-xml build/phpunit/coverage/xml || exit 0;",
93+
"tests-report-clover": "phpunit --coverage-clover build/phpunit/coverage/clover/index.xml || exit 0;"
94+
}
7095
}

phpcs.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
1+
<?xml version="1.0" encoding="UTF-8" ?>
22
<ruleset name="Base Coding Standards">
33

44
<description>Base Coding Standards</description>

phpmd.xml

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

phpmd.xml.dist

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<ruleset name="PHPMD rule set"
3+
xmlns="http://pmd.sf.net/ruleset/1.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
6+
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
7+
8+
<description>Base PHP Mess Detector Rule Set</description>
9+
10+
11+
<!-- ================== -->
12+
<!-- === Clean Code === -->
13+
<!-- ================== -->
14+
15+
<!--
16+
See: https://phpmd.org/rules/cleancode.html
17+
18+
The Clean Code ruleset contains rules that enforce a clean code base.
19+
This includes rules from SOLID and object calisthenics.
20+
-->
21+
<rule ref="rulesets/cleancode.xml">
22+
<exclude name="StaticAccess"/>
23+
<exclude name="BooleanArgumentFlag"/>
24+
</rule>
25+
26+
27+
<!-- ================= -->
28+
<!-- === Code Size === -->
29+
<!-- ================= -->
30+
31+
<!--
32+
See: https://phpmd.org/rules/codesize.html
33+
34+
The Code Size Ruleset contains a collection of rules that find code size related problems.
35+
-->
36+
<rule ref="rulesets/codesize.xml">
37+
<exclude name="TooManyPublicMethods"/>
38+
<exclude name="ExcessiveClassComplexity"/>
39+
<exclude name="TooManyMethods"/>
40+
</rule>
41+
42+
<rule ref="rulesets/codesize.xml/ExcessiveClassComplexity">
43+
<properties>
44+
<property name="maximum" value="100"/>
45+
</properties>
46+
</rule>
47+
48+
<rule ref="rulesets/codesize.xml/TooManyMethods">
49+
<properties>
50+
<property name="maxmethods" value="50"/>
51+
</properties>
52+
</rule>
53+
54+
<!--
55+
Violations of this rule usually indicate that the method is doing too much.
56+
Try to reduce the method size by creating helper methods and removing any copy/pasted code.
57+
-->
58+
<rule ref="rulesets/codesize.xml/ExcessiveMethodLength">
59+
<properties>
60+
<property name="minimum" value="100"/>
61+
</properties>
62+
</rule>
63+
64+
65+
<!-- =========================== -->
66+
<!-- === Controversial Rules === -->
67+
<!-- =========================== -->
68+
69+
<!--
70+
See: https://phpmd.org/rules/controversial.html
71+
72+
This ruleset contains a collection of controversial rules.
73+
-->
74+
<rule ref="rulesets/controversial.xml">
75+
<exclude name="CamelCaseVariableName"/>
76+
</rule>
77+
78+
79+
<!-- ==================== -->
80+
<!-- === Design Rules === -->
81+
<!-- ==================== -->
82+
83+
<!--
84+
See: https://phpmd.org/rules/design.html
85+
86+
The Design Ruleset contains a collection of rules that find software design related problems.
87+
-->
88+
<rule ref="rulesets/design.xml"/>
89+
90+
<rule ref="rulesets/design.xml/CouplingBetweenObjects">
91+
<properties>
92+
<property name="minimum" value="15"/>
93+
</properties>
94+
</rule>
95+
96+
97+
<!-- ==================== -->
98+
<!-- === Naming Rules === -->
99+
<!-- ==================== -->
100+
101+
<!--
102+
See: https://phpmd.org/rules/naming.html
103+
104+
The Naming Ruleset contains a collection of rules about names - too long, too short, and so forth.
105+
-->
106+
<rule ref="rulesets/naming.xml">
107+
<exclude name="ShortVariable"/>
108+
<exclude name="LongVariable"/>
109+
<exclude name="ShortMethodName"/>
110+
</rule>
111+
112+
<rule ref="rulesets/naming.xml/ShortVariable">
113+
<properties>
114+
<property name="minimum" value="2"/>
115+
</properties>
116+
</rule>
117+
118+
<rule ref="rulesets/naming.xml/LongVariable">
119+
<properties>
120+
<property name="maximum" value="30"/>
121+
</properties>
122+
</rule>
123+
124+
<rule ref="rulesets/naming.xml/ShortMethodName">
125+
<properties>
126+
<property name="minimum" value="2"/>
127+
</properties>
128+
</rule>
129+
130+
<rule ref="rulesets/naming.xml/BooleanGetMethodName">
131+
<properties>
132+
<property name="checkParameterizedMethods" value="true"/>
133+
</properties>
134+
</rule>
135+
136+
137+
<!-- ========================= -->
138+
<!-- === Unused Code Rules === -->
139+
<!-- ========================= -->
140+
141+
<!--
142+
See: https://phpmd.org/rules/unusedcode.html
143+
144+
The Unused Code Ruleset contains a collection of rules that find unused code.
145+
-->
146+
<rule ref="rulesets/unusedcode.xml"/>
147+
148+
</ruleset>

phpunit.xml.dist

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="UTF-8" ?>
22
<phpunit bootstrap="./tests/bootstrap.php"
33
stopOnFailure="false"
44
colors="true"
@@ -25,14 +25,4 @@
2525
<directory suffix=".php">./src/</directory>
2626
</whitelist>
2727
</filter>
28-
29-
30-
<logging>
31-
<log type="tap" target="build/phpunit/report.tap"/>
32-
<log type="junit" target="build/phpunit/report.junit.xml"/>
33-
34-
<log type="coverage-html" target="build/phpunit/coverage/html"/>
35-
<log type="coverage-text" target="build/phpunit/coverage/coverage.txt"/>
36-
<log type="coverage-clover" target="build/phpunit/coverage/coverage.xml"/>
37-
</logging>
3828
</phpunit>

0 commit comments

Comments
 (0)