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