Skip to content

Commit

Permalink
lint: refactor final output message (#503)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ee7 authored Jan 26, 2022
1 parent 6033961 commit 3171b11
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions src/lint/lint.nim
Original file line number Diff line number Diff line change
Expand Up @@ -22,40 +22,40 @@ 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)

const url = "https://github.com/exercism/docs/blob/main/building/configlet/lint.md"

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)

0 comments on commit 3171b11

Please sign in to comment.