michielbdejong/solid-panes

View on GitHub
src/transaction/period.js

Summary

Maintainability
F
1 wk
Test Coverage

Function render has a Cognitive Complexity of 149 (exceeds 5 allowed). Consider refactoring.
Open

  render: function (subject, context) {
    const dom = context.dom
    var kb = context.session.store
    var ns = UI.ns

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

  render: function (subject, context) {
    const dom = context.dom
    var kb = context.session.store
    var ns = UI.ns

Severity: Major
Found in src/transaction/period.js - About 1 day to fix

    Function renderPeriod has 245 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        var renderPeriod = function () {
          var dtstart = kb.any(subject, ns.cal('dtstart'))
          if (dtstart === undefined) {
            complain(
              '(Error: There is no start date known for this period <' +
    Severity: Major
    Found in src/transaction/period.js - About 1 day to fix

      File period.js has 289 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /*   Financial Period Pane
       **
       **  This outline pane allows a user to interact with a period
       **  downloaded from a bank statement, annotting it with classes and comments,
       ** trips, etc
      Severity: Minor
      Found in src/transaction/period.js - About 2 hrs to fix

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

              var transactionTable = function (dom, list) {
                var table = dom.createElement('table')
                table.setAttribute(
                  'style',
                  'margin-left: 100; font-size: 9pt; width: 85%;'
        Severity: Minor
        Found in src/transaction/period.js - About 1 hr to fix

          Function transactionRow has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  var transactionRow = function (dom, x) {
                    var tr = dom.createElement('tr')
          
                    var setTRStyle = function (tr, account) {
                      // var mystyle = "padding: 0.5em 1.5em 1em 1.5em; ";
          Severity: Minor
          Found in src/transaction/period.js - About 1 hr to fix

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

                    dom,
                    row,
                    subject,
                    paneName,
                    solo
            Severity: Minor
            Found in src/transaction/period.js - About 35 mins to fix

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

                    var expandAfterRow = function (dom, row, subject, paneName, solo) {
              Severity: Minor
              Found in src/transaction/period.js - About 35 mins to fix

                Avoid too many return statements within this function.
                Open

                        return 0
                Severity: Major
                Found in src/transaction/period.js - About 30 mins to fix

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

                          var transactionRow = function (dom, x) {
                            var tr = dom.createElement('tr')
                  
                            var setTRStyle = function (tr, account) {
                              // var mystyle = "padding: 0.5em 1.5em 1em 1.5em; ";
                  Severity: Major
                  Found in src/transaction/period.js and 1 other location - About 2 days to fix
                  src/transaction/pane.js on lines 184..230

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

                  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 expandAfterRow = function (dom, row, subject, paneName, solo) {
                          var siblings = row.parentNode.children
                          if (solo) {
                            for (var j = siblings.length - 1; j >= 0; j--) {
                              if (siblings[j].expanded) {
                  Severity: Major
                  Found in src/transaction/period.js and 1 other location - About 1 day to fix
                  src/transaction/pane.js on lines 136..161

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

                  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 oderByDate = function (x, y) {
                          const dx = kb.any(x, ns.qu('date'))
                          const dy = kb.any(y, ns.qu('date'))
                          if (dx !== undefined && dy !== undefined) {
                            if (dx.value < dy.value) return -1
                  Severity: Major
                  Found in src/transaction/period.js and 1 other location - About 6 hrs to fix
                  src/transaction/pane.js on lines 117..127

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

                  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 (unclassifiedIn.length) {
                          tab = transactionTable(dom, unclassifiedIn)
                          count = tab.children.length
                          div.appendChild(dom.createElement('h3')).textContent =
                            'Unclassified Income' + (count < 4 ? '' : ' (' + count + ')')
                  Severity: Major
                  Found in src/transaction/period.js and 1 other location - About 2 hrs to fix
                  src/transaction/period.js on lines 288..296

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

                  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 (unclassifiedOut.length) {
                          tab = transactionTable(dom, unclassifiedOut)
                          count = tab.children.length
                          div.appendChild(dom.createElement('h3')).textContent =
                            'Unclassified Outgoings' + (count < 4 ? '' : ' (' + count + ')')
                  Severity: Major
                  Found in src/transaction/period.js and 1 other location - About 2 hrs to fix
                  src/transaction/period.js on lines 279..287

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

                  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 expandAfterRowOrCollapse = function (
                          dom,
                          row,
                          subject,
                          paneName,
                  Severity: Major
                  Found in src/transaction/period.js and 1 other location - About 1 hr to fix
                  src/transaction/pane.js on lines 163..176

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

                  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 insertedPane = function (context, subject, paneName) {
                          var p = context.session.paneRegistry.byName(paneName)
                          var d = p.render(subject, context)
                          d.setAttribute('style', 'border: 0.1em solid green;')
                          return d
                  Severity: Major
                  Found in src/transaction/period.js and 1 other location - About 1 hr to fix
                  src/transaction/pane.js on lines 129..134

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

                  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 (s.indexOf('.') >= 0) {
                            return s.split('.')[0] + '.' + (s.split('.')[1] + '00').slice(0, 2)
                          }
                  Severity: Major
                  Found in src/transaction/period.js and 1 other location - About 1 hr to fix
                  src/transaction/pane.js on lines 95..97

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

                  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

                          for (var i = 0; i < list2.length; i++) {
                            table.appendChild(transactionRow(dom, list2[i]))
                          }
                  Severity: Minor
                  Found in src/transaction/period.js and 1 other location - About 35 mins to fix
                  src/transaction/pane.js on lines 235..237

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

                  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