예제 #1
0
        public Maybe <DesignSmell> Detect(IMethod m)
        {
            var Shallow        = 1;
            var Few            = 5;
            var ShortMemoryCap = 7;

            var maxNesting = m.ILNestingDepth;
            var cint       = CouplingIntensity.Value(m);
            var cdisp      = CouplingDispersion.Value(m);

            if ((cint > ShortMemoryCap && cdisp < CommonFractionThreshold.Half ||
                 cint > Few && cdisp < CommonFractionThreshold.AQuarter) && maxNesting > Shallow)
            {
                return(Maybe <DesignSmell> .From(
                           new DesignSmell
                {
                    Name = "Intensive Coupling",
                    Severity = CalculateSeverity(cint, cdisp),
                    SourceFile = m.ParentType.SourceFile(),
                    Source = m
                }));
            }

            return(Maybe <DesignSmell> .None);
        }
예제 #2
0
        private static double CalculateSeverity(int icio, int icdo, IMethod method)
        {
            var severityIcio = LinearNormalization.WithMeasurementRange(7, 21).ValueFor(icio);
            var severityIcdo = LinearNormalization.WithMeasurementRange(3, 9).ValueFor(icdo);

            var ocio         = CouplingIntensity.Value(method);
            var severityOcio = LinearNormalization.WithMeasurementRange(7, 21).ValueFor(ocio);

            var ocdo         = CouplingDispersion.Value(method);
            var severityOcdo = LinearNormalization.WithMeasurementRange(3, 9).ValueFor(ocdo);

            return((2 * severityIcio + 2 * severityIcdo + severityOcio + severityOcdo) / 6);
        }