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