]> git.immae.eu Git - github/shaarli/Shaarli.git/blame - Makefile
split annoyingpatterns list on multpile lines, add new patterns for removal:
[github/shaarli/Shaarli.git] / Makefile
CommitLineData
00f98bda 1# Shaarli, the personal, minimalist, super-fast, no-database delicious clone.
00f98bda 2# Makefile for PHP code analysis & testing
f3e89f50 3
00f98bda
V
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
f3e89f50 11
00f98bda
V
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
00f98bda
V
20# These targets are non-blocking: || exit 0
21##
f3e89f50 22
00f98bda
V
23static_analysis_summary: code_sniffer_source copy_paste mess_detector_summary
24
25##
26# PHP_CodeSniffer
00f98bda 27# Detects PHP syntax errors
00f98bda
V
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##
f3e89f50 32
00f98bda
V
33code_sniffer: code_sniffer_full
34
f3e89f50 35### - errors by Git author
00f98bda
V
36code_sniffer_blame:
37 @$(BIN)/phpcs $(PHP_SOURCE) --report-gitblame
38
f3e89f50 39### - all errors/warnings
00f98bda
V
40code_sniffer_full:
41 @$(BIN)/phpcs $(PHP_SOURCE) --report-full --report-width=200
42
f3e89f50 43### - errors grouped by kind
00f98bda
V
44code_sniffer_source:
45 @$(BIN)/phpcs $(PHP_SOURCE) --report-source || exit 0
46
47##
48# PHP Copy/Paste Detector
00f98bda 49# Detects code redundancy
00f98bda
V
50# Documentation: https://github.com/sebastianbergmann/phpcpd
51##
f3e89f50 52
00f98bda
V
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
00f98bda 62# Detects PHP syntax errors, sorted by category
00f98bda 63# Rules documentation: http://phpmd.org/rules/index.html
f3e89f50 64##
65
00f98bda
V
66mess_title:
67 @echo "-----------------"
68 @echo "PHP MESS DETECTOR"
69 @echo "-----------------"
70
f3e89f50 71### - all warnings
00f98bda
V
72mess_detector: mess_title
73 @$(BIN)/phpmd $(PHP_SOURCE) text $(MESS_DETECTOR_RULES) | sed 's_.*\/__'
74
f3e89f50 75### - all warnings + HTML output contains links to PHPMD's documentation
00f98bda
V
76mess_detector_html:
77 @$(BIN)/phpmd $(PHP_SOURCE) html $(MESS_DETECTOR_RULES) \
78 --reportfile phpmd.html || exit 0
79
f3e89f50 80### - warnings grouped by message, sorted by descending frequency order
00f98bda
V
81mess_detector_grouped: mess_title
82 @$(BIN)/phpmd $(PHP_SOURCE) text $(MESS_DETECTOR_RULES) \
83 | cut -f 2 | sort | uniq -c | sort -nr
84
f3e89f50 85### - summary: number of warnings by rule set
00f98bda
V
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;
1acc87ee 91
92##
93# Targets for repository and documentation maintenance
f3e89f50 94##
95
96### remove all unversioned files
1acc87ee 97clean:
98 @git clean -df
99
f3e89f50 100### update the local copy of the documentation
1acc87ee 101doc: clean
102 @rm -rf doc
103 @git clone https://github.com/shaarli/Shaarli.wiki.git doc
104 @rm -rf doc/.git
82af78b2 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;