aboutsummaryrefslogtreecommitdiffhomepage
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile39
1 files changed, 18 insertions, 21 deletions
diff --git a/Makefile b/Makefile
index 8f9ab9e7..9635e53e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,6 @@
1# Shaarli, the personal, minimalist, super-fast, no-database delicious clone. 1# Shaarli, the personal, minimalist, super-fast, no-database delicious clone.
2#
3# Makefile for PHP code analysis & testing 2# Makefile for PHP code analysis & testing
4# 3
5# Prerequisites: 4# Prerequisites:
6# - install Composer, either: 5# - install Composer, either:
7# - from your distro's package manager; 6# - from your distro's package manager;
@@ -9,6 +8,7 @@
9# - install/update test dependencies: 8# - install/update test dependencies:
10# $ composer install # 1st setup 9# $ composer install # 1st setup
11# $ composer update 10# $ composer update
11
12BIN = vendor/bin 12BIN = vendor/bin
13PHP_SOURCE = index.php 13PHP_SOURCE = index.php
14MESS_DETECTOR_RULES = cleancode,codesize,controversial,design,naming,unusedcode 14MESS_DETECTOR_RULES = cleancode,codesize,controversial,design,naming,unusedcode
@@ -17,41 +17,39 @@ all: static_analysis_summary
17 17
18## 18##
19# Concise status of the project 19# Concise status of the project
20#
21# These targets are non-blocking: || exit 0 20# These targets are non-blocking: || exit 0
22## 21##
22
23static_analysis_summary: code_sniffer_source copy_paste mess_detector_summary 23static_analysis_summary: code_sniffer_source copy_paste mess_detector_summary
24 24
25## 25##
26# PHP_CodeSniffer 26# PHP_CodeSniffer
27#
28# Detects PHP syntax errors 27# Detects PHP syntax errors
29#
30# Documentation (usage, output formatting): 28# Documentation (usage, output formatting):
31# - http://pear.php.net/manual/en/package.php.php-codesniffer.usage.php 29# - http://pear.php.net/manual/en/package.php.php-codesniffer.usage.php
32# - http://pear.php.net/manual/en/package.php.php-codesniffer.reporting.php 30# - http://pear.php.net/manual/en/package.php.php-codesniffer.reporting.php
33## 31##
32
34code_sniffer: code_sniffer_full 33code_sniffer: code_sniffer_full
35 34
36# - errors by Git author 35### - errors by Git author
37code_sniffer_blame: 36code_sniffer_blame:
38 @$(BIN)/phpcs $(PHP_SOURCE) --report-gitblame 37 @$(BIN)/phpcs $(PHP_SOURCE) --report-gitblame
39 38
40# - all errors/warnings 39### - all errors/warnings
41code_sniffer_full: 40code_sniffer_full:
42 @$(BIN)/phpcs $(PHP_SOURCE) --report-full --report-width=200 41 @$(BIN)/phpcs $(PHP_SOURCE) --report-full --report-width=200
43 42
44# - errors grouped by kind 43### - errors grouped by kind
45code_sniffer_source: 44code_sniffer_source:
46 @$(BIN)/phpcs $(PHP_SOURCE) --report-source || exit 0 45 @$(BIN)/phpcs $(PHP_SOURCE) --report-source || exit 0
47 46
48## 47##
49# PHP Copy/Paste Detector 48# PHP Copy/Paste Detector
50#
51# Detects code redundancy 49# Detects code redundancy
52#
53# Documentation: https://github.com/sebastianbergmann/phpcpd 50# Documentation: https://github.com/sebastianbergmann/phpcpd
54## 51##
52
55copy_paste: 53copy_paste:
56 @echo "-----------------------" 54 @echo "-----------------------"
57 @echo "PHP COPY/PASTE DETECTOR" 55 @echo "PHP COPY/PASTE DETECTOR"
@@ -61,32 +59,30 @@ copy_paste:
61 59
62## 60##
63# PHP Mess Detector 61# PHP Mess Detector
64#
65# Detects PHP syntax errors, sorted by category 62# Detects PHP syntax errors, sorted by category
66#
67# Rules documentation: http://phpmd.org/rules/index.html 63# Rules documentation: http://phpmd.org/rules/index.html
68# 64##
65
69mess_title: 66mess_title:
70 @echo "-----------------" 67 @echo "-----------------"
71 @echo "PHP MESS DETECTOR" 68 @echo "PHP MESS DETECTOR"
72 @echo "-----------------" 69 @echo "-----------------"
73 70
74# - all warnings 71### - all warnings
75mess_detector: mess_title 72mess_detector: mess_title
76 @$(BIN)/phpmd $(PHP_SOURCE) text $(MESS_DETECTOR_RULES) | sed 's_.*\/__' 73 @$(BIN)/phpmd $(PHP_SOURCE) text $(MESS_DETECTOR_RULES) | sed 's_.*\/__'
77 74
78# - all warnings 75### - all warnings + HTML output contains links to PHPMD's documentation
79# the generated HTML contains links to PHPMD's documentation
80mess_detector_html: 76mess_detector_html:
81 @$(BIN)/phpmd $(PHP_SOURCE) html $(MESS_DETECTOR_RULES) \ 77 @$(BIN)/phpmd $(PHP_SOURCE) html $(MESS_DETECTOR_RULES) \
82 --reportfile phpmd.html || exit 0 78 --reportfile phpmd.html || exit 0
83 79
84# - warnings grouped by message, sorted by descending frequency order 80### - warnings grouped by message, sorted by descending frequency order
85mess_detector_grouped: mess_title 81mess_detector_grouped: mess_title
86 @$(BIN)/phpmd $(PHP_SOURCE) text $(MESS_DETECTOR_RULES) \ 82 @$(BIN)/phpmd $(PHP_SOURCE) text $(MESS_DETECTOR_RULES) \
87 | cut -f 2 | sort | uniq -c | sort -nr 83 | cut -f 2 | sort | uniq -c | sort -nr
88 84
89# - summary: number of warnings by rule set 85### - summary: number of warnings by rule set
90mess_detector_summary: mess_title 86mess_detector_summary: mess_title
91 @for rule in $$(echo $(MESS_DETECTOR_RULES) | tr ',' ' '); do \ 87 @for rule in $$(echo $(MESS_DETECTOR_RULES) | tr ',' ' '); do \
92 warnings=$$($(BIN)/phpmd $(PHP_SOURCE) text $$rule | wc -l); \ 88 warnings=$$($(BIN)/phpmd $(PHP_SOURCE) text $$rule | wc -l); \
@@ -95,12 +91,13 @@ mess_detector_summary: mess_title
95 91
96## 92##
97# Targets for repository and documentation maintenance 93# Targets for repository and documentation maintenance
98# 94##
99# remove all unversioned files 95
96### remove all unversioned files
100clean: 97clean:
101 @git clean -df 98 @git clean -df
102 99
103# update the local copy of the documentation 100### update the local copy of the documentation
104doc: clean 101doc: clean
105 @rm -rf doc 102 @rm -rf doc
106 @git clone https://github.com/shaarli/Shaarli.wiki.git doc 103 @git clone https://github.com/shaarli/Shaarli.wiki.git doc