死代码和/或如何从Haskell源生成交叉引用 [英] Dead code and/or how to generate a cross reference from Haskell source

查看:108
本文介绍了死代码和/或如何从Haskell源生成交叉引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码库中有一些未使用的功能,但很难识别。随着我探索其问题空间和可能的解决方案,代码在去年得到了发展。我需要做的是找到未使用的代码,以便我可以摆脱它。如果它以可出口的名称为基础处理问题,我很高兴.GHC具有处理非导出未使用代码的警告。任何特定于此任务的工具都会引起您的兴趣。

然而,我对一个全面的交叉引用工具感到好奇。我可以用这样的工具找到未使用的代码。几年前,当我在C和汇编工作时,我发现一个很好的外部参照是一个非常方便的工具,可用于许多不同的目的。



谷歌搜索。显然,在Haskell中,交叉引用的主要含义在文学编程中。虽然也许有些东西会有用。

解决方案

我不知道这样的工具,所以在过去我已经完成如果你有一个全面的测试套件,你可以使用GHC的 /ghc/docs/7.6.2/html/users_guide/hpc.htmlrel =noreferrer>代码覆盖范围已启用跟踪。使用 -fhpc 进行编译,然后使用 hpc标记生成带注释的源代码。这给了你未使用的代码和未经测试的代码的联合,这两者你都可能想要解决。



SourceGraph 可以为您提供大量信息,您可能也会觉得有用。


I've got some unused functionality in my codebase, but it's hard to identify. The code has evolved over the last year as I explore its problem space and possible solutions. What I'm needing to do is find that unused code so I can get rid of it. I'm happy if it deals with the problem on an exportable name basis.GHC has warnings that deal with non-exported unused code. Any tools specific to this task would be of interest.

However, I'm curious about a comprehensive cross referencing tool. I can find the unused code with such a tool. Years ago when I was working in C and assembler, I found that a good xref was a pretty handy tool, useful for many different purposes.

I'm getting nowhere with googling. Apparently in Haskell the dominant meaning of cross-reference is within literate programming. Though maybe something there would be useful.

解决方案

I don’t know of such a tool, so in the past I have done a bit of a hack instead.

If you have a comprehensive test suite, you can run it with GHC’s code coverage tracing enabled. Compile with -fhpc and use hpc markup to generate annotated source. This gives you the union of unused code and untested code, both of which you would probably like to address anyway.

SourceGraph can give you a bunch of information which you may also find useful.

这篇关于死代码和/或如何从Haskell源生成交叉引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆