[FEATURE] Linters and code analysis for TYPO3 projects
Default configuration and installation
This commit is contained in:
commit
c620f7db49
94
.editorconfig
Normal file
94
.editorconfig
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
# EditorConfig is awesome: http://EditorConfig.org
|
||||||
|
|
||||||
|
# top-most EditorConfig file
|
||||||
|
root = true
|
||||||
|
|
||||||
|
# Unix-style newlines with a newline ending every file
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
# CSS-Files
|
||||||
|
[*.css]
|
||||||
|
indent_style = tab
|
||||||
|
indent_size = 4
|
||||||
|
|
||||||
|
# HTML-Files
|
||||||
|
[*.html]
|
||||||
|
indent_style = tab
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
# TMPL-Files
|
||||||
|
[*.tmpl]
|
||||||
|
indent_style = tab
|
||||||
|
indent_size = 4
|
||||||
|
|
||||||
|
# SCSS-Files
|
||||||
|
[*.scss]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
|
||||||
|
# TS/JS-Files
|
||||||
|
[*.ts]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
[*.js]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
# JSON-Files
|
||||||
|
[*.json]
|
||||||
|
indent_style = tab
|
||||||
|
indent_size = 4
|
||||||
|
|
||||||
|
# PHP-Files
|
||||||
|
[*.php]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
|
||||||
|
# ReST-Files
|
||||||
|
[*.rst]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 3
|
||||||
|
|
||||||
|
# MD-Files
|
||||||
|
[*.md]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
|
||||||
|
# YAML-Files
|
||||||
|
[{*.yaml,*.yml}]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
# package.json
|
||||||
|
# .travis.yml
|
||||||
|
# bower.json
|
||||||
|
[{package.json,.travis.yml,bower.json}]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
# TypoScript
|
||||||
|
[*.typoscript]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
[*.tsconfig]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
# XLF-Files
|
||||||
|
[*.xlf]
|
||||||
|
indent_style = tab
|
||||||
|
indent_size = 4
|
||||||
|
|
||||||
|
# SQL-Files
|
||||||
|
[*.sql]
|
||||||
|
indent_style = tab
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
# .htaccess
|
||||||
|
[{_.htaccess,.htaccess}]
|
||||||
|
indent_style = tab
|
||||||
|
indent_size = 4
|
82
.gitlab-ci.yml
Normal file
82
.gitlab-ci.yml
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
# yamllint disable rule:line-length
|
||||||
|
stages:
|
||||||
|
- lint
|
||||||
|
- check
|
||||||
|
|
||||||
|
sass-lint:
|
||||||
|
image: "node:12.14"
|
||||||
|
stage: lint
|
||||||
|
only:
|
||||||
|
changes:
|
||||||
|
- packages/**/*.scss
|
||||||
|
before_script:
|
||||||
|
- npm install
|
||||||
|
script:
|
||||||
|
- ./node_modules/.bin/gulp sass-lint
|
||||||
|
|
||||||
|
typoscript-lint:
|
||||||
|
image: "php:7.2"
|
||||||
|
stage: lint
|
||||||
|
only:
|
||||||
|
changes:
|
||||||
|
- packages/**/*.typoscript
|
||||||
|
before_script:
|
||||||
|
- apt -y update > /dev/null
|
||||||
|
- apt -y install zip > /dev/null
|
||||||
|
- curl -sS https://getcomposer.org/installer | php && mv ./composer.phar /usr/local/bin/composer
|
||||||
|
script:
|
||||||
|
- rm ./composer.json && rm ./composer.lock
|
||||||
|
- composer require --dev helmich/typo3-typoscript-lint
|
||||||
|
- ./vendor/bin/typoscript-lint --fail-on-warnings
|
||||||
|
|
||||||
|
yamllint:
|
||||||
|
image: "python:2.7"
|
||||||
|
stage: lint
|
||||||
|
only:
|
||||||
|
changes:
|
||||||
|
- packages/**/*.yaml
|
||||||
|
before_script:
|
||||||
|
- pip install yamllint
|
||||||
|
script:
|
||||||
|
- yamllint -d relaxed .
|
||||||
|
|
||||||
|
php-codesniffer:
|
||||||
|
image: "php:7.2"
|
||||||
|
stage: lint
|
||||||
|
only:
|
||||||
|
changes:
|
||||||
|
- packages/**/*.php
|
||||||
|
script:
|
||||||
|
- rm ./composer.json && rm ./composer.lock
|
||||||
|
- composer require --dev squizlabs/php_codesniffer
|
||||||
|
- ./vendor/bin/phpcs -n --extensions=php --standard=PSR2 ./packages/
|
||||||
|
|
||||||
|
phpmd:
|
||||||
|
image: "php:7.2"
|
||||||
|
stage: check
|
||||||
|
only:
|
||||||
|
changes:
|
||||||
|
- packages/**/*.php
|
||||||
|
before_script:
|
||||||
|
- apt -y update > /dev/null
|
||||||
|
- apt -y install zip > /dev/null
|
||||||
|
- curl -sS https://getcomposer.org/installer | php && mv ./composer.phar /usr/local/bin/composer
|
||||||
|
script:
|
||||||
|
- rm ./composer.json && rm ./composer.lock
|
||||||
|
- composer require --dev phpmd/phpmd
|
||||||
|
- ./vendor/bin/phpmd ./packages/ text ./phpmd.xml
|
||||||
|
|
||||||
|
phpstan:
|
||||||
|
image: "php:7.2"
|
||||||
|
stage: check
|
||||||
|
only:
|
||||||
|
changes:
|
||||||
|
- packages/**/*.php
|
||||||
|
before_script:
|
||||||
|
- apt -y update > /dev/null
|
||||||
|
- apt -y install git zip > /dev/null
|
||||||
|
- echo "memory_limit=512M" > /usr/local/etc/php/conf.d/memory-limit.ini
|
||||||
|
- curl -sS https://getcomposer.org/installer | php && mv ./composer.phar /usr/local/bin/composer
|
||||||
|
script:
|
||||||
|
- composer install
|
||||||
|
- ./vendor/bin/phpstan analyze ./packages/
|
19
.sasslint.yml
Normal file
19
.sasslint.yml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
rules:
|
||||||
|
clean-import-paths:
|
||||||
|
- 1
|
||||||
|
- leading-underscore: true
|
||||||
|
force-attribute-nesting:
|
||||||
|
- 0
|
||||||
|
force-element-nesting:
|
||||||
|
- 0
|
||||||
|
force-pseudo-nesting:
|
||||||
|
- 0
|
||||||
|
indentation:
|
||||||
|
- 1
|
||||||
|
- size: 4
|
||||||
|
leading-zero:
|
||||||
|
- 1
|
||||||
|
- include: true
|
||||||
|
property-sort-order:
|
||||||
|
- 1
|
||||||
|
- order: concentric
|
10
composer.json
Normal file
10
composer.json
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"name": "fh/typo3-linting-code-analyse-gitlab-ci",
|
||||||
|
"description": "Bessere TYPO3 Projekte durch Linting und Code Analyse mit GitLab CI",
|
||||||
|
"require-dev": {
|
||||||
|
"helmich/typo3-typoscript-lint": "^2.0",
|
||||||
|
"phpmd/phpmd": "^2.7",
|
||||||
|
"phpstan/phpstan": "^0.12.0",
|
||||||
|
"squizlabs/php_codesniffer": "^3.5"
|
||||||
|
}
|
||||||
|
}
|
1718
composer.lock
generated
Normal file
1718
composer.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
16
gulpfile.js
Normal file
16
gulpfile.js
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
const { series, src } = require('gulp');
|
||||||
|
const gulpSassLint = require('gulp-sass-lint');
|
||||||
|
|
||||||
|
function sassLint(cb) {
|
||||||
|
return src('./packages/**/*.scss')
|
||||||
|
.pipe(gulpSassLint({
|
||||||
|
options: {
|
||||||
|
formatter: 'table'
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
.pipe(gulpSassLint.format())
|
||||||
|
.pipe(gulpSassLint.failOnError());
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.default = series(sassLint);
|
||||||
|
exports.sassLint = sassLint;
|
9
package.json
Normal file
9
package.json
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"name": "typo3-linting-code-analyse-gitlab-ci",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"private": true,
|
||||||
|
"devDependencies": {
|
||||||
|
"gulp": "^4.0.2",
|
||||||
|
"gulp-sass-lint": "^1.4.0"
|
||||||
|
}
|
||||||
|
}
|
63
phpmd.xml
Normal file
63
phpmd.xml
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<ruleset name="fh"
|
||||||
|
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">
|
||||||
|
|
||||||
|
<rule ref="rulesets/cleancode.xml">
|
||||||
|
<exclude name="ElseExpression" />
|
||||||
|
<exclude name="MissingImport" />
|
||||||
|
<exclude name="StaticAccess" />
|
||||||
|
</rule>
|
||||||
|
<rule ref="rulesets/cleancode.xml/StaticAccess">
|
||||||
|
<properties>
|
||||||
|
<property name="exceptions">
|
||||||
|
<value>
|
||||||
|
\League\Csv\Reader,
|
||||||
|
\Swift_Attachment,
|
||||||
|
\TCPDF_FONTS,
|
||||||
|
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility,
|
||||||
|
\TYPO3\CMS\Core\Utility\GeneralUtility,
|
||||||
|
\TYPO3\CMS\Core\Utility\HttpUtility,
|
||||||
|
\TYPO3\CMS\Core\Utility\MailUtility,
|
||||||
|
\TYPO3\CMS\Core\Resource\ResourceFactory,
|
||||||
|
\TYPO3\CMS\Extbase\Utility\DebuggerUtility,
|
||||||
|
\TYPO3\CMS\Extbase\Utility\LocalizationUtility,
|
||||||
|
\TYPO3\CMS\Saltedpasswords\Salt\SaltFactory
|
||||||
|
</value>
|
||||||
|
</property>
|
||||||
|
</properties>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<rule ref="rulesets/codesize.xml">
|
||||||
|
<exclude name="TooManyPublicMethods" />
|
||||||
|
</rule>
|
||||||
|
<rule ref="rulesets/codesize.xml/TooManyPublicMethods">
|
||||||
|
<properties>
|
||||||
|
<property name="ignorepattern" value="(^(set|get|is))i" />
|
||||||
|
</properties>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<rule ref="rulesets/controversial.xml">
|
||||||
|
<exclude name="Superglobals" />
|
||||||
|
</rule>
|
||||||
|
<rule ref="rulesets/design.xml" />
|
||||||
|
|
||||||
|
<rule ref="rulesets/naming.xml">
|
||||||
|
<exclude name="LongVariable" />
|
||||||
|
<exclude name="ShortVariable" />
|
||||||
|
</rule>
|
||||||
|
<rule ref="rulesets/naming.xml/LongVariable">
|
||||||
|
<properties>
|
||||||
|
<property name="maximum" value="30" />
|
||||||
|
</properties>
|
||||||
|
</rule>
|
||||||
|
<rule ref="rulesets/naming.xml/ShortVariable">
|
||||||
|
<properties>
|
||||||
|
<property name="exceptions" value="to,id" />
|
||||||
|
</properties>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<rule ref="rulesets/unusedcode.xml" />
|
||||||
|
</ruleset>
|
11
phpstan.neon
Normal file
11
phpstan.neon
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
parameters:
|
||||||
|
level: 8
|
||||||
|
ignoreErrors:
|
||||||
|
- '/Constant TYPO3_MODE not found./'
|
||||||
|
- '/Undefined variable: \$_EXTKEY/'
|
||||||
|
- '/Call to an undefined( static)? method (.*?)Repository::countBy(.*?)\(\)./'
|
||||||
|
- '/Call to an undefined( static)? method (.*?)Repository::find(One)?By(.*?)\(\)./'
|
||||||
|
- '/Cannot call method getFirst\(\) on array|TYPO3\\CMS\\Extbase\\Persistence\\QueryResultInterface./'
|
||||||
|
- '/Method TYPO3\\CMS\\Extbase\\Persistence\\QueryInterface::logical(And|Or)\(\) invoked with ([0-9]+) parameters, 1 required./'
|
||||||
|
- '/Method TYPO3\\CMS\\Extbase\\Object\\ObjectManagerInterface::get\(\) invoked with ([0-9]+) parameters, 1 required./'
|
||||||
|
reportUnmatchedIgnoredErrors: false
|
9
typoscript-lint.yml
Normal file
9
typoscript-lint.yml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
paths:
|
||||||
|
- packages/
|
||||||
|
filePatterns:
|
||||||
|
- "*.typoscript"
|
||||||
|
sniffs:
|
||||||
|
- class: DeadCode
|
||||||
|
disabled: true
|
||||||
|
- class: RepeatingRValue
|
||||||
|
disabled: true
|
Loading…
Reference in New Issue
Block a user