示例#1
0
        private void CheckClassRules(ITypeMetric itmClass, CodeMetricSetting setting, string nameClass)
        {
            if (IsMaxExceed(itmClass.ClassCoupling, setting.MaxClassCouplingforClass))
            {
                WrtLog(MetricSource.Class, "Class Coupling", nameClass, itmClass.ClassCoupling, setting.MaxClassCouplingforClass);
            }

            if (IsMaxExceed(itmClass.CyclomaticComplexity, setting.MaxCyclomaticComplexityforClass))
            {
                WrtLog(MetricSource.Class, "Cyclomatic Complexity", nameClass, itmClass.CyclomaticComplexity, setting.MaxCyclomaticComplexityforClass);
            }

            if (IsMaxExceed(itmClass.DepthOfInheritance, setting.MaxDepthofInheritenceforClass))
            {
                WrtLog(MetricSource.Class, "Depth of Inheritence", nameClass, itmClass.DepthOfInheritance, setting.MaxDepthofInheritenceforClass);
            }

            if (IsMaxExceed(itmClass.EfferentCoupling, setting.MaxEfferentCoupling))
            {
                WrtLog(MetricSource.Class, "Efferent Coupling", nameClass, itmClass.EfferentCoupling, setting.MaxEfferentCoupling);
            }

            if (IsMaxExceed(itmClass.LinesOfCode, setting.MaxLinesofCodeforClass))
            {
                WrtLog(MetricSource.Class, "Lines of Code", nameClass, itmClass.LinesOfCode, setting.MaxLinesofCodeforClass);
            }

            int mainIndx = (int)itmClass.MaintainabilityIndex;

            if (IsMinExceed(mainIndx, setting.MinMaintainabilityIndexforClass))
            {
                WrtLog(MetricSource.Class, "Maintainability Index", nameClass, mainIndx, setting.MinMaintainabilityIndexforClass);
            }
        }
 public TypeMetricWithNamespace(ITypeMetric typeMetric)
 {
     var type = typeMetric.GetType();
     var myType = typeof(TypeMetricWithNamespace);
     foreach (var property in type.GetProperties())
     {
         var prop = myType.GetProperty(property.Name);
         prop.SetValue(this, property.GetValue(typeMetric));
     }
 }
示例#3
0
        public TypeMetricWithNamespace(ITypeMetric typeMetric)
        {
            var type  = typeMetric.GetType();
            var props = type.GetProperties()
                        .Join(MyType.GetProperties(), p => p.Name, p => p.Name, Tuple.Create);

            foreach (var property in props)
            {
                var value = property.Item1.GetValue(typeMetric);
                property.Item2.SetValue(this, value);
            }
        }
示例#4
0
        private static IModelNode CreateTypeNodes(ITypeMetric typeMetric, IEnumerable <IProjectMetric> projectMetrics, IEnumerable <EvaluationResult> reviews)
        {
            var children = typeMetric.ClassCouplings
                           .Select(definition => CreateTypeReferenceNode(definition, projectMetrics))
                           .Merge()
                           .ToList();

            return(new ModelNode(
                       typeMetric.Name,
                       typeMetric.Kind.ToString(),
                       reviews.GetQuality(),
                       typeMetric.LinesOfCode,
                       typeMetric.MaintainabilityIndex,
                       typeMetric.CyclomaticComplexity,
                       children));
        }
		private static IModelNode CreateTypeNodes(ITypeMetric typeMetric, IEnumerable<IProjectMetric> projectMetrics, IEnumerable<EvaluationResult> reviews)
		{
			var children = typeMetric.ClassCouplings
				.Select(definition => CreateTypeReferenceNode(definition, projectMetrics))
				.Merge()
				.ToList();
			return new ModelNode(
				typeMetric.Name,
				typeMetric.Kind.ToString(),
				reviews.GetQuality(),
				typeMetric.LinesOfCode,
				typeMetric.MaintainabilityIndex,
				typeMetric.CyclomaticComplexity,
				children);
		}
 private static FileMetric GetFileMetric(ITypeMetric metric, string filePath)
 {
     return(new FileMetric(filePath, metric.Name, metric.CyclomaticComplexity, metric.MaintainabilityIndex, metric.LinesOfCode));
 }