Ejemplo n.º 1
0
        protected override Maybe <DesignSmell> DetectCore(IType t)
        {
            var Few        = 3;
            var amwAverage = 2;
            var wmcAverage = 14;
            var nomAverage = 7;

            var bur    = BaseClassUsageRatio.Value(t);
            var bovr   = BaseClassOverridingRatio.Value(t);
            var nprotm = NumberOfProtectedMembers.Value(t);
            var wmc    = WeightedMethodCount.Value(t);
            var nom    = t.NbMethods;
            var amw    = AverageMethodWeight.Value(t);

            var childClassIgnoresBequest = nprotm > Few && bur < CommonFractionThreshold.OneThird ||
                                           bovr < CommonFractionThreshold.OneThird;
            var childClassIsNotTooSmallAndSimple = (amw > amwAverage || wmc > wmcAverage) && nom > nomAverage;

            if (nprotm > 0 && childClassIgnoresBequest && childClassIsNotTooSmallAndSimple)
            {
                return(Maybe <DesignSmell> .From(
                           new DesignSmell
                {
                    Name = "Refused Parent Bequest",
                    Severity = CalculateSeverity(bur, bovr),
                    SourceFile = t.SourceFile(),
                    Source = t
                }));
            }

            return(Maybe <DesignSmell> .None);
        }
Ejemplo n.º 2
0
        public Maybe <DesignSmell> Detect(IType t)
        {
            var wmcVeryHigh = 47;

            var atfd = AccessToForeignDataForType.Value(t);
            var wmc  = WeightedMethodCount.Value(t);
            var tcc  = TotalClassCohesion.Value(t);

            if (atfd > Few && wmc >= wmcVeryHigh && tcc < CommonFractionThreshold.OneThird)
            {
                return(Maybe <DesignSmell> .From(new DesignSmell
                {
                    Name = "God Class", Severity = CalculateSeverity(atfd), SourceFile = t.SourceFile(), Source = t
                }));
            }

            return(Maybe <DesignSmell> .None);
        }
Ejemplo n.º 3
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);
        }