onebeyond/onebeyond-studio-core

View on GitHub
src/OneBeyond.Studio.Application.SharedKernel/Specifications/FilterExpressionBuilder.cs

Summary

Maintainability
F
6 days
Test Coverage

File FilterExpressionBuilder.cs has 697 lines of code (exceeds 250 allowed). Consider refactoring.
Open

using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;

    Method TryConvertFromString has 77 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private static bool TryConvertFromString(string valueToken, Type type, out object? value)
        {
            valueToken = TrimEqualsFunction(valueToken);
            try
            {

      Method TryConvertFromString has a Cognitive Complexity of 33 (exceeds 20 allowed). Consider refactoring.
      Open

          private static bool TryConvertFromString(string valueToken, Type type, out object? value)
          {
              valueToken = TrimEqualsFunction(valueToken);
              try
              {

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method GetRangeExpressionForDate has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private static Expression GetRangeExpressionForDate(
              Expression propertyExpression,
              string[] dateValuesAsString)
          {
              if (dateValuesAsString.Length != 2)

        Method GetRangeExpressionForDateTimeOffset has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private static Expression GetRangeExpressionForDateTimeOffset(
                Expression propertyExpression,
                string[] dateTimeOffsetValuesAsString)
            {
                if (dateTimeOffsetValuesAsString.Length != 2)

          Method GetRangeExpressionForDateOnly has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private static Expression GetRangeExpressionForDateOnly(
                  Expression propertyExpression,
                  string[] dateValuesAsString)
              {
                  if (dateValuesAsString.Length != 2)

            Method IsStringFunction has 38 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private static bool IsStringFunction(string valueToken, out MethodInfo? function, out string? argument)
                {
                    valueToken = valueToken.Trim();
                    function = default;
                    argument = default;

              Method GetRangeExpressionForNumeric has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private static Expression GetRangeExpressionForNumeric(
                      Expression propertyExpression,
                      string[] numericValuesAsString)
                  {
                      if (numericValuesAsString.Length != 2)

                Method EvaluateFilterItems has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private static List<Expression> EvaluateFilterItems(
                        IReadOnlyCollection<FilterItem> filterItems,
                        ParameterExpression parameterExpression)
                    {
                        var expressions = new List<Expression>(filterItems.Count);

                  Method GetRangeExpression has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private static Expression GetRangeExpression(
                          Expression valueExpresion,
                          Expression? gteValueExpression,
                          Expression? lteValueExpression)
                      {

                    Method Build has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public static Expression<Func<T, bool>>? Build(
                            IReadOnlyDictionary<string, IReadOnlyCollection<string>> query,
                            CombineTypes combineType = CombineTypes.AND)
                        {
                            EnsureArg.IsNotNull(query, nameof(query));

                      Method GetEqualsExpressionForType has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private static Expression GetEqualsExpressionForType(
                              Expression propertyExpression,
                              ConstantExpression someValue)
                          {
                              switch (propertyExpression.Type.IsEnum ? "Enum" : propertyExpression.Type.Name)

                        Avoid too many return statements within this method.
                        Open

                                    return false;

                          Avoid too many return statements within this method.
                          Open

                                          return TryConvertDateOnlyFromString(valueToken, out value);

                            Avoid too many return statements within this method.
                            Open

                                            return TryConvertGuidFromString(valueToken, out value);

                              Avoid too many return statements within this method.
                              Open

                                                      return getSmartEnumFromValueLambda.Compile();

                                Avoid too many return statements within this method.
                                Open

                                            return true;

                                  Avoid too many return statements within this method.
                                  Open

                                              return true;

                                    Avoid too many return statements within this method.
                                    Open

                                            return false;

                                      Similar blocks of code found in 2 locations. Consider refactoring.
                                      Open

                                          private static Expression GetRangeExpressionForDateTimeOffset(
                                              Expression propertyExpression,
                                              string[] dateTimeOffsetValuesAsString)
                                          {
                                              if (dateTimeOffsetValuesAsString.Length != 2)
                                      src/OneBeyond.Studio.Application.SharedKernel/Specifications/FilterExpressionBuilder.cs on lines 274..323

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 395.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      Similar blocks of code found in 2 locations. Consider refactoring.
                                      Open

                                          private static Expression GetRangeExpressionForDateOnly(
                                              Expression propertyExpression,
                                              string[] dateValuesAsString)
                                          {
                                              if (dateValuesAsString.Length != 2)
                                      src/OneBeyond.Studio.Application.SharedKernel/Specifications/FilterExpressionBuilder.cs on lines 383..432

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 395.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      Similar blocks of code found in 2 locations. Consider refactoring.
                                      Open

                                              if (!numericValuesAsString[1].IsNullOrWhiteSpace())
                                              {
                                                  lteNumeric = Convert.ChangeType(
                                                          numericValuesAsString[1],
                                                          Nullable.GetUnderlyingType(propertyExpression.Type) ?? propertyExpression.Type)
                                      src/OneBeyond.Studio.Application.SharedKernel/Specifications/FilterExpressionBuilder.cs on lines 446..454

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 109.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      Similar blocks of code found in 2 locations. Consider refactoring.
                                      Open

                                              if (!numericValuesAsString[0].IsNullOrWhiteSpace())
                                              {
                                                  gteNumeric = Convert.ChangeType(
                                                          numericValuesAsString[0],
                                                          Nullable.GetUnderlyingType(propertyExpression.Type) ?? propertyExpression.Type)
                                      src/OneBeyond.Studio.Application.SharedKernel/Specifications/FilterExpressionBuilder.cs on lines 457..465

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 109.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      There are no issues that match your filters.

                                      Category
                                      Status