Пример #1
0
        public Maybe <DesignSmell> Detect(IType t)
        {
            var             woc = WeightOfAClass.Value(t);
            var             wmc = WeightedMethodCount.Value(t);
            IList <IMember> publicAttributes = t.PublicAttributes().ToList();
            var             nopa             = publicAttributes.Count;
            IList <IMember> accessors        = t.Accessors().ToList();
            var             noam             = accessors.Count;

            if (woc < CommonFractionThreshold.OneThird &&
                (nopa + noam > Few && wmc < 31 ||
                 nopa + noam > 8 && wmc < 47))
            {
                return(Maybe <DesignSmell> .From(
                           new DesignSmell
                {
                    Name = "Data Class", Severity = CalculateSeverity(publicAttributes, accessors, t), SourceFile = t.SourceFile(), Source = t
                }));
            }

            return(Maybe <DesignSmell> .None);
        }