michielbdejong/solid-panes

View on GitHub
src/outline/userInput.js

Summary

Maintainability
F
1 mo
Test Coverage

Function UserInput has a Cognitive Complexity of 444 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = function UserInput (outline) {
  var kb = UI.store

  var myDocument = outline.document // is this ok?
  // UI.log.warn("myDocument when it's set is "+myDocument.location);
Severity: Minor
Found in src/outline/userInput.js - About 1 wk 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 UserInput has 1799 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function UserInput (outline) {
  var kb = UI.store

  var myDocument = outline.document // is this ok?
  // UI.log.warn("myDocument when it's set is "+myDocument.location);
Severity: Major
Found in src/outline/userInput.js - About 1 wk to fix

    File userInput.js has 1806 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    // Original author: kennyluck
    //
    // Kenny's Notes:
    /* places to generate SPARQL update: clearInputAndSave() pasteFromClipboard()->insertTermTo();
                                      undetermined statement generated formUndetStat()
    Severity: Major
    Found in src/outline/userInput.js - About 4 days to fix

      Function showMenu has 361 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          showMenu: function showMenu (
            e,
            menuType,
            inputQuery,
            extraInformation,
      Severity: Major
      Found in src/outline/userInput.js - About 1 day to fix

        Function clearInputAndSave has 242 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            clearInputAndSave: function clearInputAndSave (e) {
              if (!this.lastModified) return
              if (!this.lastModified.isNew) {
                try {
                  var obj = this.getStatementAbout(this.lastModified).object
        Severity: Major
        Found in src/outline/userInput.js - About 1 day to fix

          Function getAutoCompleteHandler has 191 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              getAutoCompleteHandler: function getAutoCompleteHandler (mode) {
                qp('\n\n***** In getAutoCompleteHandler ****** mode = ' + mode)
                if (mode === 'PredicateAutoComplete') {
                  mode = 'predicate'
                } else if (mode !== 'JournalTAC') {
          Severity: Major
          Found in src/outline/userInput.js - About 7 hrs to fix

            Function fillInRequest has 156 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                fillInRequest: function fillInRequest (type, selectedTd, inputTerm) {
                  var tr = selectedTd.parentNode
                  var stat
                  var isInverse
                  stat = tr.AJAR_statement
            Severity: Major
            Found in src/outline/userInput.js - About 6 hrs to fix

              Function Refill has 111 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  Refill: function Refill (e, selectedTd) {
                    UI.log.info('Refill' + selectedTd.textContent)
                    var isPredicate = selectedTd.nextSibling
                    var predicateQuery
                    if (isPredicate) {
              Severity: Major
              Found in src/outline/userInput.js - About 4 hrs to fix

                Function insertTermTo has 101 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    insertTermTo: function insertTermTo (selectedTd, term, isObject) {
                      switch (selectedTd.className) {
                        case 'undetermined selected':
                          var defaultpropview = this.views.defaults[
                            selectedTd.parentNode.AJAR_statement.predicate.uri
                Severity: Major
                Found in src/outline/userInput.js - About 4 hrs to fix

                  Function deleteTriple has 74 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      deleteTriple: function deleteTriple (selectedTd, isBackOut) {
                        // ToDo: complete deletion of a node
                        UI.log.debug('deleteTriple entered')
                  
                        // allow a pending node to be deleted if it's a backout sent by SPARQL update callback
                  Severity: Major
                  Found in src/outline/userInput.js - About 2 hrs to fix

                    Function addNewPredicateObject has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        addNewPredicateObject: function addNewPredicateObject (e) {
                          if (UI.utils.getTarget(e).className !== 'bottom-border-active') return
                          var This = outline.UserInput
                          var target = UI.utils.getTarget(e)
                    
                    
                    Severity: Minor
                    Found in src/outline/userInput.js - About 1 hr to fix

                      Function literalModification has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          literalModification: function literalModification (selectedTd) {
                            UI.log.debug(
                              'entering literal Modification with ' +
                                selectedTd +
                                selectedTd.textContent
                      Severity: Minor
                      Found in src/outline/userInput.js - About 1 hr to fix

                        Function pasteFromClipboard has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            pasteFromClipboard: function pasteFromClipboard (address, selectedTd) {
                              function termFrom (fromCode) {
                                var term = outline.clipboard[fromCode].shift()
                                if (term === null) {
                                  UI.log.warn('no more element in clipboard!')
                        Severity: Minor
                        Found in src/outline/userInput.js - About 1 hr to fix

                          Function appendToPredicate has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              appendToPredicate: function appendToPredicate (predicateTd) {
                                var isEnd = false
                                var trIterator
                                try {
                                  for (
                          Severity: Minor
                          Found in src/outline/userInput.js - About 1 hr to fix

                            Function generateRequest has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                generateRequest: function generateRequest (
                                  tipText,
                                  trNew,
                                  isPredicate,
                                  notShow
                            Severity: Minor
                            Found in src/outline/userInput.js - About 1 hr to fix

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

                                  addNewObject: function addNewObject (e) {
                                    var predicateTd = UI.utils.getTarget(e).parentNode.parentNode
                                    // var predicateTerm = UI.utils.getAbout(kb, predicateTd)
                                    var isInverse = predicateTd.parentNode.AJAR_inverse
                                    // var titleTerm=UI.utils.getAbout(kb,UI.utils.ancestor(predicateTd.parentNode,'TD'));
                              Severity: Minor
                              Found in src/outline/userInput.js - About 1 hr to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                  if (enterEvent.keyCode === 37) {
                                                    setHighlightItem(menu.lastHighlight.previousSibling)
                                                  } else {
                                                    setHighlightItem(menu.lastHighlight.nextSibling)
                                                  }
                                Severity: Major
                                Found in src/outline/userInput.js - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                    switch (menu.lastHighlight.value) {
                                                      case 'New...':
                                                        qp('subcase New')
                                                        outline.UserInput.createNew()
                                                        break
                                  Severity: Major
                                  Found in src/outline/userInput.js - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                                      if (mode === 'JournalTAC') {
                                                        outline.UserInput.clearMenu()
                                                        qp('no lastH')
                                                        return 'no lastH'
                                                      }
                                    Severity: Major
                                    Found in src/outline/userInput.js - About 45 mins to fix

                                      Avoid deeply nested control flow statements.
                                      Open

                                                        if (mode === 'JournalTAC') {
                                                          qp('movedArrow? ' + movedArrow)
                                                          // Enter only works if arrows have been moved
                                                          if (movedArrow && menu.lastHighlight) {
                                                            // Get the title from the DOM
                                      Severity: Major
                                      Found in src/outline/userInput.js - About 45 mins to fix

                                        Avoid deeply nested control flow statements.
                                        Open

                                                        if (!isInverse) {
                                                          newStats = kb.statementsMatching(
                                                            stat.subject,
                                                            stat.predicate,
                                                            inputTerm,
                                        Severity: Major
                                        Found in src/outline/userInput.js - About 45 mins to fix

                                          Avoid deeply nested control flow statements.
                                          Open

                                                          if (kb.any(undefined, selectedPredicate, textTerm)) {
                                                            if (!e) {
                                                              // keyboard
                                                              var tdNode = this.lastModified.parentNode
                                                              e = {}
                                          Severity: Major
                                          Found in src/outline/userInput.js - About 45 mins to fix

                                            Function formUndetStat has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                            Open

                                                  trNode,
                                                  subject,
                                                  predicate,
                                                  object,
                                                  why,
                                            Severity: Minor
                                            Found in src/outline/userInput.js - About 45 mins to fix

                                              Avoid deeply nested control flow statements.
                                              Open

                                                              if (!newStats.length) {
                                                                UI.log.error("userinput.js 1711: Can't find statememt!")
                                                              }
                                              Severity: Major
                                              Found in src/outline/userInput.js - About 45 mins to fix

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

                                                      e,
                                                      menuType,
                                                      inputQuery,
                                                      extraInformation,
                                                      _order
                                                Severity: Minor
                                                Found in src/outline/userInput.js - About 35 mins to fix

                                                  Avoid too many return statements within this function.
                                                  Open

                                                                  return
                                                  Severity: Major
                                                  Found in src/outline/userInput.js - About 30 mins to fix

                                                    Avoid too many return statements within this function.
                                                    Open

                                                                      return
                                                    Severity: Major
                                                    Found in src/outline/userInput.js - About 30 mins to fix

                                                      Avoid too many return statements within this function.
                                                      Open

                                                                return
                                                      Severity: Major
                                                      Found in src/outline/userInput.js - About 30 mins to fix

                                                        Avoid too many return statements within this function.
                                                        Open

                                                                    return
                                                        Severity: Major
                                                        Found in src/outline/userInput.js - About 30 mins to fix

                                                          Avoid too many return statements within this function.
                                                          Open

                                                                    return 'nothing to return'
                                                          Severity: Major
                                                          Found in src/outline/userInput.js - About 30 mins to fix

                                                            Avoid too many return statements within this function.
                                                            Open

                                                                            return
                                                            Severity: Major
                                                            Found in src/outline/userInput.js - About 30 mins to fix

                                                              Avoid too many return statements within this function.
                                                              Open

                                                                                  return 'asGivenTxt'
                                                              Severity: Major
                                                              Found in src/outline/userInput.js - About 30 mins to fix

                                                                Avoid too many return statements within this function.
                                                                Open

                                                                                return
                                                                Severity: Major
                                                                Found in src/outline/userInput.js - About 30 mins to fix

                                                                  Avoid too many return statements within this function.
                                                                  Open

                                                                          return
                                                                  Severity: Major
                                                                  Found in src/outline/userInput.js - About 30 mins to fix

                                                                    Avoid too many return statements within this function.
                                                                    Open

                                                                                    return "I'm a little Down Arrow"
                                                                    Severity: Major
                                                                    Found in src/outline/userInput.js - About 30 mins to fix

                                                                      Avoid too many return statements within this function.
                                                                      Open

                                                                                          return
                                                                      Severity: Major
                                                                      Found in src/outline/userInput.js - About 30 mins to fix

                                                                        Avoid too many return statements within this function.
                                                                        Open

                                                                                    return
                                                                        Severity: Major
                                                                        Found in src/outline/userInput.js - About 30 mins to fix

                                                                          Avoid too many return statements within this function.
                                                                          Open

                                                                                          return
                                                                          Severity: Major
                                                                          Found in src/outline/userInput.js - About 30 mins to fix

                                                                            Avoid too many return statements within this function.
                                                                            Open

                                                                                    return
                                                                            Severity: Major
                                                                            Found in src/outline/userInput.js - About 30 mins to fix

                                                                              Avoid too many return statements within this function.
                                                                              Open

                                                                                              return // The new Td is already generated by fillInRequest, so it's done.
                                                                              Severity: Major
                                                                              Found in src/outline/userInput.js - About 30 mins to fix

                                                                                Avoid too many return statements within this function.
                                                                                Open

                                                                                          return
                                                                                Severity: Major
                                                                                Found in src/outline/userInput.js - About 30 mins to fix

                                                                                  Avoid too many return statements within this function.
                                                                                  Open

                                                                                                  return "I'm a little Arrow Up"
                                                                                  Severity: Major
                                                                                  Found in src/outline/userInput.js - About 30 mins to fix

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

                                                                                                if (UI.utils.getTarget(e).className === 'bottom-border') {
                                                                                                  border.style.borderColor = 'rgb(100%,65%,0%)'
                                                                                                  border.style.cursor = 'copy'
                                                                                                }
                                                                                    Severity: Major
                                                                                    Found in src/outline/userInput.js and 1 other location - About 1 hr to fix
                                                                                    src/outline/userInput.js on lines 1440..1443

                                                                                    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

                                                                                            if (UI.utils.getTarget(e).className === 'bottom-border') {
                                                                                              border.style.borderColor = 'transparent'
                                                                                              border.style.cursor = 'auto'
                                                                                            }
                                                                                    Severity: Major
                                                                                    Found in src/outline/userInput.js and 1 other location - About 1 hr to fix
                                                                                    src/outline/userInput.js on lines 1426..1429

                                                                                    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

                                                                                              s = kb.add(
                                                                                                s.subject,
                                                                                                s.predicate,
                                                                                                kb.literal(this.lastModified.value),
                                                                                                s.why
                                                                                    Severity: Minor
                                                                                    Found in src/outline/userInput.js and 1 other location - About 35 mins to fix
                                                                                    src/outline/userInput.js on lines 487..492

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

                                                                                    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

                                                                                                  s2 = $rdf.st(
                                                                                                    s.subject,
                                                                                                    s.predicate,
                                                                                                    kb.literal(this.lastModified.value),
                                                                                                    s.why
                                                                                    Severity: Minor
                                                                                    Found in src/outline/userInput.js and 1 other location - About 35 mins to fix
                                                                                    src/outline/userInput.js on lines 464..469

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

                                                                                    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