Welcome to mirror list, hosted at ThFree Co, Russian Federation.

mk_linters.mk - github.com/HuasoFoundries/phpPgAdmin6.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 232bceed8544ae49205f9e38b2f782e77620a0fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
VERSION = $(shell cat composer.json | sed -n 's/.*"version": "\([^"]*\)"/\1/p')

SHELL = /usr/bin/env bash

HAS_PSALM := $(shell ls ./vendor/bin/xpsalm 2> /dev/null)
XDSWI := $(shell command -v xd_swi 2> /dev/null)
HAS_PHPMD := $(shell command -v phpmd 2> /dev/null)
HAS_CSFIXER:= $(shell command -v php-cs-fixer 2> /dev/null)
XDSWI_STATUS:=$(shell command xd_swi stat 2> /dev/null)
HAS_PHIVE:=$(shell command phive --version 2> /dev/null)
CURRENT_BRANCH:=$(shell command git rev-parse --abbrev-ref HEAD 2> /dev/null)
DATENOW:=`date +'%Y-%m-%d'`
YELLOW=\033[0;33m
RED=\033[0;31m
WHITE=\033[0m
GREEN=\u001B[32m




disable_xdebug:
	@if [[ "$(XDSWI)" != "" ]]; then \
    	xd_swi off ;\
    fi 

enable_xdebug:
	@if [[ "$(XDSWI)" != "" ]]; then \
    	xd_swi $(new_status) ;\
    fi 

abort_suggesting_composer:
	@if [ "0" != "$(XDSWI_STATUS)" ]; then \
		 $(YELLOW)Warn: $(GREEN)xdebug$(WHITE) is enabled. Just saying... ;\
	fi
	@if [ ! -f "$(executable)" ]; then \
		echo -e "$(GREEN)$(package_name)$(WHITE) $(RED)NOT FOUND$(WHITE) on $(CYAN)$(executable)$(WHITE). " ;\
		echo -e "Install it with $(GREEN)composer require --dev $(package_name)$(WHITE)" ;\
		echo ;\
		exit 1 ;\
	fi

check_executable_or_exit_with_phive:
	@if [ ! -f "$(executable)" ]; then \
		echo -e "$(GREEN)$(package_name)$(WHITE) $(RED)NOT FOUND$(WHITE) on $(CYAN)$(executable)$(WHITE). " ;\
		echo -e "Install it with $(GREEN)phive install $(package_name)$(WHITE)" ;\
		echo ;\
		exit 1 ;\
	fi
	@if [ "0" != "$(XDSWI_STATUS)" ]; then \
		 $(YELLOW)Warn: $(GREEN)xdebug$(WHITE) is enabled. Just saying... ;\
	fi


update_baselines:
	@${MAKE} disable_xdebug  --no-print-directory ;\
	find .build/phpstan -mtime +5 -type f -name "*.php" -exec rm -rf {} \;
	@vendor/bin/phpstan analyze --configuration phpstan.neon --generate-baseline ;\
	find .build/psalm -mtime +5 -type f   -exec rm -rf {} \;
	@vendor/bin/psalm --config=psalm.xml --update-baseline --ignore-baseline  --set-baseline=psalm-baseline.xml ;\
	${MAKE} enable_xdebug new_status=$(XDSWI_STATUS)  --no-print-directory

.PHONY:abort_suggesting_composer check_executable_or_exit_with_phive update_baselines

phpmd: package_name:=phpmd
phpmd: executable:= $(shell command -v phpmd 2> /dev/null)
phpmd: 
	@${MAKE} check_executable_or_exit_with_phive  executable=$(executable) package_name=$(package_name) --no-print-directory 
	@$(executable) src text .phpmd.xml --exclude=src/help/*,src/translations/*

phpmd_checkstyle: package_name:=phpmd
phpmd_checkstyle: executable:=$(shell command -v phpmd 2> /dev/null)
phpmd_checkstyle:
	@$(executable) src json .phpmd.xml --exclude=src/help/*,src/translations/*   > temp/phpmd.report.json  ;\
	echo -e "$(GREEN)Finished PHPMD$(WHITE): waiting 1s"
	@sleep 1 ;\
	php tools/phpmd_checkstyle.php ;\
	echo -e "$(GREEN)Formatted PHPMD$(WHITE): as checkStyle"
	cat temp/phpmd.checkstyle.xml | vendor/bin/cs2pr 

csfixer: package_name:=friendsofphp/php-cs-fixer
csfixer: executable:=vendor/bin/php-cs-fixer
csfixer:
ifeq (,$(reportformat))
	$(eval reportformat='txt')
endif
	@${MAKE} abort_suggesting_composer executable=$(executable) package_name=$(package_name) --no-print-directory
	@mkdir -p .build/phpcs && touch .build/phpcs/csfixer.cache ;\
	vendor/bin/php-cs-fixer fix --config=.php_cs.php --cache-file=.build/phpcs/csfixer.cache --format=$(reportformat) $(dry_run)  --diff

csfixer_checkstyle:
	@${MAKE} csfixer reportformat=checkstyle  dry_run='--dry-run' --no-print-directory > temp/csfixer.checkstyle.xml ;\
	cat temp/csfixer.checkstyle.xml | vendor/bin/cs2pr ;\
	echo ""

csfixer_dry:
	@${MAKE} csfixer   dry_run='--dry-run' --no-print-directory

	
phpcs: package_name=phpcs
phpcs: executable:= $(shell command -v phpcs 2> /dev/null)
phpcs:
ifeq (,$(reportformat))
	$(eval reportformat='diff')
endif	
	@${MAKE} check_executable_or_exit_with_phive  executable=$(executable) package_name=$(package_name) --no-print-directory 
	@mkdir -p .build/phpcs && touch .build/phpcs/php-cs.cache ;\
	$(executable)  --standard=.phpcs.xml  --parallel=2 --cache=.build/phpcs/php-cs.cache --report=$(reportformat) src/*



phpcs_checkstyle:
	@${MAKE} phpcs reportformat=checkstyle --no-print-directory  > temp/phpcs.checkstyle.xml ;\
	echo -e "Finished $(GREEN)phpcs$(WHITE): waiting 1s"
	@sleep 1 ;\
	cat temp/phpcs.checkstyle.xml | vendor/bin/cs2pr 


psalm:
	$(eval executable:=vendor/bin/psalm)
	$(eval package_name:=vimeo/psalm)
	@${MAKE} abort_suggesting_composer executable=$(executable) package_name=$(package_name) --no-print-directory 
	@mkdir -p .build/psalm ;\
	echo -e "Running:" ;\
	echo -e "$(GREEN)vendor/bin/psalm$(WHITE) --show-info=false --long-progress --threads=2 --config=psalm.xml "
	@vendor/bin/psalm --show-info=false --long-progress --threads=2 --config=psalm.xml 


		echo -e "Install it with $(GREEN)composer require --dev$(package_name)$(WHITE)" ;\
		exit 1 ;\

phpstan:
	$(eval executable:=vendor/bin/phpstan)
	$(eval package_name:=phpstan/phpstan)
	@${MAKE} abort_suggesting_composer executable=$(executable) package_name=$(package_name) --no-print-directory 
	@mkdir -p .build/phpstan ;\
	echo -e "Running:" ;\
	echo -e "$(GREEN)vendor/bin/phpstan$(WHITE) analyse --memory-limit=2G   --configuration phpstan.neon " 

	@vendor/bin/phpstan analyse --memory-limit=2G   --configuration phpstan.neon 

phpstan_checkstyle:
	@${MAKE} phpstan error-format=checkstyle >  temp/phpstan.checkstyle.xml ;\
	cat temp/phpstan.checkstyle.xml | vendor/bin/cs2pr ;\
	echo ""

lint:
	$(eval executable:=vendor/bin/parallel-lint )
	$(eval package_name:=php-parallel-lint/php-parallel-lint )
	@${MAKE} abort_suggesting_composer executable=$(executable) package_name=$(package_name) --no-print-directory 
	mkdir -p .build/parallel ;\
	$(executable) --ignore-fails --exclude vendor  src 


fixers: dependency_analysis lint csfixer_dry psalm phpstan phpcs  



install_dev_deps:
	@if [ "$(HAS_PHIVE)" == "" ]; then \
		echo -e "$(GREEN)phive$(WHITE) is $(RED)NOT$(WHITE) installed. " ;\
		echo -e "Visit $(GREEN)https://github.com/phar-io/phive$(WHITE) and follow install procedure" ;\
	else \
		 phive install -g --trust-gpg-keys phpmd ;\
		 phive install -g --trust-gpg-keys phpcpd ;\
		 phive install -g --trust-gpg-keys phpcs ;\
		 phive install -g --trust-gpg-keys composer-unused ;\
		 phive install -g --trust-gpg-keys composer-require-checker ;\
		curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b tools ;\
	fi ;\
	echo ""


.PHONY: dependency_analysis
dependency_analysis: vendor ## Runs a dependency analysis with maglnet/composer-require-checker
	$(eval executable:=tools/composer-require-checker)
	$(eval package_name:=composer-require-checker )
	@${MAKE} check_executable_or_exit_with_phive executable=$(executable) package_name=$(package_name) --no-print-directory 
	@$(executable) check --config-file=$(shell pwd)/.build/composer-require-checker.json
	tools/composer-unused --excludePackage=adodb/adodb-php



	
reviewdog:
	$(eval executable:=tools/reviewdog)
	$(eval package_name:=reviewdog )
	@if [ ! -f "$(executable)" ]; then \
		echo -e "$(GREEN)$(package_name)$(WHITE) $(RED)NOT FOUND$(WHITE) on $(CYAN)$(executable)$(WHITE). " ;\
		echo -e "Install it with " ;\
		echo -e "curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b tools " ;\
		exit 1 ;\
	fi
	@tools/reviewdog -diff="git diff develop"