mirror of
https://github.com/serokell/xrefcheck.git
synced 2024-09-11 13:37:36 +03:00
Merge pull request #128 from serokell/Sereja313/#126-make-ignoreRefs-required
[#126] Make `ignoreRefs` a required parameter
This commit is contained in:
commit
bf81311e43
@ -25,6 +25,8 @@ Unreleased
|
||||
+ Fix the issue of having the lowest level context duplicated, caused by the root's trailing path separator.
|
||||
* [#31](https://github.com/serokell/xrefcheck/pull/88)
|
||||
+ Handle the "429 too many requests" errors & attempt to eliminate them during verification.
|
||||
* [#128](https://github.com/serokell/xrefcheck/pull/128)
|
||||
+ Make `ignoreRefs` a required parameter.
|
||||
|
||||
0.2.1
|
||||
==========
|
||||
|
@ -84,7 +84,7 @@ xrefcheck --help
|
||||
|
||||
If you want some external links to not be verified, you can use one of the following ways to ignore those links:
|
||||
|
||||
1. Add the regular expression that matches the ignoring link to the optional `ignoreRefs` parameter of your config file.
|
||||
1. Add the regular expression that matches the ignoring link to the `ignoreRefs` parameter of your config file.
|
||||
|
||||
For example:
|
||||
```yaml
|
||||
|
@ -55,7 +55,7 @@ data VerifyConfig = VerifyConfig
|
||||
-- ^ Files which we pretend do exist.
|
||||
, vcNotScanned :: [FilePath]
|
||||
-- ^ Prefixes of files, references in which we should not analyze.
|
||||
, vcIgnoreRefs :: Maybe [Regex]
|
||||
, vcIgnoreRefs :: [Regex]
|
||||
-- ^ Regular expressions that match external references we should not verify.
|
||||
, vcCheckLocalhost :: Bool
|
||||
-- ^ If True - we will check localhost links.
|
||||
|
@ -45,7 +45,6 @@ verification:
|
||||
|
||||
# POSIX extended regular expressions that match external references
|
||||
# that have to be ignored (not verified).
|
||||
# It is an optional parameter, so it can be omitted.
|
||||
ignoreRefs: []
|
||||
|
||||
# Check localhost links.
|
||||
|
@ -434,7 +434,7 @@ checkExternalResource VerifyConfig{..} link
|
||||
where
|
||||
skipCheck = isIgnored || (not vcCheckLocalhost && isLocalLink)
|
||||
where
|
||||
isIgnored = maybe False (doesMatchAnyRegex link) vcIgnoreRefs
|
||||
isIgnored = doesMatchAnyRegex link vcIgnoreRefs
|
||||
isLocalLink = any (`T.isInfixOf` link) ["://localhost", "://127.0.0.1"]
|
||||
|
||||
doesMatchAnyRegex :: Text -> ([Regex] -> Bool)
|
||||
|
@ -77,11 +77,10 @@ spec = do
|
||||
Just neWithRefLoc -> map (rLink . wrlReference) $ toList neWithRefLoc
|
||||
Nothing -> []
|
||||
|
||||
linksToRegexs :: [Text] -> Maybe [Regex]
|
||||
linksToRegexs :: [Text] -> [Regex]
|
||||
linksToRegexs links =
|
||||
let errOrRegexs = map (decodeEither' . encodeUtf8) links
|
||||
maybeRegexs = map (either (error . show) Just) errOrRegexs
|
||||
in sequence maybeRegexs
|
||||
in map (either (error . show) id) errOrRegexs
|
||||
|
||||
setIgnoreRefs :: Maybe [Regex] -> Config -> Config
|
||||
setIgnoreRefs :: [Regex] -> Config -> Config
|
||||
setIgnoreRefs regexs = (cVerificationL . vcIgnoreRefsL) .~ regexs
|
||||
|
@ -36,7 +36,6 @@ verification:
|
||||
|
||||
# POSIX extended regular expressions that match external references
|
||||
# that have to be ignored (not verified).
|
||||
# It is an optional parameter, so it can be omitted.
|
||||
ignoreRefs: []
|
||||
|
||||
# Check localhost links.
|
||||
|
Loading…
Reference in New Issue
Block a user