crossfilter/universe

View on GitHub
src/filters.js

Summary

Maintainability
F
5 days
Test Coverage

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

module.exports = function (service) {
  return {
    filter: filter,
    filterAll: filterAll,
    applyFilters: applyFilters,
Severity: Minor
Found in src/filters.js - About 1 day 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 299 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function (service) {
  return {
    filter: filter,
    filterAll: filterAll,
    applyFilters: applyFilters,
Severity: Major
Found in src/filters.js - About 1 day to fix

    File filters.js has 305 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    'use strict'
    
    var _ = require('./lodash')
    
    var expressions = require('./expressions')
    Severity: Minor
    Found in src/filters.js - About 3 hrs to fix

      Function makeFunction has 81 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        function makeFunction(obj, isAggregation) {
          var subGetters
      
          // Detect raw $data reference
          if (_.isString(obj)) {
      Severity: Major
      Found in src/filters.js - About 3 hrs to fix

        Function applyFilters has 61 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          function applyFilters(newFilters) {
            var ds = _.map(newFilters, function (fil, i) {
              var existing = service.filters[i]
              // Filters are the same, so no change is needed on this column
              if (fil === existing) {
        Severity: Major
        Found in src/filters.js - About 2 hrs to fix

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

            function buildFilterObject(fil, isRange, replace) {
              if (_.isUndefined(fil)) {
                return false
              }
              if (_.isFunction(fil)) {
          Severity: Minor
          Found in src/filters.js - About 1 hr to fix

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

                var ds = _.map(newFilters, function (fil, i) {
                  var existing = service.filters[i]
                  // Filters are the same, so no change is needed on this column
                  if (fil === existing) {
                    return Promise.resolve()
            Severity: Minor
            Found in src/filters.js - About 1 hr to fix

              Avoid too many return statements within this function.
              Open

                    return Promise.resolve(column.dimension.filterAll())
              Severity: Major
              Found in src/filters.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                      return function (d) {
                        return expressions.$and(d, function (d) {
                          return _.map(subGetters, function (getSub) {
                            return getSub(d)
                          })
                Severity: Major
                Found in src/filters.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

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

                    Avoid too many return statements within this function.
                    Open

                        return {
                          value: fil,
                          replace: replace,
                          type: 'exact',
                        }
                    Severity: Major
                    Found in src/filters.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                              return Promise.resolve(column.dimension.filterFunction(function (d) {
                                return fil.value.indexOf(d) > -1
                              }))
                      Severity: Major
                      Found in src/filters.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                return Promise.resolve(column.dimension.filterFunction(fil.function))
                        Severity: Major
                        Found in src/filters.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                  return function (d) {
                                    return _.map(subGetters, function (getSub) {
                                      return getSub(d)
                                    })
                                  }
                          Severity: Major
                          Found in src/filters.js - About 30 mins to fix

                            There are no issues that match your filters.

                            Category
                            Status