michielbdejong/solid-ui

View on GitHub
src/table.js

Summary

Maintainability
F
2 wks
Test Coverage

Function renderTableViewPane has a Cognitive Complexity of 376 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = function renderTableViewPane (doc, options) {
  var sourceDocument = options.sourceDocument
  var tableClass = options.tableClass
  var givenQuery = options.query

Severity: Minor
Found in src/table.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 renderTableViewPane has 1064 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function renderTableViewPane (doc, options) {
  var sourceDocument = options.sourceDocument
  var tableClass = options.tableClass
  var givenQuery = options.query

Severity: Major
Found in src/table.js - About 5 days to fix

    File table.js has 1075 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    // Table Widget: Format an array of RDF statements as an HTML table.
    //
    // This can operate in one of three modes: when the class of object is given
    // or when the source document from whuch data is taken is given,
    // or if a prepared query object is given.
    Severity: Major
    Found in src/table.js - About 2 days to fix

      Function Column has 85 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        function Column () {
          this.useCount = 0
      
          // Have we checked any values for this column yet?
      
      
      Severity: Major
      Found in src/table.js - About 3 hrs to fix

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

          function runQuery (query, rows, columns, table) {
            query.running = true
            var startTime = Date.now()
        
            var progressMessage = doc.createElement('tr')
        Severity: Major
        Found in src/table.js - About 2 hrs to fix

          Function renderLiteralSelector has 56 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            function renderLiteralSelector (rows, columns, column) {
              var result = doc.createElement('div')
          
              var textBox = doc.createElement('input')
              textBox.setAttribute('type', 'text')
          Severity: Major
          Found in src/table.js - About 2 hrs to fix

            Function renderEnumSelector has 47 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              function renderEnumSelector (rows, columns, column, list) {
                var doMultiple = true
                var result = doc.createElement('div')
                var dropdown = doc.createElement('select')
            
            
            Severity: Minor
            Found in src/table.js - About 1 hr to fix

              Function renderTableRowInto has 43 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                function renderTableRowInto (tr, row, columns, _downstream) {
                  /* Link column, for linking to this subject. */
              
                  var linkTd = doc.createElement('td')
              
              
              Severity: Minor
              Found in src/table.js - About 1 hr to fix

                Function SubjectType has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  function SubjectType (type) {
                    this.type = type
                    this.columns = null
                    this.allColumns = null
                    this.useCount = 0
                Severity: Minor
                Found in src/table.js - About 1 hr to fix

                  Function renderNumberSelector has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    function renderNumberSelector (rows, columns, column) {
                      var result = doc.createElement('div')
                  
                      var minSelector = doc.createElement('input')
                      minSelector.setAttribute('type', 'text')
                  Severity: Minor
                  Found in src/table.js - About 1 hr to fix

                    Function renderValue has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      function renderValue (obj, column) {
                        // hint
                        var hints = getHints(column)
                        var cellFormat = hints.cellFormat
                        if (cellFormat) {
                    Severity: Minor
                    Found in src/table.js - About 1 hr to fix

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

                        function inferColumnsFromFormula (columns, formula) {
                          UI.log.debug('>> processing formula')
                      
                          for (let i = 0; i < formula.statements.length; ++i) {
                            var statement = formula.statements[i]
                      Severity: Minor
                      Found in src/table.js - About 1 hr to fix

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

                          function generateColumnAddDropdown (type) {
                            var resultDiv = doc.createElement('div')
                        
                            var unusedColumns = type.getUnusedColumns()
                        
                        
                        Severity: Minor
                        Found in src/table.js - About 1 hr to fix

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

                              var onResult = function (values) {
                                if (!query.running) {
                                  return
                                }
                          
                          
                          Severity: Minor
                          Found in src/table.js - About 1 hr to fix

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

                              function applyColumnSort (rows, column, sortFunction, reverse) {
                                var columnKey = column.getKey()
                            
                                // Sort the rows array.
                                rows.sort(function (row1, row2) {
                            Severity: Minor
                            Found in src/table.js - About 1 hr to fix

                              Avoid deeply nested control flow statements.
                              Open

                                          if (obj.toString() !== orig.toString()) {
                                            different = true
                                          }
                              Severity: Major
                              Found in src/table.js - About 45 mins to fix

                                Avoid too many return statements within this function.
                                Open

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

                                  Avoid too many return statements within this function.
                                  Open

                                          return doc.createTextNode("unknown termtype '" + obj.termType + "'!")
                                  Severity: Major
                                  Found in src/table.js - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                            return linkToObject(obj, hints)
                                    Severity: Major
                                    Found in src/table.js - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                          return fallbackRenderTableSelector(rows, columns, column)
                                      Severity: Major
                                      Found in src/table.js - About 30 mins to fix

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

                                              if (
                                                statement.predicate.termType === 'NamedNode' &&
                                                statement.subject.termType === 'Variable'
                                              ) {
                                                const variable = statement.subject.toString()
                                        Severity: Major
                                        Found in src/table.js and 1 other location - About 1 hr to fix
                                        src/table.js on lines 1670..1679

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

                                        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 (
                                                statement.predicate.termType === 'NamedNode' &&
                                                statement.object.termType === 'Variable'
                                              ) {
                                                var variable = statement.object.toString()
                                        Severity: Major
                                        Found in src/table.js and 1 other location - About 1 hr to fix
                                        src/table.js on lines 1680..1689

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

                                        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