问HN:你们是如何区分有意的测试模板与真正的重复代码的?

7作者: rafaepta3 天前原帖
我正在维护一个开源项目(确定性开源重复代码检测器),有用户请求一个我不太清楚如何实现的功能。 这似乎是一个很难解决的问题: - 测试重复相同的场景。对于结构性检测器来说,这被标记为重复(重复代码)。然而,测试并不是人们希望从代码库中删除的内容。 - 测试中的重复(故意的)最终看起来像是不必要的代码重复,而工具无法区分哪一个是哪个。 - 解决这个问题的一种方法可能是引入“人类在环”的机制(类似于代码检查工具允许用户在第一次运行时接受某些内容,同时保持默认的零配置)。 我想知道你们是如何处理这个问题的,以及是否有人有任何想法。 这是项目的仓库链接:https://github.com/Rafaelpta/dupehound 这是更详细的问题链接:https://github.com/Rafaelpta/dupehound/issues/23
查看原文
I am maintaining an open-source project (deterministic open source duplicate-code detector) and a user asked for a feature which I don’t have a clear answer on how to implement.<p>This seems a very hard problem to solve:<p>-Tests repeat the same scenario. For a structural detector, this flags as repetition (duplication). However, tests are not something people want to delete from the codebases.<p>-The repetitions from tests (on purpose) end up looking like undesired code duplication and the tools canno tell which is which.<p>-One way to solve this would be something like a human in the loop (kind of how linters allow user to accept something once, while keeping the default first run zero-config).<p>Wonder how you have seen this handle and if anyone have any ideas.<p>Here is the the repo: https:&#x2F;&#x2F;github.com&#x2F;Rafaelpta&#x2F;dupehound<p>And here is the issue with more detail: https:&#x2F;&#x2F;github.com&#x2F;Rafaelpta&#x2F;dupehound&#x2F;issues&#x2F;23