private static SolutionAnalysis Analyze(GigasecondSolution gigasecondSolution) { if (gigasecondSolution.ReturnsAddSecondsWithScientificNotation()) { return(gigasecondSolution.UsesExpressionBody() ? gigasecondSolution.ApproveAsOptimal() : gigasecondSolution.ApproveWithComment(SharedComments.UseExpressionBodiedMember)); } if (gigasecondSolution.ReturnsAddSecondsWithMathPow()) { return(gigasecondSolution.ApproveWithComment(GigasecondComments.UseScientificNotationNotMathPow)); } if (gigasecondSolution.ReturnsAddSecondsWithDigitsWithoutSeparator()) { return(gigasecondSolution.ApproveWithComment(GigasecondComments.UseScientificNotationOrDigitSeparators)); } if (gigasecondSolution.UsesAddMethod() || gigasecondSolution.UsesPlusOperator()) { return(gigasecondSolution.DisapproveWithComment(GigasecondComments.UseAddSeconds)); } return(gigasecondSolution.ReferToMentor()); }
private static SolutionAnalysis ApproveWhenValid(this GigasecondSolution gigasecondSolution) { if (gigasecondSolution.UsesMathPow()) { return(gigasecondSolution.ApproveWithComment(UseScientificNotationNotMathPow)); } if (gigasecondSolution.UsesDigitsWithoutSeparator()) { return(gigasecondSolution.ApproveWithComment(UseScientificNotationOrDigitSeparators)); } if (!gigasecondSolution.UsesScientificNotation() && !gigasecondSolution.UsesDigitsWithSeparator()) { return(null); } if (gigasecondSolution.AssignsToParameterAndReturns() || gigasecondSolution.AssignsToVariableAndReturns()) { return(gigasecondSolution.ApproveWithComment(ReturnImmediately)); } if (gigasecondSolution.UsesLocalConstVariable()) { return(gigasecondSolution.ApproveAsOptimal()); } if (gigasecondSolution.UsesLocalVariable()) { return(gigasecondSolution.ApproveWithComment(UseConstant)); } if (gigasecondSolution.UsesPrivateConstField()) { return(gigasecondSolution.UsesExpressionBody() ? gigasecondSolution.ApproveAsOptimal() : gigasecondSolution.ApproveWithComment(UseExpressionBodiedMember)); } if (gigasecondSolution.UsesConstField()) { return(gigasecondSolution.ApproveWithComment(UsePrivateVisibility)); } if (gigasecondSolution.UsesField()) { return(gigasecondSolution.ApproveWithComment(UseConstant)); } return(gigasecondSolution.UsesExpressionBody() ? gigasecondSolution.ApproveAsOptimal() : gigasecondSolution.ApproveWithComment(UseExpressionBodiedMember)); }