【问题标题】:Detect the impact of changes in an application检测应用程序更改的影响
【发布时间】:2013-02-01 19:58:01
【问题描述】:

我有一项任务,其中包括创建一种方法来检测应用程序更改的影响。谁能帮我一些指示?我不知道从哪里开始,需要有人让我走上正轨。

【问题讨论】:

  • 考虑“diff”或“SmartDifferencer”。

标签: code-metrics


【解决方案1】:

对于 .NET 平台,您可以使用工具 NDepend 来检测 .NET 应用程序更改的影响(免责声明:我是该工具的主要开发人员)。

NDepend 提供了编写 C# LINQ 查询来查询您的代码库的工具,还可以查询您的代码库的 2 个不同版本之间的差异。提供了200 default LINQ queries左右(代码规则),很容易自己写。

例如下面的默认代码规则,列出两个版本之间变得更复杂的方法:

// <Name>Avoid making complex methods even more complex (Source CC)</Name>
// To visualize changes in code, right-click a matched method and select:
//  - Compare older and newer versions of source file
//  - Compare older and newer versions disassembled with Reflector

warnif count > 0 
from m in JustMyCode.Methods where
 !m.IsAbstract &&
  m.IsPresentInBothBuilds() &&
  m.CodeWasChanged()

let oldCC = m.OlderVersion().CyclomaticComplexity
where oldCC > 6 && m.CyclomaticComplexity > oldCC 

select new { m,
    oldCC ,
    newCC = m.CyclomaticComplexity ,
    oldLoc = m.OlderVersion().NbLinesOfCode,
    newLoc = m.NbLinesOfCode,
}

结果可以在 Visual Studio 或 HTML+js 报告中实时显示:

在规则组代码质量回归代码差异摘要中,许多其他默认代码规则将帮助您列出差异/更改对代码质量、代码结构的影响和代码可维护性。 A 14 days full featured trial is available for download.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-22
    • 2014-05-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多