Remove excessive empty lines from output
dcastro opened this issue · 0 comments
dcastro commented
Clarification and motivation
The output of xrefcheck seems to contain an excessive amount of empty lines.
Let's trim this.
Example 1
File a.md
:
[a](invalid.md)
[a](invalid.md)
Output
$ xrefcheck
Configuration file not found, using default config for GitHub repositories
=== Invalid references found ===
➥ In file a.md
bad reference (relative) at src:1:1-15:
- text: "a"
- link: invalid.md
- anchor: -
⛀ File does not exist:
invalid.md
➥ In file a.md
bad reference (relative) at src:2:1-15:
- text: "a"
- link: invalid.md
- anchor: -
⛀ File does not exist:
invalid.md
Invalid references dumped, 2 in total.
- We begin by printing
Configuration file not found ...
and an empty line to stderr, and then 2 empty lines to stdout. These 2 lines are really not needed. - We print 2 lines after each invalid reference - 1 line would suffice.
Example 2
If we add an empty b.md
file and run xrefcheck with -v
:
File a.md
:
[a](invalid.md)
[a](invalid.md)
File b.md
:
Output
$ xrefcheck -v
Configuration file not found, using default config for GitHub repositories
=== Repository data ===
⮚ a.md:
- references:
- reference (relative) at src:1:1-15:
- text: "a"
- link: invalid.md
- anchor: -
- reference (relative) at src:2:1-15:
- text: "a"
- link: invalid.md
- anchor: -
- anchors: []
⮚ b.md:
- references:
- reference (relative) at src:1:1-9:
- text: "a"
- link: a.md
- anchor: -
- reference (relative) at src:2:1-9:
- text: "a"
- link: a.md
- anchor: -
- anchors: []
=== Invalid references found ===
➥ In file a.md
bad reference (relative) at src:1:1-15:
- text: "a"
- link: invalid.md
- anchor: -
⛀ File does not exist:
invalid.md
➥ In file a.md
bad reference (relative) at src:2:1-15:
- text: "a"
- link: invalid.md
- anchor: -
⛀ File does not exist:
invalid.md
Invalid references dumped, 2 in total.
- "Repository data" only prints 1 empty line in-between each item, which is good.
- However, we now have 4 empty lines before the "Invalid references" section.
Example 3
Now let's try printing scanning errors:
File a.md
:
<!-- xrefcheck: ignore wrong -->
<!-- xrefcheck: ignore wrong -->
[a](invalid.md)
[a](invalid.md)
File b.md
:
Output
$ xrefcheck -v
Configuration file not found, using default config for GitHub repositories
=== Repository data ===
⮚ a.md:
- references:
- reference (relative) at src:4:1-15:
- text: "a"
- link: invalid.md
- anchor: -
- reference (relative) at src:5:1-15:
- text: "a"
- link: invalid.md
- anchor: -
- anchors: []
⮚ b.md:
- references:
- reference (relative) at src:1:1-9:
- text: "a"
- link: a.md
- anchor: -
- reference (relative) at src:2:1-9:
- text: "a"
- link: a.md
- anchor: -
- anchors: []
=== Scan errors found ===
➥ In file a.md
scan error at src:1:1-32:
⛀ Unrecognised option "wrong" perhaps you meant <"ignore link"|"ignore paragraph"|"ignore all">
➥ In file a.md
scan error at src:2:1-32:
⛀ Unrecognised option "wrong" perhaps you meant <"ignore link"|"ignore paragraph"|"ignore all">
Scan errors dumped, 2 in total.
=== Invalid references found ===
➥ In file a.md
bad reference (relative) at src:4:1-15:
- text: "a"
- link: invalid.md
- anchor: -
⛀ File does not exist:
invalid.md
➥ In file a.md
bad reference (relative) at src:5:1-15:
- text: "a"
- link: invalid.md
- anchor: -
⛀ File does not exist:
invalid.md
Invalid references dumped, 2 in total.
- Again, similar issues as we saw in example 1. We're printing 2 lines after each scanning error, 1 would suffice.
- We're also printing 2 empty lines after "Scan errors dumped, 2 in total."
Example 4
For some reason, the buildable instance for the verification error ExternalResourceSomeError
prints 1 additional empty line when compared to the other verification errors:
File a.md
:
[a](http://wwwwwwwwwww)
[a](invalid.md)
Output
$ xrefcheck
xrefcheck
Configuration file not found, using default config for GitHub repositories
=== Invalid references found ===
➥ In file a.md
bad reference (external) at src:1:1-23:
- text: "a"
- link: http://wwwwwwwwwww
- anchor: -
⛂ ConnectionFailure Network.Socket.getAddrInfo (called with preferred socket type/protocol: AddrInfo {addrFlags = [], addrFamily = AF_UNSPEC, addrSocketType = Stream, addrProtocol = 0, addrAddress = 0.0.0.0:0, addrCanonName = Nothing}, host name: Just "wwwwwwwwwww", service name: Just "80"): does not exist (Temporary failure in name resolution)
➥ In file a.md
bad reference (relative) at src:2:1-15:
- text: "a"
- link: invalid.md
- anchor: -
⛀ File does not exist:
invalid.md
Invalid references dumped, 2 in total.
As we can see, there's 3 empty lines after ConnectionFailure
.
Acceptance criteria
- We never print 2 adjacent empty lines.