meteor/meteor

View on GitHub
packages/tinytest/tinytest.js

Summary

Maintainability
D
3 days
Test Coverage

File tinytest.js has 542 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import isEqual from "lodash.isequal";

/******************************************************************************/
/* TestCaseResults                                                            */
/******************************************************************************/
Severity: Major
Found in packages/tinytest/tinytest.js - About 1 day to fix

    TestCaseResults has 28 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export class TestCaseResults {
      constructor(test_case, onEvent, onException, stop_at_offset) {
        this.test_case = test_case;
        this.onEvent = onEvent;
        this.expecting_failure = false;
    Severity: Minor
    Found in packages/tinytest/tinytest.js - About 3 hrs to fix

      Function fail has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

        fail(doc) {
          if (typeof doc === "string") {
            // Some very old code still tries to call fail() with a
            // string. Don't do this!
            doc = { type: "fail", message: doc };
      Severity: Minor
      Found in packages/tinytest/tinytest.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 fail has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        fail(doc) {
          if (typeof doc === "string") {
            // Some very old code still tries to call fail() with a
            // string. Don't do this!
            doc = { type: "fail", message: doc };
      Severity: Minor
      Found in packages/tinytest/tinytest.js - About 1 hr to fix

        Function _runOne has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          _runOne(test, onComplete, stop_at_offset) {
            if (! this._prefixMatch(test.groupPath)) {
              onComplete && onComplete();
              return;
            }
        Severity: Minor
        Found in packages/tinytest/tinytest.js - About 1 hr to fix

          Function equal has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

            equal(actual, expected, message, not) {
              if ((! not) && (typeof actual === 'string') &&
                  (typeof expected === 'string')) {
                this._stringEqual(actual, expected, message);
                return;
          Severity: Minor
          Found in packages/tinytest/tinytest.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 equal has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            equal(actual, expected, message, not) {
              if ((! not) && (typeof actual === 'string') &&
                  (typeof expected === 'string')) {
                this._stringEqual(actual, expected, message);
                return;
          Severity: Minor
          Found in packages/tinytest/tinytest.js - About 1 hr to fix

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

              addCase(test, options = {}) {
                if (test.name in this.tests)
                  throw new Error(
                    "Every test needs a unique name, but there are two tests named '" +
                      test.name + "'");
            Severity: Minor
            Found in packages/tinytest/tinytest.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 run has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              run(onEvent, onComplete, onException, stop_at_offset) {
                let completed = false;
            
                return new Promise((resolve, reject) => {
                  const results = new TestCaseResults(
            Severity: Minor
            Found in packages/tinytest/tinytest.js - About 1 hr to fix

              Function addCase has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                addCase(test, options = {}) {
                  if (test.name in this.tests)
                    throw new Error(
                      "Every test needs a unique name, but there are two tests named '" +
                        test.name + "'");
              Severity: Minor
              Found in packages/tinytest/tinytest.js - About 1 hr to fix

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

                  include(s, v, message, not) {
                    var pass = false;
                    if (s instanceof Array) {
                      pass = s.some(it => isEqual(v, it));
                    } else if (s && typeof s === "object") {
                Severity: Minor
                Found in packages/tinytest/tinytest.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