wearefine/fae

View on GitHub
app/assets/javascripts/fae/_tables.js

Summary

Maintainability
C
1 day
Test Coverage

File _tables.js has 251 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* global Fae, FCH, Cookies */

/**
 * Fae tables
 * @namespace tables
Severity: Minor
Found in app/assets/javascripts/fae/_tables.js - About 2 hrs to fix

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

      collapsibleTable: function() {
        var $collapsible = $('.collapsible');
        var $toggle = $('.collapsible-toggle');
    
        // If there's only one table, don't bother with collapsing everything
    Severity: Minor
    Found in app/assets/javascripts/fae/_tables.js - About 1 hr to fix

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

        sizeFixedHeader: function() {
          var $tables = $('.content table');
      
          var header_height = $('.js-content-header').outerHeight();
          if(FCH.large_down) {
      Severity: Minor
      Found in app/assets/javascripts/fae/_tables.js - About 1 hr to fix

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

          stickyTableHeader: function() {
            var $sticky_tables = $('.content table:not(.stuck-table)');
        
            // Add sticky psuedo tables after our main table to hold the fixed header
            $sticky_tables.each(function() {
        Severity: Minor
        Found in app/assets/javascripts/fae/_tables.js - About 1 hr to fix

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

            rowSorting: function() {
              $('.js-sort-row').sortable({
                items: 'tbody tr',
                opacity: 0.8,
                handle: ('.sortable-handle'),
          Severity: Minor
          Found in app/assets/javascripts/fae/_tables.js - About 1 hr to fix

            Function dateColumnSorting has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              dateColumnSorting: function() {
                $.tablesorter.addParser({
                  id: 'mmddyy',
                  is: function(s) {
                    // testing for ##-##-#### or ####-##-##, so it's not perfect; time can be included
            Severity: Minor
            Found in app/assets/javascripts/fae/_tables.js - About 1 hr 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 applyOffset has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                function applyOffset() {
                  var $this = $(this);
            
                  // If this is a collapsible item and the table is hidden, forget it
                  if($this.parent().hasClass('collapsible') && !$this.parent().hasClass('active')) {
            Severity: Minor
            Found in app/assets/javascripts/fae/_tables.js - About 1 hr to fix

              Function sizeFixedHeader has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                sizeFixedHeader: function() {
                  var $tables = $('.content table');
              
                  var header_height = $('.js-content-header').outerHeight();
                  if(FCH.large_down) {
              Severity: Minor
              Found in app/assets/javascripts/fae/_tables.js - About 45 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

              There are no issues that match your filters.

              Category
              Status