Beispiel #1
0
        private static SolutionAnalysis AnalyzeParameterAssignment(this TwoFerSolution twoFerSolution)
        {
            if (!twoFerSolution.AssignsToParameter())
            {
                return(null);
            }

            if (!twoFerSolution.AssignsParameterUsingKnownExpression())
            {
                return(twoFerSolution.ReferToMentor());
            }

            if (twoFerSolution.ReturnsStringFormat())
            {
                return(twoFerSolution.ApproveWithComment(UseStringInterpolationNotStringFormat));
            }

            if (twoFerSolution.ReturnsStringConcatenation())
            {
                return(twoFerSolution.ApproveWithComment(UseStringInterpolationNotStringConcatenation));
            }

            if (!twoFerSolution.ReturnsStringInterpolation())
            {
                return(null);
            }

            if (twoFerSolution.AssignsParameterUsingNullCoalescingOperator())
            {
                return(twoFerSolution.ApproveWithComment(InlineVariable));
            }

            if (twoFerSolution.AssignsParameterUsingNullCheck() ||
                twoFerSolution.AssignsParameterUsingIfNullCheck())
            {
                return(twoFerSolution.ApproveWithComment(UseNullCoalescingOperatorNotNullCheck));
            }

            if (twoFerSolution.AssignsParameterUsingIsNullOrEmptyCheck() ||
                twoFerSolution.AssignsParameterUsingIfIsNullOrEmptyCheck())
            {
                return(twoFerSolution.ApproveWithComment(UseNullCoalescingOperatorNotIsNullOrEmptyCheck));
            }

            if (twoFerSolution.AssignsParameterUsingIsNullOrWhiteSpaceCheck() ||
                twoFerSolution.AssignsParameterUsingIfIsNullOrWhiteSpaceCheck())
            {
                return(twoFerSolution.ApproveWithComment(UseNullCoalescingOperatorNotIsNullOrWhiteSpaceCheck));
            }

            return(null);
        }