diff options
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 78 |
1 files changed, 13 insertions, 65 deletions
@@ -2,8 +2,6 @@ | |||
2 | # Makefile for PHP code analysis & testing, documentation and release generation | 2 | # Makefile for PHP code analysis & testing, documentation and release generation |
3 | 3 | ||
4 | BIN = vendor/bin | 4 | BIN = vendor/bin |
5 | PHP_SOURCE = index.php application tests plugins | ||
6 | PHP_COMMA_SOURCE = index.php,application,tests,plugins | ||
7 | 5 | ||
8 | all: static_analysis_summary check_permissions test | 6 | all: static_analysis_summary check_permissions test |
9 | 7 | ||
@@ -18,84 +16,32 @@ docker_%: | |||
18 | cd ~/shaarli && make $* | 16 | cd ~/shaarli && make $* |
19 | 17 | ||
20 | ## | 18 | ## |
21 | # Concise status of the project | ||
22 | # These targets are non-blocking: || exit 0 | ||
23 | ## | ||
24 | |||
25 | static_analysis_summary: code_sniffer_source copy_paste mess_detector_summary | ||
26 | @echo | ||
27 | |||
28 | ## | ||
29 | # PHP_CodeSniffer | 19 | # PHP_CodeSniffer |
30 | # Detects PHP syntax errors | 20 | # Detects PHP syntax errors |
31 | # Documentation (usage, output formatting): | 21 | # Documentation (usage, output formatting): |
32 | # - http://pear.php.net/manual/en/package.php.php-codesniffer.usage.php | 22 | # - http://pear.php.net/manual/en/package.php.php-codesniffer.usage.php |
33 | # - http://pear.php.net/manual/en/package.php.php-codesniffer.reporting.php | 23 | # - http://pear.php.net/manual/en/package.php.php-codesniffer.reporting.php |
34 | ## | 24 | ## |
25 | PHPCS := $(BIN)/phpcs | ||
35 | 26 | ||
36 | code_sniffer: code_sniffer_full | 27 | code_sniffer: |
28 | @$(PHPCS) | ||
37 | 29 | ||
38 | ### - errors filtered by coding standard: PEAR, PSR1, PSR2, Zend... | 30 | ### - errors filtered by coding standard: PEAR, PSR1, PSR2, Zend... |
39 | PHPCS_%: | 31 | PHPCS_%: |
40 | @$(BIN)/phpcs $(PHP_SOURCE) --report-full --report-width=200 --standard=$* | 32 | @$(PHPCS) --report-full --report-width=200 --standard=$* |
41 | 33 | ||
42 | ### - errors by Git author | 34 | ### - errors by Git author |
43 | code_sniffer_blame: | 35 | code_sniffer_blame: |
44 | @$(BIN)/phpcs $(PHP_SOURCE) --report-gitblame | 36 | @$(PHPCS) --report-gitblame |
45 | 37 | ||
46 | ### - all errors/warnings | 38 | ### - all errors/warnings |
47 | code_sniffer_full: | 39 | code_sniffer_full: |
48 | @$(BIN)/phpcs $(PHP_SOURCE) --report-full --report-width=200 | 40 | @$(PHPCS) --report-full --report-width=200 |
49 | 41 | ||
50 | ### - errors grouped by kind | 42 | ### - errors grouped by kind |
51 | code_sniffer_source: | 43 | code_sniffer_source: |
52 | @$(BIN)/phpcs $(PHP_SOURCE) --report-source || exit 0 | 44 | @$(PHPCS) --report-source || exit 0 |
53 | |||
54 | ## | ||
55 | # PHP Copy/Paste Detector | ||
56 | # Detects code redundancy | ||
57 | # Documentation: https://github.com/sebastianbergmann/phpcpd | ||
58 | ## | ||
59 | |||
60 | copy_paste: | ||
61 | @echo "-----------------------" | ||
62 | @echo "PHP COPY/PASTE DETECTOR" | ||
63 | @echo "-----------------------" | ||
64 | @$(BIN)/phpcpd $(PHP_SOURCE) || exit 0 | ||
65 | @echo | ||
66 | |||
67 | ## | ||
68 | # PHP Mess Detector | ||
69 | # Detects PHP syntax errors, sorted by category | ||
70 | # Rules documentation: http://phpmd.org/rules/index.html | ||
71 | ## | ||
72 | MESS_DETECTOR_RULES = cleancode,codesize,controversial,design,naming,unusedcode | ||
73 | |||
74 | mess_title: | ||
75 | @echo "-----------------" | ||
76 | @echo "PHP MESS DETECTOR" | ||
77 | @echo "-----------------" | ||
78 | |||
79 | ### - all warnings | ||
80 | mess_detector: mess_title | ||
81 | @$(BIN)/phpmd $(PHP_COMMA_SOURCE) text $(MESS_DETECTOR_RULES) | sed 's_.*\/__' | ||
82 | |||
83 | ### - all warnings + HTML output contains links to PHPMD's documentation | ||
84 | mess_detector_html: | ||
85 | @$(BIN)/phpmd $(PHP_COMMA_SOURCE) html $(MESS_DETECTOR_RULES) \ | ||
86 | --reportfile phpmd.html || exit 0 | ||
87 | |||
88 | ### - warnings grouped by message, sorted by descending frequency order | ||
89 | mess_detector_grouped: mess_title | ||
90 | @$(BIN)/phpmd $(PHP_SOURCE) text $(MESS_DETECTOR_RULES) \ | ||
91 | | cut -f 2 | sort | uniq -c | sort -nr | ||
92 | |||
93 | ### - summary: number of warnings by rule set | ||
94 | mess_detector_summary: mess_title | ||
95 | @for rule in $$(echo $(MESS_DETECTOR_RULES) | tr ',' ' '); do \ | ||
96 | warnings=$$($(BIN)/phpmd $(PHP_COMMA_SOURCE) text $$rule | wc -l); \ | ||
97 | printf "$$warnings\t$$rule\n"; \ | ||
98 | done; | ||
99 | 45 | ||
100 | ## | 46 | ## |
101 | # Checks source file & script permissions | 47 | # Checks source file & script permissions |
@@ -170,6 +116,7 @@ release_tar: composer_dependencies htmldoc translate build_frontend | |||
170 | git archive --prefix=$(ARCHIVE_PREFIX) -o $(ARCHIVE_VERSION).tar HEAD | 116 | git archive --prefix=$(ARCHIVE_PREFIX) -o $(ARCHIVE_VERSION).tar HEAD |
171 | tar rvf $(ARCHIVE_VERSION).tar --transform "s|^vendor|$(ARCHIVE_PREFIX)vendor|" vendor/ | 117 | tar rvf $(ARCHIVE_VERSION).tar --transform "s|^vendor|$(ARCHIVE_PREFIX)vendor|" vendor/ |
172 | tar rvf $(ARCHIVE_VERSION).tar --transform "s|^doc/html|$(ARCHIVE_PREFIX)doc/html|" doc/html/ | 118 | tar rvf $(ARCHIVE_VERSION).tar --transform "s|^doc/html|$(ARCHIVE_PREFIX)doc/html|" doc/html/ |
119 | tar rvf $(ARCHIVE_VERSION).tar --transform "s|^tpl|$(ARCHIVE_PREFIX)tpl|" tpl/ | ||
173 | gzip $(ARCHIVE_VERSION).tar | 120 | gzip $(ARCHIVE_VERSION).tar |
174 | 121 | ||
175 | ### generate a release zip and include 3rd-party dependencies and translations | 122 | ### generate a release zip and include 3rd-party dependencies and translations |
@@ -180,6 +127,8 @@ release_zip: composer_dependencies htmldoc translate build_frontend | |||
180 | zip -r $(ARCHIVE_VERSION).zip $(ARCHIVE_PREFIX)doc/ | 127 | zip -r $(ARCHIVE_VERSION).zip $(ARCHIVE_PREFIX)doc/ |
181 | rsync -a vendor/ $(ARCHIVE_PREFIX)vendor/ | 128 | rsync -a vendor/ $(ARCHIVE_PREFIX)vendor/ |
182 | zip -r $(ARCHIVE_VERSION).zip $(ARCHIVE_PREFIX)vendor/ | 129 | zip -r $(ARCHIVE_VERSION).zip $(ARCHIVE_PREFIX)vendor/ |
130 | rsync -a tpl/ $(ARCHIVE_PREFIX)tpl/ | ||
131 | zip -r $(ARCHIVE_VERSION).zip $(ARCHIVE_PREFIX)tpl/ | ||
183 | rm -rf $(ARCHIVE_PREFIX) | 132 | rm -rf $(ARCHIVE_PREFIX) |
184 | 133 | ||
185 | ## | 134 | ## |
@@ -197,10 +146,9 @@ authors: | |||
197 | @git shortlog -sne > AUTHORS | 146 | @git shortlog -sne > AUTHORS |
198 | @rm .mailmap | 147 | @rm .mailmap |
199 | 148 | ||
200 | ### generate Doxygen documentation | 149 | ### generate phpDocumentor documentation |
201 | doxygen: clean | 150 | phpdoc: clean |
202 | @rm -rf doxygen | 151 | @docker run --rm -v $(PWD):/data -u `id -u`:`id -g` phpdoc/phpdoc |
203 | @doxygen Doxyfile | ||
204 | 152 | ||
205 | ### generate HTML documentation from Markdown pages with MkDocs | 153 | ### generate HTML documentation from Markdown pages with MkDocs |
206 | htmldoc: | 154 | htmldoc: |