Commit Graph

33 Commits

Author SHA1 Message Date
Diogo Castro
0871e29907
v0.2.1 release 2022-09-24 08:30:53 +01:00
Sergey Gulin
a99005d731
[#156] Make all config options optional
Problem: In #126 we made the `ignoreRefs` option required (to match the
other options). However, having it optional is better for
backwards-compatibility and to help users migrate to newer xrefcheck
versions.

Solution: Make all config options optional.
2022-09-24 05:51:39 +10:00
Sergey Gulin
c8d19a3f98
[#56] Dump all the errors from different files
Problem: Currently, xrefcheck fails immediately after the first
observed error because `die` is used right in `markdownScanner` What
we want is dumping all the errors from different markdowns and then
print them as a final xrefcheck's result together with the broken
links. Also, despite the fact that in the `makeError` function we have
4 error messages, 2 of them are not reported, and the test case that
should check this only checks that at least one of the four files
throws an error.

Solution: Make xrefcheck to report all errors. Add `ScanError` type
and propagate errors to report all of them, rather than failing
immediately after the first error is detected.
2022-09-23 17:13:50 +10:00
Diogo Castro
0a4b70f1e8
[Chore] Fix changelog
Problem: A `0.2.1` section was added to the changelog by mistake in #68,
even though no release was made. This was corrected and undone in #100.
It seems it was added back in again in #88, most likely due to a rebase
mixup.

Solution: Delete this section again.
2022-09-21 11:23:42 +01:00
Sergey Gulin
db77aaa9e4
[#137] Remove checkLocalhost option
Problem: In #85, we added the `checkLocalhost` option to decide
whether to verify links to localhost. However, upon further
reflection, it seems like this could have been subsumed by the
existing `ignoreRefs` option instead.

Solution: Remove `check-localhost` CLI option and `checkLocalhost`
config option. Add a regex matching localhost links to the
`ignoreRefs` field of the default config.
2022-09-16 03:00:53 +10:00
Sergey Gulin
332da5569e
[#77] Add support for glob patterns to ignored and notScanned
Problem: The `virtualFiles` config option supports glob patterns. On the
other hand, `ignored` only supports exact matches and `notScanned`
mathches on prefixes. There is also a bug where `ignored` does not
ignore files if they contain broken xrefcheck annotations.

Solution: Add support for glob patterns to `ignored` and
`notScanned`. Filter ignored files before parsing their contents.
2022-09-08 22:49:27 +10:00
Sergey Gulin
a3f2d28216
[#125] Display URL parsing errors
Problem: We use a 2-step process to parse a URL: we use `parseURI` and
then `mkURIBs`. Both of these functions can fail. At the moment, we're
ignoring their errors and simply throwing a `ExternalResourceInvalidUri`,
and then displaying a generic error message to the user.

Solution: Catch errors from `parseUri` and `mkURIBs` and use them to
tell user why the URL was invalid.
2022-09-08 22:31:12 +10:00
Sergey Gulin
36a1da6473
[#120] Fix bug with ignoring checks for relative anchors
Problem: When a file contains a reference to another file, and that
reference contains an anchor, that anchor is not checked.

Solution: Normalise relative anchor links before check.
2022-09-07 21:48:13 +10:00
Constantine Ter-Matevosian
80b5edd1c7
[#49] Allow certain reserved characters in the URLs
Problem: The current version of xrefcheck doesn't allow the square
brackets and some other special characters, like the angle brackets and
the curly brackets, to be present in the URLs, even in the query
strings, as they need to be percent-encoded first.

Solution: Allow some of the reserved characters, like the brackets, to
be present in the query strings of the URLs.
There exist two main standards of URL parsing: RFC 3986 and the Web
Hypertext Application Technology Working Group's URL standard. Ideally,
we want to be able to parse the URLs in accordance with the latter
standard, because it provides a much less ambiguous set of rules for
percent-encoding special characters, and is essentially a living
standard that gets updated constantly.
We allow these characters to be present in the query strings by using
the `parseURI` function from the `uri-bytestring` library with
`laxURIParseOptions`.
2022-09-06 04:39:40 +10:00
Nurlan Alkuatov
86e17eb3a4 [#99] Support Retry-After headers with dates
Problem: We currently support obtaining `Retry-After` header
values as seconds. However, the http specs state that the header
value can be also a date, e.g: `Wed, 21 Oct 2015 07:28:00 GMT`.

Solution: Support `Retry-After` headers with dates.
2022-09-05 13:17:05 +06:00
Sergey Gulin
ea88032a95
[#94] Changelog update: Add support for the id attribute in anchors
Problem: We added support for the `id` attribute in anchors. Since
this is "user-facing change", we should add an entry to `CHANGES.md`.

Solution: Add an entry to `CHANGES.md`.
2022-08-29 18:48:11 +10:00
Sergey Gulin
81ebde0d99
[#126] Changelog update: Make ignoreRefs a required parameter
Problem: We made `ignoreRefs` a required option. Since this
is "user-facing change", we should add an entry to `CHANGES.md`.

Solution: Add an entry to `CHANGES.md`.
2022-08-29 17:32:50 +10:00
Nurlan Alkuatov
96960f7ebf [#90] Forbid verifying a single file
Problem: Verifying a single file using `-r` option missbehaves
when there are absolute links present in the file. Since `-r`
option expects a directory, we can just forbid verifying a single
file.

Solution: Fail with an error message when the user tries to
specify a file as the repository's root directory.
2022-07-24 18:59:53 +06:00
Diogo Castro
e5be7a4321
[Chore] Add missing changelog entries 2022-07-22 16:51:28 +01:00
Constantine Ter-Matevosian
032395007b
[#31] Handle the "429 too many requests" errors
Problem: The current version of xrefcheck handles the HTTP responses
with the 429 status code just like every other error, when it is
possible to try and eliminate the occurrences of such errors within the
program itself.

Solution: Each time the result of performing a request on a given link
is a 429 error, retrieve the Retry-After information, describing the
delay (in seconds), from the headers of the HTTP response, or,
alternatively, use a configurable default value if the Retry-After
header is absent, and rerun the request after an amount of time
described by the said value had passed. Only after the number of retries
had reached its limiting value, which, as of right now, is not
configurable and is hardcoded, is when the 429 error is converted into
becoming 'unfixable', and any further attempts to remove the error are
terminated.

Additionally, the progress bar has been upgraded and the following
elements are supplied:
1. an extra color -- Blue -- indicating the errors that might get
   eliminated during the verification;
2. a timer with the number of seconds left to wait for the restart of
   the request; if, during the verification, a new 429 error had emerged
   with the new Retry-After value being greater than or equal to the
   elapsed time, the timer is immediately updated with that value and
   begins ticking down each second from scratch.
2022-07-14 17:25:52 +03:00
Андреев Кирилл
a9a156ef41
Undo errorneous version increment 2021-11-09 15:50:13 +04:00
Constantine Ter-Matevosian
b9e7ffb99d
[#75] Fix the root with an appended slash support
Problem: The results of the repository analysis will always contain
invalid references if the root contains a trailing forward slash.

Solution: Strip the root's trailing slash (if present) when having it be
given as an argument of the System.FilePath.Posix.takeDirectory
function.
2021-10-26 15:16:47 +03:00
Constantine Ter-Matevosian
82accc132c [#74] Detect and handle duplicate links during verification
Problem: All the duplicate external links get verified independently,
which is wasteful.

Solution: Store the verification results in the map. Verify the link
once if it hasn't been verified already, and insert the results
into the map; alternatively, if the link has been verified before,
return the results by retrieving the respective value from the map.
The traversal of all the filepath-reference pairs is done via
'forConcurrentlyCaching', which is semantically similar to
Control.Concurrent.Async.forConcurrently, except it stores the
action results in a map (in our case, we need to store the
verification results of only the external references).
2021-10-08 19:29:11 +03:00
Andrey Demidenko
c67ee9bd52
[#47] Handle ftp links
Problem:
Currently we support only http and https links. If there is an `ftp://`
link, you will get exception.

Solution:
Use `ftp-client` to check connection to ftp, see response statuses and
check file existence. This produces adding new error types and small
refactoring.
Provide a test which is separate executable, where we have to pass CLA -
ftp host.

Co-authored-by: Alexander Bantyev <alexander.bantyev@serokell.io>
2021-10-08 13:59:14 +03:00
Andrey Demidenko
24226ac2d8
[#81] Add config option for protected links
Problem:
We do not know what to do with protected links, because we cannot check
them. So we have two options, assume that these links is valid or not.

Solution:
Provide config option for user to decide what to do - assume protected
links valid or not.
2021-10-08 13:29:19 +03:00
Andrey Demidenko
29d4f12c61
[#81] Add config option for localhost links
Problem:
Almost all the time we can't validate localhost links, so we just skip them.
But to run ftp links tests (#47) we need to refer to localhost.

Solution:
Add config option whether to ignore localhost links and provide bats
tests for this new feature.

Co-authored-by: Alexander Bantyev <alexander.bantyev@serokell.io>
2021-10-08 13:29:19 +03:00
Kirill Andreev
a61defd917
[#62] [INT-141] Add to changelog, update version 2021-10-04 14:12:09 +04:00
martoon
06a39de707
Make 0.2 release 2021-05-04 15:51:28 +03:00
martoon
1042699bbf
Update changelog 2021-05-04 15:36:26 +03:00
martoon
63c09a0e55
Prepare 0.1.3 release
Problem: the feature with ignoring links has been added, and it is
necessary in many places.

Solution: make a release.
2021-03-17 15:06:19 +03:00
Alyona Antonova
e22bb18c55 [#135] Add "ignoring" changes to CHANGES.md
Problem: Changes connected with adding `ignoreRefs`
and ignorong modes are not stated in `CHANGES.md`

Solution: Add information about such changes.
2021-03-09 22:18:07 +03:00
martoon
0d6e61905f
Make a release 2020-06-26 22:32:03 +03:00
martoon
967da232d3
Disable progress bar in CI automatically
Problem: we have two major use cases:

1. Using xrefcheck in CI, in this case it is annoying for devops to
always pass mostly always reasonable `--no-progress` option.
2. Using it locally, here we want progress bar to be enabled by default
so that user could run `xrefcheck` without any options most of the time.

Solution:

Detect whether are we running in CI and use the respective default for
whether progress bar should be displayed.

Detecting whether we are within CI is possible using `CI` env variable,
at least Github actions, Gitlab CI and Buildkite pass this env.

`--no-progress` option still can be passed if user wants to suppress
progress bar in local run. The opposite `--progress` seems to also make
sense, because in case if high timeouts are set, user probably wants to
track progress somehow to make sure that CI didn't hang. So we add the
latter, and these two options can be used to override the default
behaviour defined by `CI` env var.
2020-06-26 22:32:03 +03:00
Ivan Gromakovskii
557cbeef54
Update version and changelog
Hopefully with recent changes Hackage will finally manage to
build this package, so let's try uploading again.
2020-05-19 21:15:51 +03:00
martoon
8f0c955230
Make a new release
This should fix the build problems on Hackage.
2020-05-15 21:01:52 +03:00
martoon
8e85855eb7
Bump version to 0.1.1 2020-04-28 19:25:28 +03:00
martoon
36226d0130
Update changelog 2020-04-28 19:25:28 +03:00
Ivan Gromakovskii
ec9f8bae5e
Add a changelog, require its maintenance
Problem: we are going to release this tool and from that point
it would be nice to maintain its changelog.

Solution: add a simple CHANGES.md and update PR template.
2020-01-14 20:24:01 +03:00