Standard: Code readability #175

Open
opened 2020-08-21 03:56:31 +02:00 by Kreyren · 1 comment
Kreyren commented 2020-08-21 03:56:31 +02:00 (Migrated from github.com)

If you are contributing to Zernit's projects then your code will be read and rewritten by other developers thus you are expected to make the code readable to make it easier for other developers to work on your code.

For example:

## Unwanted ##

#@ Build the script
build: vendor
@ printf 'INFO: %s\n' "Replacing '#& APPEND path' with requested code" && grep "^#& APPEND.*" src/bin/dockervuantor.sh | while IFS= read -r string; do printf '%s\n' "Processing $${string##*/} from appended" && cp "$${string##\#& APPEND }" "vendor/$${string##*/}" && printf "g/^#!\/.*/d\nw\nq\n" | ed -s "vendor/$${string##*/}" && printf "g/###! .*/d\nw\nq\n" | ed -s "vendor/$${string##*/}" && printf "g/# shellcheck .*/d\nw\nq\n" | ed -s "vendor/$${string##*/}" && printf "g/^# .*/d\nw\nq\n" | ed -s "vendor/$${string##*/}" && printf "1;/./-d\\nw\\nq\\n" | ed -s "vendor/$${string##*/}" && printf "/^#& APPEND $$(printf '%s\n' "$${string##\#& APPEND }" | sed "s#\/#\\\/#gm")/d\n-1r vendor/$${string##*/}\\nw\\nq\\n" | ed -s build/dockervuantor.sh && printf '%s\n' "File '$$string' has been processed";	done && printf '%s\n' "Replaced all mensioning of '#& APPEND path' with requested code"
	...
	$(info Build phase finished)

## Wanted ##

#@ Build the script
build: vendor
	...
	@ true \
		&& printf 'INFO: %s\n' "Replacing '#& APPEND path' with requested code" \
		&& grep "^#& APPEND.*" src/bin/dockervuantor.sh | while IFS= read -r string; do \
				true \
				&& printf '%s\n' "Processing $${string##*/} from appended" \
				&& cp "$${string##\#& APPEND }" "vendor/$${string##*/}" \
				&& : "Remove shebang from appended code" \
				&& printf "g/^#!\/.*/d\nw\nq\n" | ed -s "vendor/$${string##*/}" \
				&& : "Remove documentation comments from appended code" \
				&& printf "g/###! .*/d\nw\nq\n" | ed -s "vendor/$${string##*/}" \
				&& : "Remove shellcheck directives from appended code" \
				&& printf "g/# shellcheck .*/d\nw\nq\n" | ed -s "vendor/$${string##*/}" \
				&& : "Remove comments from appended code" \
				&& printf "g/^# .*/d\nw\nq\n" | ed -s "vendor/$${string##*/}" \
				&& : "Remove the first three blank lines if they are present (mostly they are)" \
				&& printf "1;/./-d\\nw\\nq\\n" | ed -s "vendor/$${string##*/}" \
				&& : "Replace '#& APPEND ...' with content from the file" \
				&& printf "/^#& APPEND $$(printf '%s\n' "$${string##\#& APPEND }" | sed "s#\/#\\\/#gm")/d\n-1r vendor/$${string##*/}\\nw\\nq\\n" | ed -s build/dockervuantor.sh\
				&& printf '%s\n' "File '$$string' has been processed";\
			done \
		&& printf '%s\n' "Replaced all mensioning of '#& APPEND path' with requested code"
	...
	$(info Build phase finished)

Raw file to prove the point: 4b874949a7/saasg.makefile

<!-- Please keep your request as short as possible, the longer the request the longer it's going to take for us to process it --> If you are contributing to Zernit's projects then your code will be read and rewritten by other developers thus you are expected to make the code readable to make it easier for other developers to work on your code. For example: ```makefile ## Unwanted ## #@ Build the script build: vendor @ printf 'INFO: %s\n' "Replacing '#& APPEND path' with requested code" && grep "^#& APPEND.*" src/bin/dockervuantor.sh | while IFS= read -r string; do printf '%s\n' "Processing $${string##*/} from appended" && cp "$${string##\#& APPEND }" "vendor/$${string##*/}" && printf "g/^#!\/.*/d\nw\nq\n" | ed -s "vendor/$${string##*/}" && printf "g/###! .*/d\nw\nq\n" | ed -s "vendor/$${string##*/}" && printf "g/# shellcheck .*/d\nw\nq\n" | ed -s "vendor/$${string##*/}" && printf "g/^# .*/d\nw\nq\n" | ed -s "vendor/$${string##*/}" && printf "1;/./-d\\nw\\nq\\n" | ed -s "vendor/$${string##*/}" && printf "/^#& APPEND $$(printf '%s\n' "$${string##\#& APPEND }" | sed "s#\/#\\\/#gm")/d\n-1r vendor/$${string##*/}\\nw\\nq\\n" | ed -s build/dockervuantor.sh && printf '%s\n' "File '$$string' has been processed"; done && printf '%s\n' "Replaced all mensioning of '#& APPEND path' with requested code" ... $(info Build phase finished) ## Wanted ## #@ Build the script build: vendor ... @ true \ && printf 'INFO: %s\n' "Replacing '#& APPEND path' with requested code" \ && grep "^#& APPEND.*" src/bin/dockervuantor.sh | while IFS= read -r string; do \ true \ && printf '%s\n' "Processing $${string##*/} from appended" \ && cp "$${string##\#& APPEND }" "vendor/$${string##*/}" \ && : "Remove shebang from appended code" \ && printf "g/^#!\/.*/d\nw\nq\n" | ed -s "vendor/$${string##*/}" \ && : "Remove documentation comments from appended code" \ && printf "g/###! .*/d\nw\nq\n" | ed -s "vendor/$${string##*/}" \ && : "Remove shellcheck directives from appended code" \ && printf "g/# shellcheck .*/d\nw\nq\n" | ed -s "vendor/$${string##*/}" \ && : "Remove comments from appended code" \ && printf "g/^# .*/d\nw\nq\n" | ed -s "vendor/$${string##*/}" \ && : "Remove the first three blank lines if they are present (mostly they are)" \ && printf "1;/./-d\\nw\\nq\\n" | ed -s "vendor/$${string##*/}" \ && : "Replace '#& APPEND ...' with content from the file" \ && printf "/^#& APPEND $$(printf '%s\n' "$${string##\#& APPEND }" | sed "s#\/#\\\/#gm")/d\n-1r vendor/$${string##*/}\\nw\\nq\\n" | ed -s build/dockervuantor.sh\ && printf '%s\n' "File '$$string' has been processed";\ done \ && printf '%s\n' "Replaced all mensioning of '#& APPEND path' with requested code" ... $(info Build phase finished) ``` Raw file to prove the point: https://gist.githubusercontent.com/Kreyren/5edb96ced3509d10152af5aa6e93e159/raw/4b874949a713b6b5ab6e1c6d26cb2ed501b1d2b1/saasg.makefile
issue-label-bot[bot] commented 2020-08-21 03:56:33 +02:00 (Migrated from github.com)

Issue-Label Bot is automatically applying the label feature_request to this issue, with a confidence of 0.87. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

Issue-Label Bot is automatically applying the label `feature_request` to this issue, with a confidence of 0.87. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback! Links: [app homepage](https://github.com/marketplace/issue-label-bot), [dashboard](https://mlbot.net/data/RXT0112/Zernit) and [code](https://github.com/hamelsmu/MLapp) for this bot.
Sign in to join this conversation.
No Label
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: kreyren/Zernit#175
No description provided.