Пример #1
0
 internal static MetricsReport Of(IEnumerable<MetricsReport> reports)
 {
     var combinedReport = new MetricsReport();
     foreach (var typeMetrics in reports.SelectMany(r => r.typeReports.Values))
         combinedReport.AddTypeReport(typeMetrics);
     return combinedReport;
 }
Пример #2
0
 protected void OutputAnalysisMetrics(string heading, MetricsReport metrics)
 {
     var prepared = new PreparedMetricsFactory().Prepare(metrics);
     Console.WriteLine(string.Format("{0} ({1} RLOC):\tACD: {2};\tCS: {3};\tCC: {4};\tML: {5};\tPF: {6};\tCN: {7};",
                                     heading,
                                     prepared.CommonKnowledge.RelevantLinesOfCode,
                                     prepared.Rated.AverageComponentDependency,
                                     prepared.Rated.AverageRatedClassSize,
                                     prepared.Rated.AverageRatedCyclomaticComplexity,
                                     prepared.Rated.AverageRatedMethodLength,
                                     prepared.Rated.AverageRatedNumberOfNonStaticPublicFields,
                                     prepared.Rated.NamespacesWithCyclicDependencies));
     Console.WriteLine(string.Format("Hotspots:\tACD: {0};\tCS: {1};\tCC: {2};\tML: {3};\tPF: {4};\tCN: {5};",
                                     prepared.CumulativeComponentDependencyHotspots.Count(),
                                     prepared.ClassSizeHotspots.Count(),
                                     prepared.CyclomaticComplexityHotspots.Count(),
                                     prepared.MethodLengthHotspots.Count(),
                                     prepared.NumberOfNonStaticPublicFieldsHotspots.Count(),
                                     prepared.NumberOfNamespacesInCycleHotspots.Count()));
     Console.WriteLine(string.Format("Distributions:\tACD: {0};\tCS: {1};\tCC: {2};\tML: {3};\tPF: {4};\tCN: {5};",
                                     prepared.CumulativeComponentDependencyHistogram.GeometricalFit.Parameter,
                                     prepared.ClassSizeHistogram.GeometricalFit.Parameter,
                                     prepared.CyclomaticComplexityHistogram.GeometricalFit.Parameter,
                                     prepared.MethodLengthHistogram.GeometricalFit.Parameter,
                                     prepared.NumberOfNonStaticPublicFieldsHistogram.GeometricalFit.Parameter,
                                     prepared.NumberOfNamespacesInCycleHistogram.GeometricalFit.Parameter));
 }
Пример #3
0
 public IEnumerable<MethodMetricsReport> ComparedTo(MetricsReport metrics)
 {
     if (metrics != null)
         return AllChangedMethods(metrics);
     else
         return Enumerable.Empty<MethodMetricsReport>();
 }
Пример #4
0
 private static void AddTypesOf(MetricsReport[] reports, MetricsReport combinedReport)
 {
     foreach (var typeMetrics in reports.SelectMany(r => r.typeReports.Values))
     {
         combinedReport.AddTypeReport(typeMetrics);
     }
 }
Пример #5
0
 public static MutableGraph<NamespaceMetricsWithTypeMetrics> WithNamespacesOf(MetricsReport metrics)
 {
     var namespaceGraph = metrics.GraphOfTypes.Cast(t => t.AsNamespaceWithTypes(), n => n.HasName);
     foreach (var namespaceGroup in namespaceGraph.Vertices.GroupBy(n => n.Namespace.Name))
         namespaceGraph.Reduce(namespaceGroup.AsNamespaceWithTypes(), namespaceGroup);
     return namespaceGraph;
 }
 public static PropertyMetricsReport ForProperty(this MetricsReport metrics, PropertyInfo property)
 {
     return(new PropertyMetricsReport
     {
         Getter = metrics.ForMethod(property.GetFullGetterName()),
         Setter = metrics.ForMethod(property.GetFullSetterName())
     });
 }
Пример #7
0
 internal static MetricsReport Of(params MetricsReport[] reports)
 {
     var combinedReport = new MetricsReport();
     combinedReport.Remember.WhenCreated = reports.FirstCreated();
     AddTypesOf(reports, combinedReport);
     combinedReport.CommonKnowledge.SetAssemblies(reports.Length);
     return combinedReport;
 }
Пример #8
0
 private IEnumerable<MethodMetricsReport> AllChangedMethods(MetricsReport metrics)
 {
     return from m1 in _metrics.Methods
            join m2 in metrics.Methods
                on m1.Signature equals m2.Signature
            where !m1.CompilerGenerated
            where MethodsDiffer(m1, m2)
            select m1;
 }
Пример #9
0
        internal static MetricsReport Of(params MetricsReport[] reports)
        {
            var combinedReport = new MetricsReport();

            combinedReport.Remember.WhenCreated = reports.FirstCreated();
            AddTypesOf(reports, combinedReport);
            combinedReport.CommonKnowledge.SetAssemblies(reports.Length);
            return(combinedReport);
        }
Пример #10
0
 private void InitializeStatistics(MetricsReport metrics)
 {
     AverageRatedCyclomaticComplexity = RatedMethods.AverageAny(m => m.RatedCyclomaticComplexity, m => m.CyclomaticComplexity > 0);
     AverageRatedMethodLength = RatedMethods.AverageAny(m => m.RatedMethodLength, m => m.MethodLength > 0);
     AverageRatedClassSize = RatedTypes.AverageAny(m => m.RatedClassSize);
     AverageRatedNumberOfNonStaticPublicFields = RatedTypes.AverageAny(m => m.RatedNumberOfNonStaticPublicFields);
     AverageComponentDependency = RatedTypes.AverageAny(m => m.CumulativeComponentDependency) / metrics.CommonKnowledge.NumberOfClasses;
     NamespacesWithCyclicDependencies = (double)RatedNamespaces.CountAny(m => m.IsInCycle) / metrics.CommonKnowledge.NumberOfNamespaces;
 }
Пример #11
0
 private IEnumerable <MethodMetricsReport> AllChangedMethods(MetricsReport metrics)
 {
     return(from m1 in _metrics.Methods
            join m2 in metrics.Methods
            on m1.Signature equals m2.Signature
            where !m1.CompilerGenerated
            where MethodsDiffer(m1, m2)
            select m1);
 }
Пример #12
0
 public IEnumerable <MethodMetricsReport> ComparedTo(MetricsReport metrics)
 {
     if (metrics != null)
     {
         return(AllChangedMethods(metrics));
     }
     else
     {
         return(Enumerable.Empty <MethodMetricsReport>());
     }
 }
Пример #13
0
 protected void OutputAnalysisTimes(string heading, MetricsReport metrics)
 {
     var times = new AnalyzeTimes(metrics);
     Console.WriteLine(string.Format("{0} ({1} RLOC, {2} assemblies):\t{3}s\t(analysis: {4}s\tpostprocessing: {5}s)",
                                     heading,
                                     metrics.CommonKnowledge.RelevantLinesOfCode,
                                     metrics.CommonKnowledge.NumberOfAssemblies,
                                     times.CompleteTime.TotalSeconds,
                                     times.AnalysisTime.TotalSeconds,
                                     times.PostProcessingTime.TotalSeconds));
 }
Пример #14
0
        private void OutputMetricsReport(MetricsReport metrics)
        {
            foreach (var namespaceMetrics in metrics.Namespaces)
                OutputNamespaceMetricsReport(namespaceMetrics);

            OutputSeperator(2);

            foreach (var type in metrics.Types.Where(t => !t.CompilerGenerated))
                OutputTypeMetricsReport(type);

            OutputSeperator(2);

            foreach (var method in metrics.Methods.Where(m => !m.CompilerGenerated && !m.OnlyDeclaration))
                OutputMethodMetricsReport(method);

            OutputSeperator(3);

            OutputRatings(metrics.Rate());
            OutputHotspots(metrics.Hotspots());
        }
Пример #15
0
 internal RatedMetrics(MetricsReport metrics)
 {
     Metrics = metrics;
     InitializeRatedLists(metrics);
     InitializeStatistics(metrics);
 }
Пример #16
0
 public PreparedMetricsReport(MetricsReport metrics)
 {
     Report = metrics;
     ThrowExceptionWhenNoMetrics();
     Prepare();
 }
Пример #17
0
 public void Rloc_NoMethodNoTypes_0Lines()
 {
     var emptyMetrics = new MetricsReport();
     Assert.AreEqual(0, emptyMetrics.CommonKnowledge.RelevantLinesOfCode);
 }
 public static TypeMetricsReport ForType(this MetricsReport metrics, string typeName)
 {
     return(metrics.TypeForName(typeName));
 }
Пример #19
0
 public static Changes Of(MetricsReport metrics)
 {
     return new Changes(metrics);
 }
 public static MethodMetricsReport ForMethod(this MetricsReport metrics, string memberName)
 {
     return((from m in metrics.Methods
             where m.Signature == memberName
             select m).FirstOrDefault());
 }
        public static MethodMetricsReport ForMethod(this MetricsReport metrics, Expression <Action> expression)
        {
            var methodName = (expression.Body as MethodCallExpression).GetCalleeName();

            return(metrics.ForMethod(methodName));
        }
Пример #22
0
 public TypeReference(MetricsReport metrics, TypeMetricsReport source, TypeMetricsReport target)
 {
     this.metrics = metrics;
     this.Source  = source;
     this.Target  = target;
 }
 public static TypeMetricsReport ForType <T>(this MetricsReport metrics)
 {
     return(metrics.ForType(typeof(T)));
 }
Пример #24
0
 public static Changes Of(MetricsReport metrics)
 {
     return(new Changes(metrics));
 }
 public static PropertyMetricsReport ForProperty(this MetricsReport metrics, Expression <Func <object> > expression)
 {
     return(metrics.ForProperty(PropertyExtensions.GetPropertyInfo(expression)));
 }
Пример #26
0
 private Changes(MetricsReport metrics)
 {
     _metrics = metrics;
 }
Пример #27
0
 public static MutableGraph<TypeMetricsReport> WithTypesOf(MetricsReport metrics)
 {
     return metrics.Types
         .ToDictionary(t => t, t => t.InterestingDirectDependencies.Select(d => metrics.TypeForName(d)))
         .ToGraph();
 }
Пример #28
0
 private void InitializeRatedLists(MetricsReport metrics)
 {
     RatedMethods = metrics.Methods.ToList(m => m.Rate(), m => !m.CompilerGenerated && !m.OnlyDeclaration);
     RatedTypes = metrics.Types.ToList(m => m.Rate(), m => !m.CompilerGenerated);
     RatedNamespaces = metrics.Namespaces.ToList(m => m.Rate());
 }
Пример #29
0
 public static void Of(MetricsReport metrics)
 {
     metrics.SetInterestingDirectDependencies();
     metrics.GraphOfTypes = CreateGraph.WithTypesOf(metrics);
     metrics.SetCumulativeComponentDependency();
 }
Пример #30
0
		public OutgoingTypeReferences(MetricsReport metrics, TypeMetricsReport source)
		{
			this.metrics = metrics;
			this.source = source;
		}
 public static MethodMetricsReport ForMethod(this MetricsReport metrics, MethodInfo method)
 {
     return(metrics.ForMethod(method.GetFullName()));
 }
Пример #32
0
 public void Analyze(string assemblyPath)
 {
     Report = new MetricsReport();
     using (var host = new PeReader.DefaultHost())
         TryToAnalyzeInHost(assemblyPath, host);
 }
Пример #33
0
 private Changes(MetricsReport metrics)
 {
     _metrics = metrics;
 }
Пример #34
0
 private static void AddTypesOf(MetricsReport[] reports, MetricsReport combinedReport)
 {
     foreach (var typeMetrics in reports.SelectMany(r => r.typeReports.Values))
         combinedReport.AddTypeReport(typeMetrics);
 }
Пример #35
0
 internal MetricsHotspots(MetricsReport metrics)
 {
     Metrics = metrics;
 }
 public static TypeMetricsReport ForTypeOf(this MetricsReport metrics, MethodMetricsReport methodMetrics)
 {
     return(metrics.TypeOf(methodMetrics));
 }
Пример #37
0
 public HotspotCyclomaticComplexity(MethodMetricsReport method, MetricsReport metrics)
     : base(method)
 {
 	mMetrics = metrics;
 }
Пример #38
0
 public HotspotNamespaceInCycle(NamespaceMetricsReport namespaceReport, MetricsReport metrics)
     : base(namespaceReport, metrics)
 {
 }
Пример #39
0
 public NamespaceCycle(MetricsReport metrics, IEnumerable<NamespaceMetricsReport> namespaces)
 {
     this.metrics = metrics;
     this.namespaces = namespaces;
     Jump += type => { };
 }
Пример #40
0
 public void Ensure_MetricsReportIsAvailable()
 {
     if (Metrics == null) Metrics = Analyze.Me();
 }
Пример #41
0
 protected override void AnalyzeTypes(IAssembly assembly, PdbReader pdb, IMetadataHost host, MetricsReport report)
 {
     foreach (var typeMetrics in AnalyzeTypes(assembly, pdb, host))
         report.AddTypeReport(typeMetrics);
 }
 public HotspotCumulativeComponentDependency(TypeMetricsReport type, MetricsReport metrics)
     : base(type, metrics)
 {
 }
Пример #43
0
 public static IEnumerable <TypeMetricsReport> TypesOfNamespace(this MetricsReport metrics, NamespaceMetricsReport namespaceMetrics)
 {
     return(metrics.TypesOf(namespaceMetrics));
 }
Пример #44
0
 public static IEnumerable <MethodMetricsReport> MethodsOfType(this MetricsReport metrics, TypeMetricsReport typeMetrics)
 {
     return(metrics.MethodsOf(typeMetrics));
 }
Пример #45
0
		public TypeReference(MetricsReport metrics, TypeMetricsReport source, TypeMetricsReport target)
		{
			this.metrics = metrics;
			this.Source = source;
			this.Target = target;
		}
Пример #46
0
 public HotspotClassSize(TypeMetricsReport type, MetricsReport metrics)
     : base(type, metrics)
 {
 }
Пример #47
0
 protected abstract void AnalyzeTypes(IAssembly assembly, PdbReader pdb, IMetadataHost host, MetricsReport report);
 public static TypeMetricsReport ForType(this MetricsReport metrics, Type type)
 {
     return(metrics.ForType(type.GetFullName()));
 }