grommet/grommet-ferret

View on GitHub
server/filter.js

Summary

Maintainability
F
3 days
Test Coverage

Function Expression has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
Open

function Expression () {

  this.op = (op) => {
    if (! this._op) {
      this._op = op;
Severity: Minor
Found in server/filter.js - About 6 hrs 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

File filter.js has 386 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// (C) Copyright 2014-2015 Hewlett Packard Enterprise Development LP

const TRACE_PARSING = false;
const TRACE_MATCHING = false;

Severity: Minor
Found in server/filter.js - About 5 hrs to fix

    Function alphanum has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

    function alphanum (a, b) {
      function chunkify(t) {
        var tz = [],
          x = 0,
          y = -1,
    Severity: Minor
    Found in server/filter.js - About 2 hrs 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 Expression has 70 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function Expression () {
    
      this.op = (op) => {
        if (! this._op) {
          this._op = op;
    Severity: Major
    Found in server/filter.js - About 2 hrs to fix

      Function TextTerm has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function TextTerm (text) {
        this._not = false;
        this._text = text;
      
        // if the string is quoted, require matching at both ends
      Severity: Minor
      Found in server/filter.js - About 1 hr to fix

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

        function AttributeTerm (text) {
          this._not = false;
        
          const parts = text.toLowerCase().split(':');
          this._name = parts[0];
        Severity: Minor
        Found in server/filter.js - About 1 hr to fix

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

          function alphanum (a, b) {
            function chunkify(t) {
              var tz = [],
                x = 0,
                y = -1,
          Severity: Minor
          Found in server/filter.js - About 1 hr to fix

            Function AttributeTerm has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

            function AttributeTerm (text) {
              this._not = false;
            
              const parts = text.toLowerCase().split(':');
              this._name = parts[0];
            Severity: Minor
            Found in server/filter.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 TextTerm has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

            function TextTerm (text) {
              this._not = false;
              this._text = text;
            
              // if the string is quoted, require matching at both ends
            Severity: Minor
            Found in server/filter.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 filterUserQuery has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export function filterUserQuery (items, userQuery) {
              // handle quoted strings, e.g. 'a b' c "d e"
              const regexp = /'([^']+)'|"([^"]+)"|(\w+)/g;
              let matches;
              let terms = [];
            Severity: Minor
            Found in server/filter.js - About 1 hr to fix

              Function parseQuery has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              function parseQuery (query) {
              
                const parsers = [
                  parseSpace,
                  parseParens,
              Severity: Minor
              Found in server/filter.js - About 25 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

              Function filterFilter has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              export function filterFilter (items, filterParam) {
                // convert filter to something more useful for comparison
                let filter = {};
                (typeof filterParam === 'string' ? [filterParam] : filterParam)
                  .forEach((term) => {
              Severity: Minor
              Found in server/filter.js - About 25 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

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

              function parseAnd (text, expression) {
                let result = 0;
                if ('AND' === text.slice(0, 3)) {
                  traceParsing('--and--');
                  result = 3;
              Severity: Major
              Found in server/filter.js and 1 other location - About 1 hr to fix
              server/filter.js on lines 285..293

              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

              function parseOr (text, expression) {
                let result = 0;
                if ('OR' === text.slice(0, 2)) {
                  traceParsing('--or--');
                  result = 2;
              Severity: Major
              Found in server/filter.js and 1 other location - About 1 hr to fix
              server/filter.js on lines 275..283

              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