zedseven/Romanization.NET

View on GitHub
Romanization/Internal/ReplaceOperations.cs

Summary

Maintainability
C
1 day
Test Coverage
B
88%

Method ReplaceWithSameCase has a Cognitive Complexity of 56 (exceeds 20 allowed). Consider refactoring.
Open

        [Pure]
        public static string ReplaceWithSameCase(this string str, string oldValue, string newValue, StringComparison strComp = StringComparison.CurrentCultureIgnoreCase)
        {
            // Check inputs.
            if (str == null)
Severity: Minor
Found in Romanization/Internal/ReplaceOperations.cs - About 6 hrs to fix

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 ReplaceWithSameCase has 59 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        [Pure]
        public static string ReplaceWithSameCase(this string str, string oldValue, string newValue, StringComparison strComp = StringComparison.CurrentCultureIgnoreCase)
        {
            // Check inputs.
            if (str == null)
Severity: Major
Found in Romanization/Internal/ReplaceOperations.cs - About 2 hrs to fix

    Consider simplifying this complex logical expression.
    Open

                        if (newValue.Length > 1)
                        {
                            bool lastCharUpper = char.IsUpper(str[foundAt + oldValue.Length - 1]) &&
                                                 (oldValue.Length > 1 ||
                                                  (str.Length > foundAt + 1 && char.IsUpper(str[foundAt + 1])) ||
    Severity: Major
    Found in Romanization/Internal/ReplaceOperations.cs - About 40 mins to fix

      There are no issues that match your filters.

      Category
      Status