code-metrics

What can be alternative metrics to code coverage?

我的未来我决定 提交于 2019-12-02 15:18:11
Code coverage is propably the most controversial code metric. Some say, you have to reach 80% code coverage, other say, it's superficial and does not say anything about your testing quality. (See Jon Limjap's good answer on "What is a reasonable code coverage % for unit tests (and why)?" .) People tend to measure everything. They need comparisons, benchmarks etc. Project teams need a pointer, how good their testing is. So what are alternatives to code coverage? What would be a good metric that says more than "I touched this line of code"? Are there real alternatives? If you are looking for

Code Metrics Calculation in Visual Studio

主宰稳场 提交于 2019-12-02 14:52:10
What is the prefered score range for the code metrics calculation for the following Maintainability Index Cyclomatic Complexity Depth of Inheritance class Coupling The theoretically optimal values are: Maintainability index: 100. Higher values indicate better maintainability. Cyclomatic complexity: 1. The number of different paths that code can take. Depth of inheritance: 1. The number of class definitions above this one in the inheritance tree, not including interfaces. Class coupling: 0. Number of other entities this entity is dependent on. There are no hard and fast "good" ranges, though it

Clarifying the manual count of Cyclomatic Complexity

痴心易碎 提交于 2019-12-02 00:29:29
Let's assume that we have a code like this: switch(y) { case 1: case 2: case 3: function(); break; case 4: case 5: case 6: function_2(); break; } Can we get the CC value as 6+1 here? Why a value of 1 is added? If the CC value is considered as 7, is that the number of independent paths? What if a fall through scenario is considered above? As only possible two unique paths are there, 2 +1 =3 Which of the above are correct or are the both of them correct? As we know, CC = P+1. Here, P = number of predicate nodes (conditions) = 2 Number of conditions will be 2 because: Case branch can cover

How do I show how many lines of code my project contains in Visual Studio? [duplicate]

北战南征 提交于 2019-11-29 18:57:51
Possible Duplicate: How do you count the lines of code in a Visual Studio solution? How can I show the code metrics window in Visual Studio 2008 Professional SP1? I'm looking to see how many total lines of code my project is for school and I can't find it. The help file said to go to View->Other Windows->Code Metrics, but this option is not available to me. I also tried right-clicking the project in the Solution Explorer to see if there was an option but there wasn't. Where is this mythical unicorn of a feature? If the Pro version doesn't have this feature has anyone found a simple external

Do you find cyclomatic complexity a useful measure?

我的梦境 提交于 2019-11-28 16:38:38
I've been playing around with measuring the cyclomatic complexity of a big code base. Cyclomatic complexity is the number of linearly independent paths through a program's source code and there are lots of free tools for your language of choice. The results are interesting but not surprising. That is, the parts I know to be the hairiest were in fact the most complex (with a rating of > 50). But what I am finding useful is that a concrete "badness" number is assigned to each method as something I can point to when deciding where to start refactoring. Do you use cyclomatic complexity? What's the

How do I show how many lines of code my project contains in Visual Studio? [duplicate]

柔情痞子 提交于 2019-11-28 14:13:03
问题 Possible Duplicate: How do you count the lines of code in a Visual Studio solution? How can I show the code metrics window in Visual Studio 2008 Professional SP1? I'm looking to see how many total lines of code my project is for school and I can't find it. The help file said to go to View->Other Windows->Code Metrics, but this option is not available to me. I also tried right-clicking the project in the Solution Explorer to see if there was an option but there wasn't. Where is this mythical

TFS 2010/Code Metrics Integration, Automated Builds Fail, Code Metrics Don't Run

故事扮演 提交于 2019-11-28 08:38:12
问题 I'm trying to add an automatic post-build trigger to run NDepend (code metrics software) after an automated team build in TFS 2010. NDepend's website provided code for integrating this capability, and so I have pasted their code into my .csproj file where they said for it to go, but I receive errors on the build. The errors refer to two of the three "BuildStep" tags I have in the code snippet. The following two snippets are giving me errors: <BuildStep TeamFoundationServerUrl="$

How many lines of code should a function/procedure/method have? [duplicate]

孤街浪徒 提交于 2019-11-27 17:30:33
Possible Duplicate: When is a function too long? I've recently been given the unenviable task of reviewing poor code written by another developer and documenting the bad practices. (This is all for the purposes of getting out of paying for the developer's work rather than any altruistic reason, of course!) The reviewed code has several procedures that are many lines of code - the longest is almost 600 lines. A couple of problems with this that I've thought of are maintainability and readability. The trick is that I need to justify to a layperson why this is a bad practice and if possible back

Free C# metrics calculation library (DLL) [closed]

送分小仙女□ 提交于 2019-11-27 12:27:35
问题 I wanted to ask whether you know about some free C# libraries (dlls) that calculate CK metrics (mainly Cyclomatic Complexity). I would need that for a project I'm planning to do. I know that there are already some finished solutions that calculate CK metrics and display it to you in various forms, but what I would need is one that I could use from within my application. So before starting and writing one myself I first wanted to ask you. Thanks 回答1: DrivenMetrics is a open source C# command

Do you find cyclomatic complexity a useful measure?

大兔子大兔子 提交于 2019-11-27 09:50:57
问题 I've been playing around with measuring the cyclomatic complexity of a big code base. Cyclomatic complexity is the number of linearly independent paths through a program's source code and there are lots of free tools for your language of choice. The results are interesting but not surprising. That is, the parts I know to be the hairiest were in fact the most complex (with a rating of > 50). But what I am finding useful is that a concrete "badness" number is assigned to each method as