18F/federalist

View on GitHub
admin-client/src/lib/jsonTreeView.js

Summary

Maintainability
F
2 wks
Test Coverage

Function JSONTreeView has a Cognitive Complexity of 307 (exceeds 5 allowed). Consider refactoring.
Open

function JSONTreeView(name_, value_, parent_, isRoot_) {
  const self = this;
  this.ee = new EventEmitter();
  this.on = (...args) => this.ee.on(...args);
  this.once = (...args) => this.ee.once(...args);
Severity: Minor
Found in admin-client/src/lib/jsonTreeView.js - About 6 days 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 JSONTreeView has 726 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function JSONTreeView(name_, value_, parent_, isRoot_) {
  const self = this;
  this.ee = new EventEmitter();
  this.on = (...args) => this.ee.on(...args);
  this.once = (...args) => this.ee.once(...args);
Severity: Major
Found in admin-client/src/lib/jsonTreeView.js - About 3 days to fix

    File jsonTreeView.js has 762 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /**
     * https://gist.github.com/mudge/5830382#gistcomment-2691957
     */
    class EventEmitter {
      constructor() {
    Severity: Major
    Found in admin-client/src/lib/jsonTreeView.js - About 1 day to fix

      Function setValue has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        function setValue(newValue) {
          let oldValue = value;
          let str; let
            len;
      
      
      Severity: Minor
      Found in admin-client/src/lib/jsonTreeView.js - About 1 hr to fix

        Function expand has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          function expand(recursive, silent) {
            let keys;
        
            if (type == 'object') {
              keys = Object.keys(value);
        Severity: Minor
        Found in admin-client/src/lib/jsonTreeView.js - About 1 hr to fix

          Function editFieldStop has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            function editFieldStop(field) {
              const element = dom[field];
          
              if (field == 'name') {
                if (!edittingName) {
          Severity: Minor
          Found in admin-client/src/lib/jsonTreeView.js - About 1 hr to fix

            Function editField has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              function editField(field) {
                if ((readonly > 0 && filterText) || !!(readonly & 1)) {
                  return;
                }
                if (field === 'value' && (type === 'object' || type === 'array')) {
            Severity: Minor
            Found in admin-client/src/lib/jsonTreeView.js - About 1 hr to fix

              Function numericValueKeyDown has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                function numericValueKeyDown(e) {
                  let increment = 0; let
                    currentValue;
              
                  if (type != 'number') {
              Severity: Minor
              Found in admin-client/src/lib/jsonTreeView.js - About 1 hr to fix

                Function onChildAppend has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                  function onChildAppend(child, keyPath, nameOrValue, newValue, sender) {
                Severity: Minor
                Found in admin-client/src/lib/jsonTreeView.js - About 35 mins to fix

                  Function onChildDelete has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                    function onChildDelete(child, keyPath, deletedValue, parentType, passive) {
                  Severity: Minor
                  Found in admin-client/src/lib/jsonTreeView.js - About 35 mins to fix

                    Function onChildRename has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                      function onChildRename(child, keyPath, oldName, newName, original) {
                    Severity: Minor
                    Found in admin-client/src/lib/jsonTreeView.js - About 35 mins to fix

                      Function onChildChange has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                        function onChildChange(child, keyPath, oldValue, newValue, recursed) {
                      Severity: Minor
                      Found in admin-client/src/lib/jsonTreeView.js - About 35 mins to fix

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

                          function onChildClick(child, keyPath, value) {
                            if (self.withRootName || !self.isRoot) {
                              keyPath.unshift(name);
                            }
                            self.emit('click', child, keyPath, value);
                        Severity: Major
                        Found in admin-client/src/lib/jsonTreeView.js and 3 other locations - About 1 hr to fix
                        admin-client/src/lib/jsonTreeView.js on lines 903..908
                        admin-client/src/lib/jsonTreeView.js on lines 910..915
                        admin-client/src/lib/jsonTreeView.js on lines 917..922

                        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 57.

                        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 4 locations. Consider refactoring.
                        Open

                          function onChildExpand(child, keyPath, value) {
                            if (self.withRootName || !self.isRoot) {
                              keyPath.unshift(name);
                            }
                            self.emit('expand', child, keyPath, value);
                        Severity: Major
                        Found in admin-client/src/lib/jsonTreeView.js and 3 other locations - About 1 hr to fix
                        admin-client/src/lib/jsonTreeView.js on lines 896..901
                        admin-client/src/lib/jsonTreeView.js on lines 910..915
                        admin-client/src/lib/jsonTreeView.js on lines 917..922

                        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 57.

                        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 4 locations. Consider refactoring.
                        Open

                          function onChildCollapse(child, keyPath, value) {
                            if (self.withRootName || !self.isRoot) {
                              keyPath.unshift(name);
                            }
                            self.emit('collapse', child, keyPath, value);
                        Severity: Major
                        Found in admin-client/src/lib/jsonTreeView.js and 3 other locations - About 1 hr to fix
                        admin-client/src/lib/jsonTreeView.js on lines 896..901
                        admin-client/src/lib/jsonTreeView.js on lines 903..908
                        admin-client/src/lib/jsonTreeView.js on lines 917..922

                        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 57.

                        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 4 locations. Consider refactoring.
                        Open

                          function onChildRefresh(child, keyPath, value) {
                            if (self.withRootName || !self.isRoot) {
                              keyPath.unshift(name);
                            }
                            self.emit('refresh', child, keyPath, value);
                        Severity: Major
                        Found in admin-client/src/lib/jsonTreeView.js and 3 other locations - About 1 hr to fix
                        admin-client/src/lib/jsonTreeView.js on lines 896..901
                        admin-client/src/lib/jsonTreeView.js on lines 903..908
                        admin-client/src/lib/jsonTreeView.js on lines 910..915

                        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 57.

                        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

                            self.emit('delete', self, [self.name], self.value,
                              self.parent.isRoot ? self.parent.oldType : self.parent.type, false);
                        Severity: Major
                        Found in admin-client/src/lib/jsonTreeView.js and 1 other location - About 1 hr to fix
                        admin-client/src/lib/jsonTreeView.js on lines 627..628

                        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 56.

                        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

                            child.emit('delete', child, [child.name], child.value,
                              child.parent.isRoot ? child.parent.oldType : child.parent.type, true);
                        Severity: Major
                        Found in admin-client/src/lib/jsonTreeView.js and 1 other location - About 1 hr to fix
                        admin-client/src/lib/jsonTreeView.js on lines 822..823

                        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 56.

                        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 (!silent && (type == 'object' || type == 'array')) {
                              self.emit('expand', self, [self.name], self.value);
                            }
                        Severity: Minor
                        Found in admin-client/src/lib/jsonTreeView.js and 1 other location - About 40 mins to fix
                        admin-client/src/lib/jsonTreeView.js on lines 433..435

                        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 49.

                        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 (!silent && (type == 'object' || type == 'array')) {
                              self.emit('collapse', self, [self.name], self.value);
                            }
                        Severity: Minor
                        Found in admin-client/src/lib/jsonTreeView.js and 1 other location - About 40 mins to fix
                        admin-client/src/lib/jsonTreeView.js on lines 481..483

                        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 49.

                        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 3 locations. Consider refactoring.
                        Open

                                for (const i in children) {
                                  if (typeof children[i] === 'object') {
                                    children[i].showCountOfObjectOrArray = show;
                                  }
                                }
                        Severity: Minor
                        Found in admin-client/src/lib/jsonTreeView.js and 2 other locations - About 30 mins to fix
                        admin-client/src/lib/jsonTreeView.js on lines 210..214
                        admin-client/src/lib/jsonTreeView.js on lines 227..231

                        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 45.

                        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 3 locations. Consider refactoring.
                        Open

                                for (const i in children) {
                                  if (typeof children[i] === 'object') {
                                    children[i].filterText = text;
                                  }
                                }
                        Severity: Minor
                        Found in admin-client/src/lib/jsonTreeView.js and 2 other locations - About 30 mins to fix
                        admin-client/src/lib/jsonTreeView.js on lines 177..181
                        admin-client/src/lib/jsonTreeView.js on lines 227..231

                        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 45.

                        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 3 locations. Consider refactoring.
                        Open

                                for (const i in children) {
                                  if (typeof children[i] === 'object') {
                                    children[i].alwaysShowRoot = value;
                                  }
                                }
                        Severity: Minor
                        Found in admin-client/src/lib/jsonTreeView.js and 2 other locations - About 30 mins to fix
                        admin-client/src/lib/jsonTreeView.js on lines 177..181
                        admin-client/src/lib/jsonTreeView.js on lines 210..214

                        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 45.

                        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