Пример #1
0
        private bool ClassHasEnoughLongMethods(PartialSmellDetectionReport report)
        {
            int longMethodCounter = 0;

            foreach (List <Issue> issues in report.CodeSnippetIssues.Values)
            {
                longMethodCounter += issues.Count(issue => issue.IssueType == SmellType.LONG_METHOD);
            }

            return(longMethodCounter >= _relatedSmellsCount);
        }
Пример #2
0
        public PartialSmellDetectionReport FindIssues(List <CaDETClass> classes)
        {
            List <CaDETMember> methods = classes.SelectMany(c => c.Members).ToList();

            var partialReport = new PartialSmellDetectionReport();

            foreach (var method in methods)
            {
                var issues = ApplyRule(method);
                foreach (var issue in issues.Where(issue => issue != null))
                {
                    partialReport.AddIssue(issue.CodeSnippetId, issue);
                }
            }
            return(partialReport);
        }
Пример #3
0
        public PartialSmellDetectionReport FindIssues(List <CaDETClass> classes)
        {
            //DefineTopXMetricRules(caDetClassDtoList);

            var partialReport = new PartialSmellDetectionReport();

            foreach (var cadetClass in classes)
            {
                var issues = ApplyRule(cadetClass);
                foreach (var issue in issues.Where(issue => issue != null))
                {
                    partialReport.AddIssue(issue.CodeSnippetId, issue);
                }
            }
            return(partialReport);
        }
Пример #4
0
        public PartialSmellDetectionReport FindIssues(List <CaDETClass> classes)
        {
            var partialReport = new PartialSmellDetectionReport();

            foreach (var caDETClass in classes)
            {
                var metricRuleIssue = ApplyRule(caDETClass);
                if (metricRuleIssue == null)
                {
                    continue;
                }

                var methodIssuesReport = _methodMetricRuleEngine.FindIssues(new List <CaDETClass> {
                    caDETClass
                });
                if (ClassHasEnoughLongMethods(methodIssuesReport))
                {
                    partialReport.AddIssue(caDETClass.FullName,
                                           new Issue(SmellType.GOD_CLASS, caDETClass.FullName));
                }
            }
            return(partialReport);
        }