private static SolutionAnalysis AnalyzeVariableAssignment(this TwoFerSolution twoFerSolution) { if (!twoFerSolution.AssignsVariable()) { return(null); } if (!twoFerSolution.AssignsVariableUsingKnownInitializer()) { return(twoFerSolution.ReferToMentor()); } if (twoFerSolution.ReturnsStringFormatWithVariable()) { return(twoFerSolution.ApproveWithComment(UseStringInterpolationNotStringFormat)); } if (twoFerSolution.ReturnsStringConcatenationWithVariable()) { return(twoFerSolution.ApproveWithComment(UseStringInterpolationNotStringConcatenation)); } if (!twoFerSolution.ReturnsStringInterpolationWithVariable()) { return(null); } if (twoFerSolution.AssignsVariableUsingNullCoalescingOperator()) { return(twoFerSolution.ApproveAsOptimal()); } if (twoFerSolution.AssignsVariableUsingNullCheck()) { return(twoFerSolution.ApproveWithComment(UseNullCoalescingOperatorNotTernaryOperatorWithNullCheck)); } if (twoFerSolution.AssignsVariableUsingIsNullOrEmptyCheck()) { return(twoFerSolution.ApproveWithComment(UseNullCoalescingOperatorNotTernaryOperatorWithIsNullOrEmptyCheck)); } if (twoFerSolution.AssignsVariableUsingIsNullOrWhiteSpaceCheck()) { return(twoFerSolution.ApproveWithComment(UseNullCoalescingOperatorNotTernaryOperatorWithIsNullOrWhiteSpaceCheck)); } return(null); }
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); }
private static SolutionAnalysis AnalyzeSingleLine(this TwoFerSolution twoFerSolution) { if (!twoFerSolution.UsesSingleLine()) { return(null); } if (twoFerSolution.ReturnsStringInterpolationWithDefaultValue() || twoFerSolution.ReturnsStringInterpolationWithNullCoalescingOperator()) { return(twoFerSolution.UsesExpressionBody() ? twoFerSolution.ApproveAsOptimal() : twoFerSolution.ApproveWithComment(UseExpressionBodiedMember)); } if (twoFerSolution.ReturnsStringInterpolationWithIsNullOrEmptyCheck()) { return(twoFerSolution.ApproveWithComment(UseNullCoalescingOperatorNotTernaryOperatorWithIsNullOrEmptyCheck)); } if (twoFerSolution.ReturnsStringInterpolationWithIsNullOrWhiteSpaceCheck()) { return(twoFerSolution.ApproveWithComment(UseNullCoalescingOperatorNotTernaryOperatorWithIsNullOrWhiteSpaceCheck)); } if (twoFerSolution.ReturnsStringInterpolationWithNullCheck()) { return(twoFerSolution.ApproveWithComment(UseNullCoalescingOperatorNotTernaryOperatorWithNullCheck)); } if (twoFerSolution.ReturnsStringConcatenation()) { return(twoFerSolution.ApproveWithComment(UseStringInterpolationNotStringConcatenation)); } if (twoFerSolution.ReturnsStringFormat()) { return(twoFerSolution.ApproveWithComment(UseStringInterpolationNotStringFormat)); } return(null); }