From 04ec8fedd91642d4c0fc96258868086b8a51c899 Mon Sep 17 00:00:00 2001 From: VirtualTam Date: Sat, 13 Oct 2018 00:05:04 +0200 Subject: 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 --- Makefile | 14 ++++++++------ phpcs.xml | 17 +++++++++++++++++ 2 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 phpcs.xml diff --git a/Makefile b/Makefile index 28740690..b758d1fd 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,6 @@ # Makefile for PHP code analysis & testing, documentation and release generation BIN = vendor/bin -PHP_SOURCE = index.php application tests plugins 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.reporting.php ## -code_sniffer: code_sniffer_full +PHPCS := $(BIN)/phpcs + +code_sniffer: + @$(PHPCS) ### - errors filtered by coding standard: PEAR, PSR1, PSR2, Zend... PHPCS_%: - @$(BIN)/phpcs $(PHP_SOURCE) --report-full --report-width=200 --standard=$* + @$(PHPCS) --report-full --report-width=200 --standard=$* ### - errors by Git author code_sniffer_blame: - @$(BIN)/phpcs $(PHP_SOURCE) --report-gitblame + @$(PHPCS) --report-gitblame ### - all errors/warnings code_sniffer_full: - @$(BIN)/phpcs $(PHP_SOURCE) --report-full --report-width=200 + @$(PHPCS) --report-full --report-width=200 ### - errors grouped by kind code_sniffer_source: - @$(BIN)/phpcs $(PHP_SOURCE) --report-source || exit 0 + @$(PHPCS) --report-source || exit 0 ## # Checks source file & script permissions diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 00000000..29b95d56 --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,17 @@ + + + The Shaarli coding standards + + index.php + application + plugins + tests + + */*.css + */*.js + + + + + + -- cgit v1.2.3