Exemplo n.º 1
0
        public void FinalizeSelf(MetricsAccumulationNode node)
        {
            int assignmentCount;
            int branchCount;
            int callCount;

            node.TryGetDataItem <int>(AssignmentCount, out assignmentCount);
            node.TryGetDataItem <int>(BranchingCount, out branchCount);
            node.TryGetDataItem <int>(CallCount, out callCount);
            var ABCScore = Math.Sqrt(Math.Pow(assignmentCount, 2) + Math.Pow(branchCount, 2) + Math.Pow(callCount, 2));

            node.SetDataItem <double>(ABCScoreAccumulator, ABCScore);

            if (node.children.Count > 0)
            {
                var ABCWithChildren = ABCScore;
                foreach (MetricsAccumulationNode child in node.children)
                {
                    double ABCScoreForChildren = 0;
                    if (child.TryGetDataItem <double>(ABCScoreWithChildrenAccumulator, out ABCScoreForChildren) ||
                        child.TryGetDataItem <double>(ABCScoreAccumulator, out ABCScoreForChildren))
                    {
                        ABCWithChildren += ABCScoreForChildren;
                    }
                }
                node.SetDataItem <double>(ABCScoreWithChildrenAccumulator, ABCWithChildren);
            }
        }
Exemplo n.º 2
0
        public override void Visit(MetricsAccumulationNode node)
        {
            depth++;
            SyntaxKind nodeKind = node.nodeReference.Kind();

            double abcCount, totalAbcCount;
            int    assignments, branches, calls;

            node.TryGetDataItem(ABCStrategy.ABCScoreAccumulator, out abcCount);
            node.TryGetDataItem(ABCStrategy.AssignmentCount, out assignments);
            node.TryGetDataItem(ABCStrategy.BranchingCount, out branches);
            node.TryGetDataItem(ABCStrategy.CallCount, out calls);

            node.TryGetDataItem <double>(ABCStrategy.ABCScoreWithChildrenAccumulator, out totalAbcCount);

            formatter.AddItem(depth, node.Name, abcCount, totalAbcCount, assignments, branches, calls);

            base.Visit(node);
            depth--;
        }
        public override void Visit(MetricsAccumulationNode node)
        {
            depth++;
            SyntaxKind nodeKind = node.nodeReference.Kind();

            int loc, tLoc, complexity, tComplexity;

            node.TryGetDataItem <int>(LinesOfCodeStrategy.LinesOfCodeData, out loc);

            node.TryGetDataItem <int>(LinesOfCodeStrategy.TotalLinesOfCodeData, out tLoc);

            node.TryGetDataItem <int>(CyclomaticComplexityStrategy.CyclomaticComplexityeData, out complexity);

            node.TryGetDataItem <int>(CyclomaticComplexityStrategy.TotalCyclomaticComplexityData, out tComplexity);

            formatter.AddItem(depth, node.Name, loc, tLoc, complexity, tComplexity);

            base.Visit(node);
            depth--;
        }
Exemplo n.º 4
0
        public void FinalizeSelf(MetricsAccumulationNode node)
        {
            int totalComplexity;

            node.TryGetDataItem <int>(CyclomaticComplexityeData, out totalComplexity);
            foreach (MetricsAccumulationNode child in node.children)
            {
                int childComplexity = 0;
                if (child.TryGetDataItem <int>(TotalCyclomaticComplexityData, out childComplexity) ||
                    child.TryGetDataItem <int>(CyclomaticComplexityeData, out childComplexity))
                {
                    totalComplexity += childComplexity;
                }
            }
            node.SetDataItem <int>(TotalCyclomaticComplexityData, totalComplexity);
        }
        public void FinalizeSelf(MetricsAccumulationNode node)
        {
            int totalLinesOfCode = 0;

            node.TryGetDataItem <int>(LinesOfCodeData, out totalLinesOfCode);
            foreach (MetricsAccumulationNode child in node.children)
            {
                int childLinesOfCode = 0;
                if (child.TryGetDataItem <int>(TotalLinesOfCodeData, out childLinesOfCode) ||
                    child.TryGetDataItem <int>(LinesOfCodeData, out childLinesOfCode))
                {
                    totalLinesOfCode += childLinesOfCode;
                }
                continue;
            }
            node.SetDataItem <int>(TotalLinesOfCodeData, totalLinesOfCode);
        }