michielbdejong/solid-panes

View on GitHub
src/outline/manager.js

Summary

Maintainability
F
1 mo
Test Coverage

Function exports has a Cognitive Complexity of 699 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = function (context) {
  const dom = context.dom

  this.document = context.dom
  this.outlineIcons = outlineIcons
Severity: Minor
Found in src/outline/manager.js - About 2 wks 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 exports has 1847 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function (context) {
  const dom = context.dom

  this.document = context.dom
  this.outlineIcons = outlineIcons
Severity: Major
Found in src/outline/manager.js - About 1 wk to fix

    File manager.js has 1856 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /* -*- coding: utf-8-dos -*-
       Outline Mode Manager
    */
    var panes = require('pane-registry')
    const $rdf = require('rdflib')
    Severity: Major
    Found in src/outline/manager.js - About 5 days to fix

      Function appendPropertyTRs has 178 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        function appendPropertyTRs (parent, plist, inverse, predicateFilter) {
          // UI.log.info('@appendPropertyTRs, 'this' is %s, dom is %s, '+ // Gives 'can't access dead object'
          //                   'thisOutline.document is %s', this, dom.location, thisOutline.document.location);
          // UI.log.info('@appendPropertyTRs, dom is now ' + this.document.location);
          // UI.log.info('@appendPropertyTRs, dom is now ' + thisOutline.document.location);
      Severity: Major
      Found in src/outline/manager.js - About 7 hrs to fix

        Function expandedHeaderTR has 162 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          async function expandedHeaderTR (subject, requiredPane, options) {
            async function renderPaneIconTray (td, options = {}) {
              const paneShownStyle =
                'width: 24px; border-radius: 0.5em; border-top: solid #222 1px; border-left: solid #222 0.1em; border-bottom: solid #eee 0.1em; border-right: solid #eee 0.1em; margin-left: 1em; padding: 3px; background-color:   #ffd;'
              const paneHiddenStyle =
        Severity: Major
        Found in src/outline/manager.js - About 6 hrs to fix

          Function outlineExpand has 158 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            function outlineExpand (p, subject1, options) {
              options = options || {}
              var pane = options.pane
              var already = !!options.already
              var immediate = options.immediate
          Severity: Major
          Found in src/outline/manager.js - About 6 hrs to fix

            Function OutlinerKeypressPanel has 136 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              this.OutlinerKeypressPanel = function OutlinerKeypressPanel (e) {
                UI.log.info('Key ' + e.keyCode + ' pressed')
            
                function showURI (about) {
                  if (about && dom.getElementById('UserURI')) {
            Severity: Major
            Found in src/outline/manager.js - About 5 hrs to fix

              Function renderPaneIconTray has 115 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  async function renderPaneIconTray (td, options = {}) {
                    const paneShownStyle =
                      'width: 24px; border-radius: 0.5em; border-top: solid #222 1px; border-left: solid #222 0.1em; border-bottom: solid #eee 0.1em; border-right: solid #eee 0.1em; margin-left: 1em; padding: 3px; background-color:   #ffd;'
                    const paneHiddenStyle =
                      'width: 24px; border-radius: 0.5em; margin-left: 1em; padding: 3px'
              Severity: Major
              Found in src/outline/manager.js - About 4 hrs to fix

                Function showNobj has 105 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      tr.showNobj = function (n) {
                        var predDups = k - dups
                        var show = 2 * n < predDups ? n : predDups
                        var showLaterArray = []
                        if (predDups !== 1) {
                Severity: Major
                Found in src/outline/manager.js - About 4 hrs to fix

                  Function listen has 86 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                            var listen = function (ico, pane) {
                              // Freeze scope for event time
                              ico.addEventListener(
                                'click',
                                function (event) {
                  Severity: Major
                  Found in src/outline/manager.js - About 3 hrs to fix

                    Function outlineObjectTD has 79 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      this.outlineObjectTD = function outlineObjectTD (
                        obj,
                        view,
                        deleteNode,
                        statement
                    Severity: Major
                    Found in src/outline/manager.js - About 3 hrs to fix

                      Function viewAsBoringDefault has 72 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        function viewAsBoringDefault (obj) {
                          // UI.log.debug('entered viewAsBoringDefault...');
                          var rep // representation in html
                      
                          if (obj.termType === 'Literal') {
                      Severity: Major
                      Found in src/outline/manager.js - About 2 hrs to fix

                        Function getDashboardItems has 60 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          async function getDashboardItems () {
                            const me = UI.authn.currentUser()
                            const div = dom.createElement('div')
                            const [books, pods] = await Promise.all([getAddressBooks(), getPods()])
                            return [
                        Severity: Major
                        Found in src/outline/manager.js - About 2 hrs to fix

                          Function walk has 60 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            this.walk = function walk (directionCode, inputTd) {
                              var selectedTd = inputTd || selection[0]
                              var newSelTd
                              switch (directionCode) {
                                case 'down':
                          Severity: Major
                          Found in src/outline/manager.js - About 2 hrs to fix

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

                              this.appendAccessIcon = function (node, uri) {
                                if (!uri) return ''
                                var docuri = UI.rdf.uri.docpart(uri)
                                if (docuri.slice(0, 5) !== 'http:') return ''
                                var state = sf.getState(docuri)
                            Severity: Major
                            Found in src/outline/manager.js - About 2 hrs to fix

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

                                this.outlinePredicateTD = function outlinePredicateTD (
                                  predicate,
                                  newTr,
                                  inverse,
                                  internal
                              Severity: Minor
                              Found in src/outline/manager.js - About 2 hrs to fix

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

                                    function render () {
                                      subject = kb.canon(subject)
                                      if (!p || !p.parentNode || !p.parentNode.parentNode) return false
                                
                                      var newTable
                                Severity: Minor
                                Found in src/outline/manager.js - About 1 hr to fix

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

                                    function setSelected (node, newValue) {
                                      // UI.log.info('selection has ' +selection.map(function(item){return item.textContent;}).join(', '));
                                      // UI.log.debug('@outline setSelected, intended to '+(newValue?'select ':'deselect ')+node+node.textContent);
                                      // if (newValue === selected(node)) return; //we might not need this anymore...
                                      if (node.nodeName !== 'TD') {
                                  Severity: Minor
                                  Found in src/outline/manager.js - About 1 hr to fix

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

                                        function expand (uri) {
                                          if (arguments[3]) return true // already fetched indicator
                                          var cursubj = kb.canon(subject) // canonical identifier may have changed
                                          UI.log.info(
                                            '@@ expand: relevant subject=' +
                                    Severity: Minor
                                    Found in src/outline/manager.js - About 1 hr to fix

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

                                        async function globalAppTabs (options = {}) {
                                          console.log('globalAppTabs @@')
                                          const div = dom.createElement('div')
                                          const me = UI.authn.currentUser()
                                          if (!me) {
                                      Severity: Minor
                                      Found in src/outline/manager.js - About 1 hr to fix

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

                                          var propertyTable = (this.propertyTable = function propertyTable (
                                            subject,
                                            table,
                                            pane,
                                            options
                                        Severity: Minor
                                        Found in src/outline/manager.js - About 1 hr to fix

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

                                            this.GotoSubject = function (subject, expand, pane, solo, referrer, table) {
                                              table = table || dom.getElementById('outline') // if does not exist just add one? nowhere to out it
                                              if (solo) {
                                                UI.utils.emptyNode(table)
                                                table.style.width = '100%'
                                          Severity: Minor
                                          Found in src/outline/manager.js - About 1 hr to fix

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

                                              function selectableTDClickListener (e) {
                                                // Is we are in editing mode already
                                                if (thisOutline.UserInput._tabulatorMode) {
                                                  return thisOutline.UserInput.Click(e)
                                                }
                                            Severity: Minor
                                            Found in src/outline/manager.js - About 1 hr to fix

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

                                                async function showDashboard (options = {}) {
                                                  const dashboardContainer = getDashboardContainer()
                                                  const outlineContainer = getOutlineContainer()
                                                  // reuse dashboard if already children already is inserted
                                                  if (dashboardContainer.childNodes.length > 0 && options.pane) {
                                              Severity: Minor
                                              Found in src/outline/manager.js - About 1 hr to fix

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

                                                  function setSelectedParent (node, inc) {
                                                    var onIcon = outlineIcons.termWidgets.optOn
                                                    var offIcon = outlineIcons.termWidgets.optOff
                                                    for (var n = node; n.parentNode; n = n.parentNode) {
                                                      while (true) {
                                                Severity: Minor
                                                Found in src/outline/manager.js - About 1 hr to fix

                                                  Function renderPane has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                                                  Open

                                                                  var renderPane = function (pane) {
                                                                    var paneDiv
                                                                    UI.log.info('outline: Rendering pane (2): ' + pane.name)
                                                                    if (UI.no_catch_pane_errors) {
                                                                      // for debugging
                                                  Severity: Minor
                                                  Found in src/outline/manager.js - About 1 hr to fix

                                                    Function TabulatorMousedown has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                                                    Open

                                                      function TabulatorMousedown (e) {
                                                        UI.log.info('@TabulatorMousedown, dom.location is now ' + dom.location)
                                                        var target = thisOutline.targetOf(e)
                                                        if (!target) return
                                                        var tname = target.tagName
                                                    Severity: Minor
                                                    Found in src/outline/manager.js - About 1 hr to fix

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

                                                        function outlineCollapse (p, subject) {
                                                          var row = UI.utils.ancestor(p, 'TR')
                                                          row = UI.utils.ancestor(row.parentNode, 'TR') // two levels up
                                                          if (row) var statement = row.AJAR_statement
                                                          var level // find level (the enclosing TD)
                                                      Severity: Minor
                                                      Found in src/outline/manager.js - About 1 hr to fix

                                                        Consider simplifying this complex logical expression.
                                                        Open

                                                            if (
                                                              obj.termType === 'NamedNode' ||
                                                              obj.termType === 'BlankNode' ||
                                                              (obj.termType === 'Literal' &&
                                                                obj.value.slice &&
                                                        Severity: Major
                                                        Found in src/outline/manager.js - About 1 hr to fix

                                                          Avoid deeply nested control flow statements.
                                                          Open

                                                                                  if (d.paneButton) {
                                                                                    d.paneButton.setAttribute('class', 'paneHidden')
                                                                                    d.paneButton.style = paneHiddenStyle
                                                                                  }
                                                          Severity: Major
                                                          Found in src/outline/manager.js - About 45 mins to fix

                                                            Avoid deeply nested control flow statements.
                                                            Open

                                                                          if (displayed >= show) {
                                                                            trObj.style.display = 'none'
                                                                            showLaterArray.push(trObj)
                                                                          }
                                                            Severity: Major
                                                            Found in src/outline/manager.js - About 45 mins to fix

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

                                                                this.GotoSubject = function (subject, expand, pane, solo, referrer, table) {
                                                              Severity: Minor
                                                              Found in src/outline/manager.js - About 45 mins to fix

                                                                Avoid deeply nested control flow statements.
                                                                Open

                                                                                        if (
                                                                                          d.pane.requireQueryButton &&
                                                                                          t.parentNode.className /* outer table */ &&
                                                                                          numberOfPanesRequiringQueryButton === 1 &&
                                                                                          dom.getElementById('queryButton')
                                                                Severity: Major
                                                                Found in src/outline/manager.js - About 45 mins to fix

                                                                  Avoid too many return statements within this function.
                                                                  Open

                                                                      if (UI.utils.getTarget(e).tagName === 'INPUT') return
                                                                  Severity: Major
                                                                  Found in src/outline/manager.js - About 30 mins to fix

                                                                    Avoid too many return statements within this function.
                                                                    Open

                                                                            if (this.walk('left')) return
                                                                    Severity: Major
                                                                    Found in src/outline/manager.js - About 30 mins to fix

                                                                      Avoid too many return statements within this function.
                                                                      Open

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

                                                                        Avoid too many return statements within this function.
                                                                        Open

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

                                                                          Avoid too many return statements within this function.
                                                                          Open

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

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

                                                                                                try {
                                                                                                  paneDiv = pane.render(subject, context, options)
                                                                                                } catch (e) {
                                                                                                  // Easier debugging for pane developers
                                                                                                  paneDiv = dom.createElement('div')
                                                                            Severity: Major
                                                                            Found in src/outline/manager.js and 1 other location - About 2 hrs to fix
                                                                            src/outline/manager.js on lines 821..831

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

                                                                            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

                                                                                      try {
                                                                                        UI.log.info('outline: Rendering pane (1): ' + tr1.firstPane.name)
                                                                                        paneDiv = tr1.firstPane.render(subject, context, options)
                                                                                      } catch (e) {
                                                                                        // Easier debugging for pane developers
                                                                            Severity: Major
                                                                            Found in src/outline/manager.js and 1 other location - About 2 hrs to fix
                                                                            src/outline/manager.js on lines 644..655

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

                                                                            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

                                                                                function showURI (about) {
                                                                                  if (about && dom.getElementById('UserURI')) {
                                                                                    dom.getElementById('UserURI').value =
                                                                                      about.termType === 'NamedNode' ? about.uri : '' // blank if no URI
                                                                                  }
                                                                            Severity: Major
                                                                            Found in src/outline/manager.js and 1 other location - About 1 hr to fix
                                                                            src/outline/manager.js on lines 1325..1330

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

                                                                            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

                                                                              this.showURI = function showURI (about) {
                                                                                if (about && dom.getElementById('UserURI')) {
                                                                                  dom.getElementById('UserURI').value =
                                                                                    about.termType === 'NamedNode' ? about.uri : '' // blank if no URI
                                                                                }
                                                                            Severity: Major
                                                                            Found in src/outline/manager.js and 1 other location - About 1 hr to fix
                                                                            src/outline/manager.js on lines 1520..1525

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

                                                                            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 (inverse) {
                                                                                  sel = function (x) {
                                                                                    return x.subject
                                                                                  }
                                                                                  plist = plist.sort(UI.utils.RDFComparePredicateSubject)
                                                                            Severity: Minor
                                                                            Found in src/outline/manager.js and 1 other location - About 35 mins to fix
                                                                            src/outline/manager.js on lines 883..888

                                                                            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

                                                                                } else {
                                                                                  sel = function (x) {
                                                                                    return x.object
                                                                                  }
                                                                                  plist = plist.sort(UI.utils.RDFComparePredicateObject)
                                                                            Severity: Minor
                                                                            Found in src/outline/manager.js and 1 other location - About 35 mins to fix
                                                                            src/outline/manager.js on lines 878..883

                                                                            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