Commit Graph

52 Commits

Author SHA1 Message Date
Diogo Castro
0871e29907
v0.2.1 release 2022-09-24 08:30:53 +01: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
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
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
Andrei Borzenkov
a6b4513587 [#95] Support HTML tag parsing compatible with HTML spec
Problem: We had hardcoded HTML tag parser, that doesn't work with add valid HTML tags

Solution: Replace it with `tagsoup` library, that care about all parsing stuff
2022-07-17 20:48:51 +04: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
Andrei Borzenkov
55268fee2c [#106] Fix using ./ in paths
Problem: --ignored and --root CLI options had misbehave when you use ./ in path

Solution: add path normalisation and path-equality from System.FilePath instead of common functions for strings
2022-07-13 16:13:38 +04:00
Andrei Borzenkov
654d143113 [#105] Add hlint support, enable -Weveryting
Problem: we had a lot redundant dependencies and had no linter for handling obvious errors

Solution: hlint support and enable -Weverything flag, fix all hints from them, add hlint to the CI pipeline
2022-07-13 11:08:01 +04:00
Andrei Borzenkov
e460301275 [#107] Replace file-embed library with inline config
Problem: At new resolver version we recieved obscure error when tried to cross-compile project to Windows on CI. Changing file-embed version to the old one doesn't help us.

Solution: inline content of this file into haskell source, using raw-string-qq library, that helps us to avoid escaping and typing newline characters.
2022-07-08 13:01:13 +04:00
Andrei Borzenkov
b255445a55 [#107] Update stack resolver to the newer version
Problem: We had old resolver version, that used ghc 8.10.4 and outdated versions of libraries

Solution: Change resolver to lts 19.13, that uses ghc 9.0.2 and update haskell.nix configuration files to can build project via `nix-build` command
2022-07-08 13:01:13 +04:00
Андреев Кирилл
a9a156ef41
Undo errorneous version increment 2021-11-09 15:50:13 +04:00
Андреев Кирилл
9ecf668fbc
Add explicit strategies to deriving clauses
Problem:  The `deriving ($classes...)` is becoming obsolete.

Solution: Replace with `deriving $strat ($classes...)`;
          make old deriving a warning.
2021-11-04 18:46:54 +04:00
Андреев Кирилл
d644a95734
[#71] Separate concerns in Node traversal.
Problem:  The tree traversal uses explicit recursion and
          does not-closely-unrelated stuff at once.

Solution: Separate different actions.
2021-11-01 15:25:34 +04:00
Kirill Andreev
92c3de5587
Improve readability of imports
Problem:  In
          ```
          import qualified Foo.Bar as Bar
          import Foo.Bar (Bar)
          ```
          names of the imported modules are on different
          vertical lines, which disables autosorting,
          and makes it harder to read.

Solution: Use `ImportQualifiedPost`
2021-11-01 15:25:29 +04:00
Kirill Andreev
2f9a9d8599
Remove mixins
Problem:  Stack cannot build projects with mixins, and they only
          used to splice universum instead of base.

Solution: Use `NoImplicitPreduce` and import `Universum`
          everywhere explicitly.
2021-11-01 15:24:25 +04: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
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
045f4146cf
[#55] Generate config depending on the repo type
Problem: now when we include repository type into the config, it seems
to make sense to generate config differently depending on the repository
type. Especially taking into account that currently in some fields we
mix GitHub and GitLab -specific contents.

Solution:

Leave placeholders in the default config and later fill them from the
code depending on the required repository type.

Add a mandatory repository type parameter to `dump-config` CLI command.

Along with a test checking for config validity, add a golden test on the
produced config so that we could assess how sane it looks like.
2021-05-03 17:01:20 +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
martoon
d0ca7d7771
[#35] Stop using aeson-options
`aeson-options` package is going to be deprecated. Moreover, it does not
work in the recent lts.

Solution: use `aeson-casing` package instead.
2021-03-10 12:08:29 +03:00
Alyona Antonova
bc9e497efb [#135] Add tests and markdowns to check ignoring regex performance
Problem: There are no tests checking ignoring
regex performance.

Solution: Add test checking that broken links
matched by regexs are not verified and
test checking that not matched broken links
are verified as links with error.
2021-03-09 22:18:07 +03:00
Alyona Antonova
ecff1dc342 [#135] Add support of right in-place annotations
Problem: It can be convenient not only specifying
exclusions in the config, but also annotating
the excluded thing right in-place. It is about
adding comment before the link or the paragraph
or even the whole file to ignore this item.

Solution: Support annotation as html comment in
a "<!-- xrefcheck: ignore mode -->" format, where
mode is "link" or "paragraph" or "file". Modify
`nodeExtractInfo` from `Xrefcheck.Scanners.Markdown`
just to skip a node in AST while parsing. Take into
account that "ignore file" can only be at the top
of the file or right after the license. In markdown
terms: either the first node must be HTML_BLOCK
with "<!-- xrefcheck: ignore file -->" content
or the first is HTML_BLOCK comment (smth
between "<!--" and "-->") and the second is
HTML_BLOCK with "ignore file" content.
Also take into account that "ignore link" must be
followed by a link. Strictly speaking, there is
either LINK after "ignore link" or TEXT and LINK
(if there is some text before the link).
2021-03-09 22:18:07 +03:00
Alyona Antonova
40640124db [#135] Add vcIgnoreRefs as regexs to Xrefcheck.Config
Problem: External links must be ignored sometimes
and not be checked for validity.

Solution: Add `vcIgnoreRefs` to `Config` that is a list
of regexs using `regex-tdfa`. Each regex define a link
we want to ignore while validating. Change
`checkExternalResource` to support matching the regex.
2021-03-09 16:42:29 +03:00
Alexander Bantyev
76b7ae101b
Add a windows build 2020-07-03 12:08:22 +03:00
Ivan Gromakovskii
c56a9eb0bc
Add an upper bound on base
Problem: `stack upload` does not like that `base` does not have an
upper bound, it reports an error while checking the package.

Solution: add an upper bound on `base` to prevent people from using a
broken version of this package in case of breaking changes in `base`.
Since we build with stack, our current default is 4.13 (deduced from
the resolver). However, 4.14 does not seem to have any breaking changes
https://hackage.haskell.org/package/base-4.14.0.0/changelog
so it should be fine to permit it as well, and that's what we are doing.
2020-06-29 23:58:08 +03:00
martoon
0d6e61905f
Make a release 2020-06-26 22:32:03 +03:00
Ivan Gromakovskii
59f188c496
[#36] Switch to lts-15.13
Problem: LTS-14.16 that we currently using and a bit old.
And its GHC is old as well.

Solution: update the resolver, make some changes that were necessary.
They are pretty trivial. The only essential breaking change is the
removal of `parseUrl` from `req`.
2020-05-23 18:41:11 +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
Ivan Gromakovskii
ccc402574e
[#30] Depend on base instead of base-noprelude
Problem: base-noprelude is a non-standard dependency, unlike `base`.
Due to our use of `mixins` we don't need `base-noprelude` anymore,
we can just hide `Prelude`.

Solution: use `base` and hide `Prelude`.
2020-05-19 21:07:05 +03:00
Ivan Gromakovskii
c87b37e724
Drop autoexporter usage
Problem: `autoexporter` is used in one place to re-export one module.
Probably one day it will re-export more, but at this point it's really
overkill.
Moreover, it causes Hackage build to fail for the reasons mentioned
here:
https://github.com/haskell/hackage-server/issues/821

Solution: stop using it, re-export manually.
2020-05-19 20:57:31 +03:00
martoon
eb98aa70e4
Mention 'Path_* module in package.yaml`
Problem: after we started using mixins feature, generated .cabal file
requires cabal 2.0. Attempt to upload our package to Hackage now reports
an error, saying that `autogen-modules` section have to mention `Path_*`
files.

Solution: add `Paths_xrefcheck` to `generated-other-modules` section of
`package.yaml`.
2020-05-16 16:11:04 +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
553c41c385
Avoid loot-prelude dependency
Problem: lootbox is not uploaded to hackage, so when we upload
xrefcheck, its build on hackage fails.

Solution: we can use `mixins` feature to set Universum as prelude
without any intermediate packages.

This seems to be supported even by quite old versions of stack, like
1.7.3, so that should not bring build problems in most cases.
2020-05-15 19:26:09 +03:00
martoon
8e85855eb7
Bump version to 0.1.1 2020-04-28 19:25:28 +03:00
martoon
be9d750624
Use UTF-8 encoding for stdin/stdout
Problem: we use many unusual unicode characters, on some locales this
may cause failures on attempt to print to stdout.

Solution: it is generally a good practice to set encoding of all
handlers to UTF-8, and this commit brings `with-utf8` package which does
that.
2020-03-25 16:37:43 +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
martoon
fd949bc3c8
Rename the project to xrefcheck
Problem: the previous name `crossref-verifier` was found long and
boring.

Solution: rename to `xrefcheck`.
2020-01-14 12:17:01 +03:00
Ivan Gromakovskii
8060c7187b
[INT-128] Make the repository REUSE compliant
Problem: nowadays we want all files to store licensing information in
machine-readable format and to use reuse tool to check that. But the
repo is not REUSE compliant.

Solution: add `LICENSES` folder and licensing information for each
file.
2019-12-19 16:19:27 +03:00
Ivan Gromakovskii
4592392f02
Update licensing information in package.yaml
Problem: it was agreed with Kostya Ivanov that the copyright owner
is Serokell, so it should be updated in package.yaml.
Also it mentions incorrect license (the one in the repo is MPL-2.0)
and does not have license-file.

Solution: update `copyright` field and `license` field. Also add
`license-file`. Update maintainer as well, because now many people
from Serokell are involved.
I also took the liberty to fix the `github` field.
2019-12-19 16:19:25 +03:00
Alexander Bantyev
198725b792
Add hspec-discover to build-tools of test 2019-12-05 00:00:36 +03:00
Ivan Gromakovskii
2ebbbc1d63
Use newer resolver
Problem: latest available LTS resolver is 14.16 and `crossref-verifier`
doesn't compile with it.

Solution: update resolver to 14.16. Newer versions of some packages
are used from now on. I assume that it shouldn't break anything as
long as tests pass.
`req` stopped using `Default` class, that's the only change in the code
I had to make.
2019-12-05 00:00:34 +03:00
martoon
0671986bcb
Make providing config optional
Problem: currently `crossref-verify` executable does not work without
configuration, and user was supposed to use one from the repository if
he does not have its own. This is very inconvenient.

Solution: make executable remember some config and use it by default.
2019-12-03 23:19:37 +03:00
martoon
90e160e7d2
Allow to specify virtual files
For instance, reference to `issues` github page is a valid one despite there is no such
file physically in the repository.

Now user can specify list of "existing" virtual files in config.
2019-03-13 15:29:33 +03:00
martoon
444fa7349f
Add verification progress bar 2019-03-12 16:40:10 +03:00
martoon
2f4101c361
Add tests on header to anchor conversion 2019-03-11 17:16:06 +03:00
martoon
dc14c19e45
[INT-31] Enable external references checker 2018-10-16 14:58:53 +03:00
martoon
56b4e38308
[INT-31] Add config and CLI options 2018-10-11 17:27:59 +03:00
martoon
d1ee907cfb
[INT-31] Prettify output 2018-10-11 15:40:39 +03:00