public async Task<ITypeMetric> CalculateFrom(TypeDeclarationSyntaxInfo typeNode, IEnumerable<IMemberMetric> metrics)
{
var memberMetrics = metrics.AsArray();
var type = typeNode.Syntax;
var symbol = Model.GetDeclaredSymbol(type);
var documentation = await _documentationFactory.Create(symbol, CancellationToken.None);
var metricKind = GetMetricKind(type);
var source = CalculateClassCoupling(type, memberMetrics);
var depthOfInheritance = CalculateDepthOfInheritance(type);
var cyclomaticComplexity = memberMetrics.Sum(x => x.CyclomaticComplexity);
var linesOfCode = memberMetrics.Sum(x => x.LinesOfCode);
var maintainabilityIndex = CalculateAveMaintainabilityIndex(memberMetrics);
var afferentCoupling = await CalculateAfferentCoupling(type);
var efferentCoupling = GetEfferentCoupling(type, symbol);
var instability = (double)efferentCoupling / (efferentCoupling + afferentCoupling);
var modifier = GetAccessModifier(type.Modifiers);
return new TypeMetric(
symbol.IsAbstract,
metricKind,
modifier,
memberMetrics,
linesOfCode,
cyclomaticComplexity,
maintainabilityIndex,
depthOfInheritance,
source,
type.GetName(),
afferentCoupling,
efferentCoupling,
instability,
documentation);
}