CORE-POS/IS4C

View on GitHub
pos/is4c-nf/scale-drivers/drivers/NewMagellan/Newtonsoft.Json/Utilities/JavaScriptUtils.cs

Summary

Maintainability
D
2 days
Test Coverage

Method WriteEscapedJavaScriptString has a Cognitive Complexity of 82 (exceeds 20 allowed). Consider refactoring.
Open

        public static void WriteEscapedJavaScriptString(TextWriter writer, string s, char delimiter, bool appendDelimiters,
            bool[] charEscapeFlags, StringEscapeHandling stringEscapeHandling, ref char[] writeBuffer)
        {
            // leading delimiter
            if (appendDelimiters)

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

        public static void WriteEscapedJavaScriptString(TextWriter writer, string s, char delimiter, bool appendDelimiters,
            bool[] charEscapeFlags, StringEscapeHandling stringEscapeHandling, ref char[] writeBuffer)
        {
            // leading delimiter
            if (appendDelimiters)

    Method WriteEscapedJavaScriptString has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            public static void WriteEscapedJavaScriptString(TextWriter writer, string s, char delimiter, bool appendDelimiters,
                bool[] charEscapeFlags, StringEscapeHandling stringEscapeHandling, ref char[] writeBuffer)

      Avoid deeply nested control flow statements.
      Open

                                      if (c == '\'' && stringEscapeHandling != StringEscapeHandling.EscapeHtml)
                                      {
                                          escapedValue = @"\'";
                                      }
                                      else if (c == '"' && stringEscapeHandling != StringEscapeHandling.EscapeHtml)

        Avoid deeply nested control flow statements.
        Open

                                    if (isEscapedUnicodeText)
                                        Array.Copy(writeBuffer, newBuffer, 6);

          There are no issues that match your filters.

          Category
          Status