lint: setup PHPCS for PSR-1 and PSR-2
Relates to https://github.com/shaarli/Shaarli/issues/95 See: - https://github.com/squizlabs/PHP_CodeSniffer - https://github.com/squizlabs/PHP_CodeSniffer/blob/master/phpcs.xml.dist - https://www.php-fig.org/psr/psr-1/ - https://www.php-fig.org/psr/psr-2/ Signed-off-by: VirtualTam <virtualtam@flibidi.net>
This commit is contained in:
parent
37c9c6b4e6
commit
04ec8fedd9
2 changed files with 25 additions and 6 deletions
14
Makefile
14
Makefile
|
@ -2,7 +2,6 @@
|
||||||
# Makefile for PHP code analysis & testing, documentation and release generation
|
# Makefile for PHP code analysis & testing, documentation and release generation
|
||||||
|
|
||||||
BIN = vendor/bin
|
BIN = vendor/bin
|
||||||
PHP_SOURCE = index.php application tests plugins
|
|
||||||
|
|
||||||
all: static_analysis_summary check_permissions test
|
all: static_analysis_summary check_permissions test
|
||||||
|
|
||||||
|
@ -23,23 +22,26 @@ docker_%:
|
||||||
# - http://pear.php.net/manual/en/package.php.php-codesniffer.usage.php
|
# - http://pear.php.net/manual/en/package.php.php-codesniffer.usage.php
|
||||||
# - http://pear.php.net/manual/en/package.php.php-codesniffer.reporting.php
|
# - http://pear.php.net/manual/en/package.php.php-codesniffer.reporting.php
|
||||||
##
|
##
|
||||||
code_sniffer: code_sniffer_full
|
PHPCS := $(BIN)/phpcs
|
||||||
|
|
||||||
|
code_sniffer:
|
||||||
|
@$(PHPCS)
|
||||||
|
|
||||||
### - errors filtered by coding standard: PEAR, PSR1, PSR2, Zend...
|
### - errors filtered by coding standard: PEAR, PSR1, PSR2, Zend...
|
||||||
PHPCS_%:
|
PHPCS_%:
|
||||||
@$(BIN)/phpcs $(PHP_SOURCE) --report-full --report-width=200 --standard=$*
|
@$(PHPCS) --report-full --report-width=200 --standard=$*
|
||||||
|
|
||||||
### - errors by Git author
|
### - errors by Git author
|
||||||
code_sniffer_blame:
|
code_sniffer_blame:
|
||||||
@$(BIN)/phpcs $(PHP_SOURCE) --report-gitblame
|
@$(PHPCS) --report-gitblame
|
||||||
|
|
||||||
### - all errors/warnings
|
### - all errors/warnings
|
||||||
code_sniffer_full:
|
code_sniffer_full:
|
||||||
@$(BIN)/phpcs $(PHP_SOURCE) --report-full --report-width=200
|
@$(PHPCS) --report-full --report-width=200
|
||||||
|
|
||||||
### - errors grouped by kind
|
### - errors grouped by kind
|
||||||
code_sniffer_source:
|
code_sniffer_source:
|
||||||
@$(BIN)/phpcs $(PHP_SOURCE) --report-source || exit 0
|
@$(PHPCS) --report-source || exit 0
|
||||||
|
|
||||||
##
|
##
|
||||||
# Checks source file & script permissions
|
# Checks source file & script permissions
|
||||||
|
|
17
phpcs.xml
Normal file
17
phpcs.xml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<ruleset name="Shaarli">
|
||||||
|
<description>The Shaarli coding standards</description>
|
||||||
|
|
||||||
|
<file>index.php</file>
|
||||||
|
<file>application</file>
|
||||||
|
<file>plugins</file>
|
||||||
|
<file>tests</file>
|
||||||
|
|
||||||
|
<exclude-pattern>*/*.css</exclude-pattern>
|
||||||
|
<exclude-pattern>*/*.js</exclude-pattern>
|
||||||
|
|
||||||
|
<arg name="colors"/>
|
||||||
|
|
||||||
|
<rule ref="PSR1"/>
|
||||||
|
<rule ref="PSR2"/>
|
||||||
|
</ruleset>
|
Loading…
Reference in a new issue