meteor/meteor

View on GitHub
packages/check/match.js

Summary

Maintainability
F
5 days
Test Coverage

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

const testSubtree = (value, pattern) => {

  // Match anything!
  if (pattern === Match.Any) {
    return false;
Severity: Minor
Found in packages/check/match.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 testSubtree has 197 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const testSubtree = (value, pattern) => {

  // Match anything!
  if (pattern === Match.Any) {
    return false;
Severity: Major
Found in packages/check/match.js - About 7 hrs to fix

    File match.js has 370 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    // XXX docs
    import { isPlainObject } from './isPlainObject';
    
    // Things we explicitly do NOT support:
    //    - heterogenous arrays
    Severity: Minor
    Found in packages/check/match.js - About 4 hrs to fix

      Avoid deeply nested control flow statements.
      Open

              if (result) {
                result.path = _prependPath(key, result.path);
                return result;
              }
      Severity: Major
      Found in packages/check/match.js - About 45 mins to fix

        Avoid too many return statements within this function.
        Open

            return {
              message: `Expected null, got ${stringForErrorMessage(value)}`,
              path: '',
            };
        Severity: Major
        Found in packages/check/match.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return false;
          Severity: Major
          Found in packages/check/match.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

              return EJSON.stringify(value);
            Severity: Major
            Found in packages/check/match.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                  return false;
              Severity: Major
              Found in packages/check/match.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                      return {
                        message: `Bad pattern: arrays must have one type element ${stringForErrorMessage(pattern)}`,
                        path: '',
                      };
                Severity: Major
                Found in packages/check/match.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                      return {
                        message: `Missing key '${keys[0]}'`,
                        path: '',
                      };
                  Severity: Major
                  Found in packages/check/match.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return result;
                    Severity: Major
                    Found in packages/check/match.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                          return {
                            message: 'Failed Match.Where validation',
                            path: '',
                          };
                      Severity: Major
                      Found in packages/check/match.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                              return false;
                        Severity: Major
                        Found in packages/check/match.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                  return result;
                          Severity: Major
                          Found in packages/check/match.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                  return false;
                            Severity: Major
                            Found in packages/check/match.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                        return result;
                              Severity: Major
                              Found in packages/check/match.js - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                      return false;
                                Severity: Major
                                Found in packages/check/match.js - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                      return {
                                        message: `Expected object, got ${typeof value}`,
                                        path: '',
                                      };
                                  Severity: Major
                                  Found in packages/check/match.js - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                          return {
                                            message: err.message,
                                            path: err.path
                                          };
                                    Severity: Major
                                    Found in packages/check/match.js - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                          return {
                                            message: `Expected object, got null`,
                                            path: '',
                                          };
                                      Severity: Major
                                      Found in packages/check/match.js - About 30 mins to fix

                                        Avoid too many return statements within this function.
                                        Open

                                                return result;
                                        Severity: Major
                                        Found in packages/check/match.js - About 30 mins to fix

                                          Avoid too many return statements within this function.
                                          Open

                                              return {
                                                message: `Expected ${pattern}, got ${stringForErrorMessage(value)}`,
                                                path: '',
                                              };
                                          Severity: Major
                                          Found in packages/check/match.js - About 30 mins to fix

                                            Avoid too many return statements within this function.
                                            Open

                                                return {
                                                  message: 'Failed Match.OneOf, Match.Maybe or Match.Optional validation',
                                                  path: '',
                                                };
                                            Severity: Major
                                            Found in packages/check/match.js - About 30 mins to fix

                                              Avoid too many return statements within this function.
                                              Open

                                                  return {
                                                    message: `Expected plain object`,
                                                    path: '',
                                                  };
                                              Severity: Major
                                              Found in packages/check/match.js - About 30 mins to fix

                                                Avoid too many return statements within this function.
                                                Open

                                                    return {
                                                      message: 'Bad pattern: unknown pattern type',
                                                      path: '',
                                                    };
                                                Severity: Major
                                                Found in packages/check/match.js - About 30 mins to fix

                                                  Avoid too many return statements within this function.
                                                  Open

                                                        return false;
                                                  Severity: Major
                                                  Found in packages/check/match.js - About 30 mins to fix

                                                    Avoid too many return statements within this function.
                                                    Open

                                                          return {
                                                            message: `Expected array, got ${stringForErrorMessage(value)}`,
                                                            path: '',
                                                          };
                                                    Severity: Major
                                                    Found in packages/check/match.js - About 30 mins to fix

                                                      Avoid too many return statements within this function.
                                                      Open

                                                          return {
                                                            message: `Expected ${pattern.name || 'particular constructor'}`,
                                                            path: '',
                                                          };
                                                      Severity: Major
                                                      Found in packages/check/match.js - About 30 mins to fix

                                                        Avoid too many return statements within this function.
                                                        Open

                                                            return {
                                                              message: `Expected Integer, got ${stringForErrorMessage(value)}`,
                                                              path: '',
                                                            };
                                                        Severity: Major
                                                        Found in packages/check/match.js - About 30 mins to fix

                                                          Avoid too many return statements within this function.
                                                          Open

                                                                  return {
                                                                    message: 'Unknown key',
                                                                    path: key,
                                                                  };
                                                          Severity: Major
                                                          Found in packages/check/match.js - About 30 mins to fix

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

                                                            const stringForErrorMessage = (value, options = {}) => {
                                                              if ( value === null ) {
                                                                return 'null';
                                                              }
                                                            
                                                            
                                                            Severity: Minor
                                                            Found in packages/check/match.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

                                                            There are no issues that match your filters.

                                                            Category
                                                            Status