zedseven/Romanization.NET

View on GitHub

Showing 14 of 14 total issues

Method Replace has a Cognitive Complexity of 62 (exceeds 20 allowed). Consider refactoring.
Open

        public string Replace(string text)
        {
            StringBuilder result = new StringBuilder(text.Length);

            bool foundMatch = false;
Severity: Minor
Found in Romanization/Internal/CaseAwareSub.cs - About 7 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 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 Process has a Cognitive Complexity of 41 (exceeds 20 allowed). Consider refactoring.
Open

            [Pure]
            public string Process(string text, bool givenName, bool noun = false, bool hyphenateSyllables = false)
            {
                text = text
                    // Replace common alternate characters
Severity: Minor
Found in Romanization/Languages/Korean/RevisedRomanization.cs - About 3 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 ToRomanNumerals has 78 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        [Pure]
        public static string ToRomanNumerals(this decimal num)
        {
            if (num < 0)
                throw new ArgumentOutOfRangeException(nameof(num), num, "Must be a non-negative value");
Severity: Major
Found in Romanization/Internal/NumeralRenderer.cs - About 3 hrs to fix

    Method Replace has 63 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            public string Replace(string text)
            {
                StringBuilder result = new StringBuilder(text.Length);
    
                bool foundMatch = false;
    Severity: Major
    Found in Romanization/Internal/CaseAwareSub.cs - About 2 hrs to fix

      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

        File ModifiedHepburn.cs has 261 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        using Romanization.Internal;
        using System;
        using System.Collections.Generic;
        using System.Diagnostics.Contracts;
        using System.Globalization;
        Severity: Minor
        Found in Romanization/Languages/Japanese/ModifiedHepburn.cs - About 2 hrs to fix

          Method Process has 54 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                      [Pure]
                      public string Process(string text, bool givenName, bool noun = false, bool hyphenateSyllables = false)
                      {
                          text = text
                              // Replace common alternate characters
          Severity: Major
          Found in Romanization/Languages/Korean/RevisedRomanization.cs - About 2 hrs to fix

            Method Process has 53 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                            [Pure]
                            internal NumeralValue Process(string text, bool? textUsesOverbars)
                            {
                                // Clean, normalize, and prepare the text
                                // TODO: This could be done much more efficiently, but this system should only ever be used for small strings so the impact shouldn't be very high
            Severity: Major
            Found in Romanization/Languages/Greek/Ancient/GreekNumerals.cs - About 2 hrs to fix

              Method Generate has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      public string Generate(CasingMode casingMode, IList<string> captures)
                      {
                          if (captures.Count != ExpectedCaptureCount)
                              throw new CaptureCountMismatchException(
                                  $"Number of captures provided ({captures.Count}) does not match the expected number ({ExpectedCaptureCount}).",
              Severity: Minor
              Found in Romanization/Internal/DynamicReplacement.cs - About 1 hr to fix

                Avoid deeply nested control flow statements.
                Open

                                            if (match.Groups[i].Index + match.Groups[i].Length <= searchStart)
                                            {
                                                lastCharIndex = searchStart;
                                                break;
                                            }
                Severity: Major
                Found in Romanization/Internal/CaseAwareSub.cs - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                                      if (!noun && jamoList[i + 1] == 'ㅎ' &&
                                                          (jamoList[i] == 'ㄱ' || jamoList[i] == 'ㄷ' || jamoList[i] == 'ㅂ'))
                                                          romanizedText.Append(hyphenateSyllables
                                                              ? specialCaseRomanization.ToString(false)
                                                              : specialCaseRomanization.BaseString.NonAspiratedString);
                  Severity: Major
                  Found in Romanization/Languages/Korean/RevisedRomanization.cs - About 45 mins to fix

                    Consider simplifying this complex logical expression.
                    Open

                                    if (firstCharIndex > -1)
                                    {
                                        searchStart = match.Index + match.Length - 1;
                                        if (!_countCapturesInCasing)
                                            for (int i = match.Groups.Count - 1; i >= 1; i--)
                    Severity: Major
                    Found in Romanization/Internal/CaseAwareSub.cs - About 40 mins 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
                        Severity
                        Category
                        Status
                        Source
                        Language