From 3171b116594efc8801ac0c74c2db5bd9d18d1bfd Mon Sep 17 00:00:00 2001 From: ee7 <45465154+ee7@users.noreply.github.com> Date: Wed, 26 Jan 2022 12:19:42 +0100 Subject: [PATCH] lint: refactor final output message (#503) Changes: - Indent contents of triple-quoted string literals, using `unindent` or `dedent`. This improves readability, and consistency with other code. - Move a block of code, to clarify that we currently only print the message about warnings when there were warnings but no errors. --- src/lint/lint.nim | 56 +++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/lint/lint.nim b/src/lint/lint.nim index 5c341843..c67ec940 100644 --- a/src/lint/lint.nim +++ b/src/lint/lint.nim @@ -22,9 +22,10 @@ proc allChecksPass(trackDir: Path): bool = result = allTrue(checks) proc lint*(conf: Conf) = - echo "The lint command is under development.\n" & - "Please re-run this command regularly to see if your track passes " & - "the latest linting rules.\n" + echo """ + The lint command is under development. + Please re-run this command regularly to see if your track passes the latest linting rules. + """.unindent() let trackDir = Path(conf.trackDir) @@ -32,30 +33,29 @@ proc lint*(conf: Conf) = if allChecksPass(trackDir): echo """ -Basic linting finished successfully: -- config.json exists and is valid JSON -- config.json has these valid fields: - language, slug, active, blurb, version, status, online_editor, key_features, tags -- Every concept has the required .md files -- Every concept has a valid links.json file -- Every concept has a valid .meta/config.json file -- Every concept exercise has the required .md files -- Every concept exercise has a valid .meta/config.json file -- Every practice exercise has the required .md files -- Every practice exercise has a valid .meta/config.json file -- Required track docs are present -- Required shared exercise docs are present""" + Basic linting finished successfully: + - config.json exists and is valid JSON + - config.json has these valid fields: + language, slug, active, blurb, version, status, online_editor, key_features, tags + - Every concept has the required .md files + - Every concept has a valid links.json file + - Every concept has a valid .meta/config.json file + - Every concept exercise has the required .md files + - Every concept exercise has a valid .meta/config.json file + - Every practice exercise has the required .md files + - Every practice exercise has a valid .meta/config.json file + - Required track docs are present + - Required shared exercise docs are present""".dedent() + if printedWarning: + echo "" + const msg = """ + Configlet produced at least one warning. + These warnings might become errors in a future configlet release. + For more information, please see the documentation:""".unindent() + warn(msg, url, doubleFinalNewline = false) else: - echo &""" -Configlet detected at least one problem. -For more information on resolving the problems, please see the documentation: -{url}""" + echo fmt""" + Configlet detected at least one problem. + For more information on resolving the problems, please see the documentation: + {url}""".unindent() quit(1) - - if printedWarning: - echo "" - const msg = """ - Configlet produced at least one warning. - These warnings might become errors in a future configlet release. - For more information, please see the documentation:""".unindent() - warn(msg, url, doubleFinalNewline = false)