Esempio n. 1
0
        public void Apply(Instance src)
        {
            if (!Matches(src))
            {
                return;
            }

            LinesOfCode                  = LinesOfCode.Max(src.LinesOfCode);
            DepthOfInheritance           = DepthOfInheritance.Max(src.DepthOfInheritance);
            CyclomaticComplexity         = CyclomaticComplexity.Max(src.CyclomaticComplexity);
            ClassCoupling                = ClassCoupling.Max(src.ClassCoupling);
            NumberOfMethods              = NumberOfMethods.Max(src.NumberOfMethods);
            AnonymousInnerClassLength    = AnonymousInnerClassLength.Max(src.AnonymousInnerClassLength);
            ClassFanOutComplexity        = ClassFanOutComplexity.Max(src.ClassFanOutComplexity);
            ClassDataAbstractionCoupling = ClassDataAbstractionCoupling.Max(src.ClassDataAbstractionCoupling);

            if (src.Members.HasValues())
            {
                Members = new List <Member>(src.Members);
            }
            if (src.Duplicates.HasValues())
            {
                Duplicates = new List <Duplicate>(src.Duplicates);
            }
        }
        public void ComplexityToString_ReturnsValue()
        {
            var    complexity     = new CyclomaticComplexity(5);
            string complexityText = complexity.ToString();

            Assert.AreEqual("Complexity:5", complexityText, "Complexity ToString should return formated value.");
        }
Esempio n. 3
0
        public string GetPropertyValueString(string prop)
        {
            switch (prop)
            {
            case "codeLines":
                return(CodeLines?.ToString("N0") ?? string.Empty);

            case "commentedCodeLines":
                return(CommentedCodeLines?.ToString("N0") ?? string.Empty);

            case "commentLines":
                return(CommentLines?.ToString("N0") ?? string.Empty);

            case "coupling":
                return(Coupling?.ToString("N0") ?? string.Empty);

            case "fanIn":
                return(FanIn?.ToString("N0") ?? string.Empty);

            case "fanOut":
                return(FanOut?.ToString("N0") ?? string.Empty);

            case "cyclomaticComplexity":
                return(CyclomaticComplexity?.ToString("N0") ?? string.Empty);

            case "ratioCommentLinesCodeLines":
                return(RatioCommentLinesCodeLines?.ToString("N2") ?? string.Empty);

            case "halsteadProgramLength":
                return(HalsteadProgramLength?.ToString("N0") ?? string.Empty);

            case "halsteadProgramVocabulary":
                return(HalsteadProgramVocabulary?.ToString("N0") ?? string.Empty);

            case "halsteadVolume":
                return(HalsteadVolume?.ToString("N2") ?? string.Empty);

            case "distinctOperators":
                return(DistinctOperators?.ToString("N0") ?? string.Empty);

            case "distinctOperands":
                return(DistinctOperands?.ToString("N0") ?? string.Empty);

            case "integrationComplexity":
                return(IntegrationComplexity?.ToString("N0") ?? string.Empty);

            case "essentialComplexity":
                return(EssentialComplexity?.ToString("N0") ?? string.Empty);

            default:
                return(string.Empty);
            }
        }
        public void LocTester(string treeKey)
        {
            SyntaxTree tree = _treeDictionary[treeKey];

            int result = int.Parse(treeKey.Split("-")[0]);

            var classDeclaration = (ClassDeclarationSyntax)tree.GetRoot().ChildNodes().Single();

            int cc = CyclomaticComplexity.GetCount(classDeclaration);

            Assert.IsTrue(cc == result);
        }
Esempio n. 5
0
        public string GetCSVString()
        {
            var builder = new StringBuilder();

            builder.Append(Solution).Append(PrintConstants.Semicolon);
            builder.Append(TotalNumberOfClasses).Append(PrintConstants.Semicolon);
            builder.Append(TotalNumberOfMethods).Append(PrintConstants.Semicolon);
            builder.Append(CyclomaticComplexity).Append(PrintConstants.Semicolon);
            builder.Append(TotalNumberOfNamespaces).Append(PrintConstants.Semicolon);
            builder.Append(TotalLinesOfCode).Append(PrintConstants.Semicolon);
            builder.Append(Double.Parse(TotalNumberOfClasses.ToString()) / TotalNumberOfNamespaces).Append(PrintConstants.Semicolon);
            builder.Append(Double.Parse(TotalNumberOfMethods.ToString()) / TotalNumberOfClasses).Append(PrintConstants.Semicolon);
            builder.Append(Double.Parse(TotalLinesOfCode.ToString()) / TotalNumberOfMethods).Append(PrintConstants.Semicolon);
            builder.Append(Double.Parse(CyclomaticComplexity.ToString()) / TotalLinesOfCode);
            return(builder.ToString());
        }
 private ProjectPlanDto BuildProjectPlanDto()
 {
     lock (m_Lock)
     {
         return(new ProjectPlanDto()
         {
             ProjectStart = ProjectStart,
             DependentActivities = Activities.Select(x => DtoConverter.ToDto(x)).ToList(),
             ResourceSettings = ResourceSettingsDto.Copy(),
             ArrowGraphSettings = ArrowGraphSettingsDto.Copy(),
             GraphCompilation = DtoConverter.ToDto(GraphCompilation, CyclomaticComplexity.GetValueOrDefault(), Duration.GetValueOrDefault()),
             ArrowGraph = ArrowGraphDto != null?ArrowGraphDto.Copy() : new ArrowGraphDto()
             {
                 Edges = new List <ActivityEdgeDto>(), Nodes = new List <EventNodeDto>(), IsStale = false
             },
             HasStaleOutputs = HasStaleOutputs
         });
     }
 }
Esempio n. 7
0
        private static void CyclomaticComplexity()
        {
            var cc = new CyclomaticComplexity();

            cc.RunReport(Report.StaffShiftPattern);
        }