Skip to content

Commit

Permalink
Use Matomo coding standard repo (#22421)
Browse files Browse the repository at this point in the history
* Use new global Matomo cs

* update used branch
  • Loading branch information
sgiehl authored Aug 1, 2024
1 parent 9fb618b commit 1e35cae
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 50 deletions.
11 changes: 8 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/matomo-org/matomo-coding-standards.git"
}
],
"require": {
"php": ">=7.2.5",
"composer/ca-bundle": "^1.2",
Expand Down Expand Up @@ -66,10 +72,9 @@
"wikimedia/less.php": "^3.0"
},
"require-dev": {
"phpunit/phpunit": "~8.5",
"slevomat/coding-standard": "~8.14.0",
"squizlabs/php_codesniffer": "~3.6",
"matomo-org/matomo-coding-standards": "dev-master",
"phpstan/phpdoc-parser": "~1.24.0",
"phpunit/phpunit": "~8.5",
"symfony/var-dumper": "~5.4.0",
"symfony/yaml": "~5.4.0"
},
Expand Down
34 changes: 32 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 2 additions & 45 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<ruleset name="matomo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">

<description>Matomo Coding Standard</description>
<description>Matomo Core Coding Standard</description>

<arg name="extensions" value="php" />

Expand All @@ -12,21 +12,11 @@
<exclude-pattern>tests/PHPUnit/proxy/*</exclude-pattern>
<exclude-pattern>tests/PHPUnit/Unit/Config/test_files/*</exclude-pattern>
<exclude-pattern>tests/javascript/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*/libs/*</exclude-pattern>

<!-- exclude all plugins included as submodule as long as they might not fully follow this CS -->
<exclude-pattern>plugins/(AnonymousPiwikUsageMeasurement|Bandwidth|CustomAlerts|CustomVariables|DeviceDetectorCache|LogViewer|LoginLdap|MarketingCampaignsReporting|Provider|QueuedTracking|SecurityInfo|TagManager|TasksTimetable|TrackingSpamPrevention|TreemapVisualization|VisitorGenerator)/*</exclude-pattern>

<config name="installed_paths" value="../../slevomat/coding-standard"/>

<!-- Use PSR 12 standard as default -->
<!-- Some rules are currently excluded/restricted, but those restrictions should be removed in the future -->

<rule ref="PSR12">
<!-- can't use this as long as we have functions.php files that need to be required manually -->
<exclude name="PSR1.Files.SideEffects.FoundWithSymbols" />
</rule>
<rule ref="Matomo"></rule>

<rule ref="Generic.Files.LineLength">
<properties>
Expand All @@ -36,42 +26,9 @@
<exclude-pattern>plugins/*/tests/*</exclude-pattern>
</rule>

<rule ref="Squiz.Classes.ValidClassName.NotCamelCaps">
<!-- Classnames for our update files don't match PascalCase, this can't be changed easily -->
<exclude-pattern>core/Updates/*</exclude-pattern>
<exclude-pattern>plugins/*/Updates/*</exclude-pattern>
</rule>

<rule ref="PSR1.Classes.ClassDeclaration.MultipleClasses">
<!-- Allow using multiple classes in one file for tests -->
<exclude-pattern>tests/PHPUnit/*</exclude-pattern>
<exclude-pattern>plugins/*/tests/*</exclude-pattern>
</rule>


<!-- Additional rules that are not covered by PSR above -->

<!-- Forbid unused use statements -->
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
<properties>
<property name="searchAnnotations" value="true"/>
<property name="ignoredAnnotations" type="array">
<element value="@group"/>
<element value="@api"/>
</property>
</properties>
</rule>

<!-- Forbid some functions that should not be used (directly) -->
<rule ref="Generic.PHP.ForbiddenFunctions">
<properties>
<property name="forbiddenFunctions" type="array">
<element key="eval" value="null"/>
<element key="create_function" value="null"/>
<element key="unserialize" value="\Piwik\Common::safe_unserialize"/>
</property>
</properties>
<!-- still allow those functions in tests -->
<exclude-pattern>*/tests/*</exclude-pattern>
</rule>
</ruleset>

0 comments on commit 1e35cae

Please sign in to comment.