From 2e0d0f6a315da1e21ad6d4a18d6d23c3e6fef6a6 Mon Sep 17 00:00:00 2001 From: Yuri Romanowski Date: Fri, 23 Dec 2022 16:20:05 +0500 Subject: [PATCH] fixup! [#64] Implement copy/paste protection checks Review: fix config, README, CHANGES --- CHANGES.md | 2 ++ README.md | 11 +++++++++++ src/Xrefcheck/Config/Default.hs | 4 ++-- tests/configs/github-config.yaml | 4 ++-- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index a4d037eb..f1655df6 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -41,6 +41,8 @@ Unreleased * [#231](https://github.com/serokell/xrefcheck/pull/231) + Anchor analysis takes now into account the appropriate case-sensitivity depending on the configured Markdown flavour. +* [#245](https://github.com/serokell/xrefcheck/pull/245) + + Now xrefcheck is able to detect possible copy-pastes relying on links and their names. 0.2.2 ========== diff --git a/README.md b/README.md index 73d76c56..2d59128a 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ Comparing to alternative solutions, this tool tries to achieve the following poi * Supports relative and absolute local links. * Supports external links (`http`, `https`, `ftp` and `ftps`). * Detects broken and ambiguous anchors in local links. +* Detects possible bad copy-pastes of links. * Integration with GitHub Actions. ## Dependencies [↑](#xrefcheck) @@ -148,6 +149,16 @@ There are several ways to fix this: * By default, `xrefcheck` will ignore links to localhost. * This behavior can be disabled by removing the corresponding entry from the `ignoreExternalRefsTo` list in the config file. +1. How does the copy-paste check work? + * If there are some references with the same links and for one of them name is similar to the link itself, other links may turn out to be copypasted from that link. Example: + ```md + Links with bad copypaste: + [good link](https://good.link.uri/). + [copypasted link](https://good.link.uri/). + ``` + The second link will be reported by `xrefcheck` as a possible bad copy-paste of the first link. + * This checks both external references and local ones. + ## Further work [↑](#xrefcheck) - [ ] Support link detection in different languages, not only Markdown. diff --git a/src/Xrefcheck/Config/Default.hs b/src/Xrefcheck/Config/Default.hs index 8550b0bd..5378d9e2 100644 --- a/src/Xrefcheck/Config/Default.hs +++ b/src/Xrefcheck/Config/Default.hs @@ -68,8 +68,8 @@ scanners: # This affects which anchors are generated for headers. flavor: #s{flavor} - # Whether copy-paste check is enabled globally. - copyPasteCheckEnabled: True + # Whether the copy-paste check is enabled globally. + copyPasteCheckEnabled: true |] where ignoreLocalRefsFrom :: NonEmpty Text diff --git a/tests/configs/github-config.yaml b/tests/configs/github-config.yaml index c0698528..1722de1a 100644 --- a/tests/configs/github-config.yaml +++ b/tests/configs/github-config.yaml @@ -57,5 +57,5 @@ scanners: # This affects which anchors are generated for headers. flavor: GitHub - # Whether copy-paste check is enabled globally. - copyPasteCheckEnabled: True + # Whether the copy-paste check is enabled globally. + copyPasteCheckEnabled: true