File tinytest.js
has 542 lines of code (exceeds 250 allowed). Consider refactoring. Open
import isEqual from "lodash.isequal";
/******************************************************************************/
/* TestCaseResults */
/******************************************************************************/
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;
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 };
- Read upRead up
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 };
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;
}
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;
- Read upRead up
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;
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 + "'");
- Read upRead up
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(
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 + "'");
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") {
- Read upRead up
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"