Skip to content

Commit

Permalink
[#156] Trim redundant config fields from test configs
Browse files Browse the repository at this point in the history
Problem: In #159 we made all config fields optional. Now we can trim
redundant fields from test configs.

Solution: Trim redundant config fields. Also slightly refactor
`overrideVerify` function to make it more readable.
  • Loading branch information
Sereja313 committed Sep 25, 2022
1 parent 31777f7 commit 24ea5a9
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 142 deletions.
27 changes: 11 additions & 16 deletions src/Xrefcheck/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -225,23 +225,18 @@ overrideConfig config

overrideVerify verifyConfig
= VerifyConfig
{ vcAnchorSimilarityThreshold = fromMaybe (vcAnchorSimilarityThreshold defVerification)
$ vcAnchorSimilarityThreshold verifyConfig
, vcExternalRefCheckTimeout = fromMaybe (vcExternalRefCheckTimeout defVerification)
$ vcExternalRefCheckTimeout verifyConfig
, vcVirtualFiles = fromMaybe (vcVirtualFiles defVerification)
$ vcVirtualFiles verifyConfig
, vcNotScanned = fromMaybe (vcNotScanned defVerification)
$ vcNotScanned verifyConfig
, vcIgnoreRefs = fromMaybe (vcIgnoreRefs defVerification)
$ vcIgnoreRefs verifyConfig
, vcIgnoreAuthFailures = fromMaybe (vcIgnoreAuthFailures defVerification)
$ vcIgnoreAuthFailures verifyConfig
, vcDefaultRetryAfter = fromMaybe (vcDefaultRetryAfter defVerification)
$ vcDefaultRetryAfter verifyConfig
, vcMaxRetries = fromMaybe (vcMaxRetries defVerification)
$ vcMaxRetries verifyConfig
{ vcAnchorSimilarityThreshold = overrideField vcAnchorSimilarityThreshold
, vcExternalRefCheckTimeout = overrideField vcExternalRefCheckTimeout
, vcVirtualFiles = overrideField vcVirtualFiles
, vcNotScanned = overrideField vcNotScanned
, vcIgnoreRefs = overrideField vcIgnoreRefs
, vcIgnoreAuthFailures = overrideField vcIgnoreAuthFailures
, vcDefaultRetryAfter = overrideField vcDefaultRetryAfter
, vcMaxRetries = overrideField vcMaxRetries
}
where
overrideField :: (forall f. VerifyConfig' f -> Field f a) -> a
overrideField field = fromMaybe (field defVerification) $ field verifyConfig

-----------------------------------------------------------
-- Yaml instances
Expand Down
14 changes: 0 additions & 14 deletions tests/golden/check-cli/config-no-scan-ignored.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,5 @@
#
# SPDX-License-Identifier: Unlicense

traversal:
ignored: []

verification:
anchorSimilarityThreshold: 0.5
externalRefCheckTimeout: 10s
notScanned: [ "to-ignore/broken-link.md" ]
virtualFiles: []
ignoreRefs: []
ignoreAuthFailures: true
defaultRetryAfter: 30s
maxRetries: 3

scanners:
markdown:
flavor: GitHub
14 changes: 0 additions & 14 deletions tests/golden/check-ignoreRefs/config-check-disabled.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,6 @@
#
# SPDX-License-Identifier: Unlicense

traversal:
ignored: []

verification:
anchorSimilarityThreshold: 0.5
externalRefCheckTimeout: 10s
notScanned: []
virtualFiles: []
ignoreRefs:
- ^(https?|ftps?)://(localhost|127\.0\.0\.1).*
ignoreAuthFailures: true
defaultRetryAfter: 30s
maxRetries: 3

scanners:
markdown:
flavor: GitHub
14 changes: 0 additions & 14 deletions tests/golden/check-ignoreRefs/config-check-enabled.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,5 @@
#
# SPDX-License-Identifier: Unlicense

traversal:
ignored: []

verification:
anchorSimilarityThreshold: 0.5
externalRefCheckTimeout: 10s
notScanned: []
virtualFiles: []
ignoreRefs: []
ignoreAuthFailures: true
defaultRetryAfter: 30s
maxRetries: 3

scanners:
markdown:
flavor: GitHub
14 changes: 0 additions & 14 deletions tests/golden/check-ignored/config-ignored.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,3 @@
traversal:
ignored:
- ./to-ignore/inner-directory/broken_annotation.md

verification:
anchorSimilarityThreshold: 0.5
externalRefCheckTimeout: 10s
notScanned: []
virtualFiles: []
ignoreRefs: []
ignoreAuthFailures: true
defaultRetryAfter: 30s
maxRetries: 3

scanners:
markdown:
flavor: GitHub
14 changes: 0 additions & 14 deletions tests/golden/check-notScanned/config-directory.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,6 @@
#
# SPDX-License-Identifier: Unlicense

traversal:
ignored: []

verification:
anchorSimilarityThreshold: 0.5
externalRefCheckTimeout: 10s
notScanned:
- notScanned/inner-directory
virtualFiles: []
ignoreRefs: []
ignoreAuthFailures: true
defaultRetryAfter: 30s
maxRetries: 3

scanners:
markdown:
flavor: GitHub
14 changes: 0 additions & 14 deletions tests/golden/check-notScanned/config-full-path.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,6 @@
#
# SPDX-License-Identifier: Unlicense

traversal:
ignored: []

verification:
anchorSimilarityThreshold: 0.5
externalRefCheckTimeout: 10s
notScanned:
- ./notScanned/inner-directory/bad-reference.md
virtualFiles: []
ignoreRefs: []
ignoreAuthFailures: true
defaultRetryAfter: 30s
maxRetries: 3

scanners:
markdown:
flavor: GitHub
14 changes: 0 additions & 14 deletions tests/golden/check-notScanned/config-nested-directories.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,6 @@
#
# SPDX-License-Identifier: Unlicense

traversal:
ignored: []

verification:
anchorSimilarityThreshold: 0.5
externalRefCheckTimeout: 10s
notScanned:
- ./**/*
virtualFiles: []
ignoreRefs: []
ignoreAuthFailures: true
defaultRetryAfter: 30s
maxRetries: 3

scanners:
markdown:
flavor: GitHub
14 changes: 0 additions & 14 deletions tests/golden/check-notScanned/config-wildcard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,6 @@
#
# SPDX-License-Identifier: Unlicense

traversal:
ignored: []

verification:
anchorSimilarityThreshold: 0.5
externalRefCheckTimeout: 10s
notScanned:
- ./notScanned/inner-directory/*
virtualFiles: []
ignoreRefs: []
ignoreAuthFailures: true
defaultRetryAfter: 30s
maxRetries: 3

scanners:
markdown:
flavor: GitHub
14 changes: 0 additions & 14 deletions tests/golden/check-virtualFiles/config-virtualFiles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,8 @@
#
# SPDX-License-Identifier: Unlicense

traversal:
ignored: []

verification:
anchorSimilarityThreshold: 0.5
externalRefCheckTimeout: 10s
notScanned: []
virtualFiles:
- ./one/a.md
- ./two/*
- ./three/**/*
ignoreRefs: []
ignoreAuthFailures: true
defaultRetryAfter: 30s
maxRetries: 3

scanners:
markdown:
flavor: GitHub

0 comments on commit 24ea5a9

Please sign in to comment.