Skip to content

Commit 140de62

Browse files
committed
change code check tool to PHP Insights and update PHPUnit config
1 parent e037ca1 commit 140de62

File tree

5 files changed

+149
-100
lines changed

5 files changed

+149
-100
lines changed

insights.php

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use NunoMaduro\PhpInsights\Domain\Insights\CyclomaticComplexityIsHigh;
6+
use NunoMaduro\PhpInsights\Domain\Insights\ForbiddenDefineFunctions;
7+
use NunoMaduro\PhpInsights\Domain\Insights\ForbiddenFinalClasses;
8+
use NunoMaduro\PhpInsights\Domain\Insights\ForbiddenNormalClasses;
9+
use NunoMaduro\PhpInsights\Domain\Insights\ForbiddenPrivateMethods;
10+
use NunoMaduro\PhpInsights\Domain\Insights\ForbiddenTraits;
11+
use NunoMaduro\PhpInsights\Domain\Metrics\Architecture\Classes;
12+
use NunoMaduro\PhpInsights\Domain\Sniffs\ForbiddenSetterSniff;
13+
use ObjectCalisthenics\Sniffs\Files\FunctionLengthSniff;
14+
use ObjectCalisthenics\Sniffs\Metrics\MethodPerClassLimitSniff;
15+
use ObjectCalisthenics\Sniffs\NamingConventions\ElementNameMinimalLengthSniff;
16+
use PHP_CodeSniffer\Standards\Generic\Sniffs\Files\LineLengthSniff;
17+
use SlevomatCodingStandard\Sniffs\Classes\SuperfluousExceptionNamingSniff;
18+
use SlevomatCodingStandard\Sniffs\Classes\SuperfluousInterfaceNamingSniff;
19+
use SlevomatCodingStandard\Sniffs\Classes\SuperfluousTraitNamingSniff;
20+
use SlevomatCodingStandard\Sniffs\Functions\StaticClosureSniff;
21+
use SlevomatCodingStandard\Sniffs\Namespaces\AlphabeticallySortedUsesSniff;
22+
use SlevomatCodingStandard\Sniffs\TypeHints\DeclareStrictTypesSniff;
23+
use SlevomatCodingStandard\Sniffs\TypeHints\TypeHintDeclarationSniff;
24+
25+
return [
26+
27+
/*
28+
|--------------------------------------------------------------------------
29+
| Default Preset
30+
|--------------------------------------------------------------------------
31+
|
32+
| This option controls the default preset that will be used by PHP Insights
33+
| to make your code reliable, simple, and clean. However, you can always
34+
| adjust the `Metrics` and `Insights` below in this configuration file.
35+
|
36+
| Supported: "default", "laravel", "symfony", "magento2", "drupal"
37+
|
38+
*/
39+
40+
'preset' => 'laravel',
41+
/*
42+
|--------------------------------------------------------------------------
43+
| IDE
44+
|--------------------------------------------------------------------------
45+
|
46+
| This options allow to add hyperlinks in your terminal to quickly open
47+
| files in your favorite IDE while browsing your PhpInsights report.
48+
|
49+
| Supported: "textmate", "macvim", "emacs", "sublime", "phpstorm",
50+
| "atom", "vscode".
51+
|
52+
| If you have another IDE that is not in this list but which provide an
53+
| url-handler, you could fill this config with a pattern like this:
54+
|
55+
| myide://open?url=file://%f&line=%l
56+
|
57+
*/
58+
59+
'ide' => null,
60+
/*
61+
|--------------------------------------------------------------------------
62+
| Configuration
63+
|--------------------------------------------------------------------------
64+
|
65+
| Here you may adjust all the various `Insights` that will be used by PHP
66+
| Insights. You can either add, remove or configure `Insights`. Keep in
67+
| mind that all added `Insights` must belong to a specific `Metric`.
68+
|
69+
*/
70+
71+
'exclude' => [
72+
// 'path/to/directory-or-file'
73+
],
74+
75+
'add' => [
76+
Classes::class => [
77+
ForbiddenFinalClasses::class,
78+
],
79+
],
80+
81+
'remove' => [
82+
AlphabeticallySortedUsesSniff::class,
83+
DeclareStrictTypesSniff::class,
84+
ForbiddenDefineFunctions::class,
85+
ForbiddenNormalClasses::class,
86+
ForbiddenTraits::class,
87+
TypeHintDeclarationSniff::class,
88+
ForbiddenSetterSniff::class,
89+
SuperfluousExceptionNamingSniff::class,
90+
SuperfluousInterfaceNamingSniff::class,
91+
SuperfluousTraitNamingSniff::class,
92+
CyclomaticComplexityIsHigh::class,
93+
],
94+
95+
'config' => [
96+
ForbiddenPrivateMethods::class => [
97+
'title' => 'The usage of private methods is not idiomatic in Laravel.',
98+
],
99+
MethodPerClassLimitSniff::class => [
100+
'maxCount' => 15,
101+
],
102+
LineLengthSniff::class => [
103+
'lineLimit' => 120,
104+
'absoluteLineLimit' => 140,
105+
'ignoreComments' => false,
106+
],
107+
ElementNameMinimalLengthSniff::class => [
108+
'allowedShortNames' => ['e'],
109+
],
110+
StaticClosureSniff::class => [
111+
'exclude' => [
112+
'src/Provider/RequestQueryParserProvider.php',
113+
],
114+
],
115+
FunctionLengthSniff::class => [
116+
'exclude' => [
117+
'src/BuilderParamsApplierTrait.php',
118+
],
119+
],
120+
],
121+
];

phpcs.xml

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

phpunit.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
require __DIR__.'/vendor/autoload.php';

phpunit.xml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit backupGlobals="false"
3+
backupStaticAttributes="false"
4+
bootstrap="phpunit.php"
5+
colors="true"
6+
convertErrorsToExceptions="true"
7+
convertNoticesToExceptions="true"
8+
convertWarningsToExceptions="true"
9+
processIsolation="false"
10+
stopOnError="false"
11+
stopOnFailure="false"
12+
verbose="true"
13+
>
14+
<testsuites>
15+
<testsuite name="Lumen Api Query Parser Test Suite">
16+
<directory suffix="Test.php">./tests</directory>
17+
</testsuite>
18+
</testsuites>
19+
20+
<filter>
21+
<whitelist>
22+
<directory>./src</directory>
23+
</whitelist>
24+
</filter>
25+
</phpunit>

phpunit.xml.dist

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

0 commit comments

Comments
 (0)