mohsen1/json-formatter

View on GitHub
src/json-formatter.js

Summary

Maintainability
D
2 days
Test Coverage

Function jsonFormatterDirective has a Cognitive Complexity of 64 (exceeds 5 allowed). Consider refactoring.
Open

.directive('jsonFormatter', ['RecursionHelper', 'JSONFormatterConfig', function jsonFormatterDirective(RecursionHelper, JSONFormatterConfig) {
  function escapeString(str) {
    return str.replace('"', '\"');
  }

Severity: Minor
Found in src/json-formatter.js - About 1 day 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

Function jsonFormatterDirective has 135 lines of code (exceeds 25 allowed). Consider refactoring.
Open

.directive('jsonFormatter', ['RecursionHelper', 'JSONFormatterConfig', function jsonFormatterDirective(RecursionHelper, JSONFormatterConfig) {
  function escapeString(str) {
    return str.replace('"', '\"');
  }

Severity: Major
Found in src/json-formatter.js - About 5 hrs to fix

    Function link has 68 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      function link(scope) {
        scope.isArray = function () {
          return angular.isArray(scope.json);
        };
    
    
    Severity: Major
    Found in src/json-formatter.js - About 2 hrs to fix

      Function JSONFormatterConfigProvider has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      .provider('JSONFormatterConfig', function JSONFormatterConfigProvider() {
      
        // Default values for hover preview config
        var hoverPreviewEnabled = false;
        var hoverPreviewArrayCount = 100;
      Severity: Minor
      Found in src/json-formatter.js - About 1 hr to fix

        Avoid too many return statements within this function.
        Open

              return results[1];
        Severity: Major
        Found in src/json-formatter.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                return '';
          Severity: Major
          Found in src/json-formatter.js - About 30 mins to fix

            There are no issues that match your filters.

            Category
            Status