michielbdejong/solid-ui

View on GitHub
src/pad.js

Summary

Maintainability
F
1 wk
Test Coverage

Function notepad has a Cognitive Complexity of 184 (exceeds 5 allowed). Consider refactoring.
Open

UI.pad.notepad = function (dom, padDoc, subject, me, options) {
  options = options || {}
  var exists = options.exists
  var table = dom.createElement('table')
  var kb = UI.store
Severity: Minor
Found in src/pad.js - About 3 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 notepad has 580 lines of code (exceeds 25 allowed). Consider refactoring.
Open

UI.pad.notepad = function (dom, padDoc, subject, me, options) {
  options = options || {}
  var exists = options.exists
  var table = dom.createElement('table')
  var kb = UI.store
Severity: Major
Found in src/pad.js - About 2 days to fix

    File pad.js has 742 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /** **************
     *   Notepad Widget
     */
    
    /** @module UI.pad
    Severity: Major
    Found in src/pad.js - About 1 day to fix

      Function addListeners has 165 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        var addListeners = function (part, chunk) {
          part.addEventListener('keydown', function (event) {
            var queueProperty, queue
            //  up 38; down 40; left 37; right 39     tab 9; shift 16; escape 27
            switch (event.keyCode) {
      Severity: Major
      Found in src/pad.js - About 6 hrs to fix

        Function updateStore has 71 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            var updateStore = function (part) {
              var chunk = part.subject
              setPartStyle(part, undefined, true)
              var old = kb.any(chunk, ns.sioc('content')).value
              var del = [$rdf.st(chunk, ns.sioc('content'), old, padDoc)]
        Severity: Major
        Found in src/pad.js - About 2 hrs to fix

          Function newChunk has 65 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            var newChunk = function (ele, before) {
              // element of chunk being split
              var kb = UI.store
              var indent = 0
              var queueProperty = null
          Severity: Major
          Found in src/pad.js - About 2 hrs to fix

            Function consistencyCheck has 51 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              var consistencyCheck = function () {
                var found = []
                var failed = 0
                function complain2 (msg) {
                  complain(msg)
            Severity: Major
            Found in src/pad.js - About 2 hrs to fix

              Function sync has 50 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                var sync = function () {
                  // var first = kb.the(subject, PAD('next'))
                  if (kb.each(subject, PAD('next')).length !== 1) {
                    var msg =
                      'Pad: Inconsistent data - NEXT pointers: ' +
              Severity: Minor
              Found in src/pad.js - About 2 hrs to fix

                Function removePart has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  var removePart = function (part) {
                    var chunk = part.subject
                    if (!chunk) throw new Error('No chunk for line to be deleted!') // just in case
                    var prev = kb.any(undefined, PAD('next'), chunk)
                    var next = kb.any(chunk, PAD('next'))
                Severity: Minor
                Found in src/pad.js - About 1 hr to fix

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

                  UI.pad.renderPartipants = function (dom, table, padDoc, subject, me, options) {
                    table.setAttribute('style', 'margin: 0.8em;')
                  
                    var newRowForParticpation = function (parp) {
                      var person = kb.any(parp, ns.wf('participant'))
                  Severity: Minor
                  Found in src/pad.js - About 1 hr to fix

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

                    UI.pad.participationObject = function (subject, padDoc, me) {
                      return new Promise(function (resolve, reject) {
                        if (!me) {
                          throw new Error('Not user id')
                        }
                    Severity: Minor
                    Found in src/pad.js - About 1 hr to fix

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

                        var reloadAndSync = function () {
                          if (reloading) {
                            console.log('   Already reloading - stop')
                            return // once only needed
                          }
                      Severity: Minor
                      Found in src/pad.js - About 1 hr to fix

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

                        UI.pad.recordParticipation = function (subject, padDoc, refreshable) {
                          var me = UI.authn.currentUser()
                          if (!me) return // Not logged in
                        
                          var parps = kb.each(subject, ns.wf('participation')).filter(function (pn) {
                        Severity: Minor
                        Found in src/pad.js - About 1 hr to fix

                          Function setPartStyle has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            var setPartStyle = function (part, colors, pending) {
                              var chunk = part.subject
                              colors = colors || ''
                              var baseStyle =
                                'font-size: 100%; font-family: monospace; width: 100%; border: none; white-space: pre-wrap;'
                          Severity: Minor
                          Found in src/pad.js - About 1 hr to fix

                            Function tryReload has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                var tryReload = function () {
                                  console.log('try reload - timeout = ' + retryTimeout)
                                  updater.reload(updater.store, padDoc, function (ok, message, xhr) {
                                    reloading = false
                                    if (ok) {
                            Severity: Minor
                            Found in src/pad.js - About 1 hr to fix

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

                                dom,
                                container,
                                padDoc,
                                subject,
                                me,
                              Severity: Minor
                              Found in src/pad.js - About 45 mins to fix

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

                                UI.pad.renderPartipants = function (dom, table, padDoc, subject, me, options) {
                                Severity: Minor
                                Found in src/pad.js - About 45 mins to fix

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

                                  UI.pad.notepad = function (dom, padDoc, subject, me, options) {
                                  Severity: Minor
                                  Found in src/pad.js - About 35 mins to fix

                                    Function participationObject has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                    UI.pad.participationObject = function (subject, padDoc, me) {
                                      return new Promise(function (resolve, reject) {
                                        if (!me) {
                                          throw new Error('Not user id')
                                        }
                                    Severity: Minor
                                    Found in src/pad.js - About 35 mins 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

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

                                      var hash = function (x) {
                                        return x.split('').reduce(function (a, b) {
                                          a = (a << 5) - a + b.charCodeAt(0)
                                          return a & a
                                        }, 0)
                                    Severity: Major
                                    Found in src/pad.js and 1 other location - About 1 hr to fix
                                    src/utils.js on lines 99..104

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

                                    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

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

                                      var refreshTree = function (root) {
                                        if (root.refresh) {
                                          root.refresh()
                                          return
                                        }
                                    Severity: Major
                                    Found in src/pad.js and 1 other location - About 1 hr to fix
                                    src/widgets/buttons.js on lines 582..590

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

                                    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

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

                                      var parps = kb.each(subject, ns.wf('participation')).filter(function (pn) {
                                        return kb.holds(pn, ns.wf('participant'), me)
                                      })
                                    Severity: Major
                                    Found in src/pad.js and 1 other location - About 1 hr to fix
                                    src/pad.js on lines 104..106

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

                                    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

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

                                        var parps = kb.each(subject, ns.wf('participation')).filter(function (pn) {
                                          return kb.holds(pn, ns.wf('participant'), me)
                                        })
                                    Severity: Major
                                    Found in src/pad.js and 1 other location - About 1 hr to fix
                                    src/pad.js on lines 150..152

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

                                    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

                                            case 38: // Up
                                              if (part.parentNode.previousSibling) {
                                                part.parentNode.previousSibling.firstChild.focus()
                                                event.preventDefault()
                                              }
                                    Severity: Minor
                                    Found in src/pad.js and 1 other location - About 55 mins to fix
                                    src/pad.js on lines 459..464

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

                                    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

                                            case 40: // Down
                                              if (part.parentNode.nextSibling) {
                                                part.parentNode.nextSibling.firstChild.focus()
                                                event.preventDefault()
                                              }
                                    Severity: Minor
                                    Found in src/pad.js and 1 other location - About 55 mins to fix
                                    src/pad.js on lines 452..457

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

                                    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