Example #1
0
        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));
        }