Showing 7 of 7 total issues
File base.js
has 255 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
var _ = require('lodash');
var utils = require('./utils');
/**
* Base
Function Base
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
var Base = function Base(condition, negate) {
// Set up flags
var self = this;
this.flags = {
not: false,
Function _chain
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Open
Indeed.prototype._chain = function(name, condition, join, negate) {
// Get the list of current calls.
// This will be something like ['indeed', 'and', 'and'] or ['either', 'or'].
var calls = this.calls;
- 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
Consider simplifying this complex logical expression. Open
Open
if (!grammaticallyCorrect || (allow.list.length === 1 && calls.length === 2 && !allow.chain) || (calls.length === 1 && calls[0] === name)) {
// If exceeded length is the reason we're throwing, display the pair (e.g. "and" cannot be chained with "neither/nor");
// otherwise, just display the original call (e.g. "either" cannot be chained with "indeed")
var display = (allow.list.length === 1 && calls.length === 2 && !allow.chain) ? calls[0] + '/' + calls[1] : calls[0];
throw new Error('IllegalMethodException: "' + name + '" cannot be chained with "' + display + '"');
Function throws
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
Expect.prototype.throws = function (exception) {
var self = this;
return this._compare(function(fn) {
if (typeof fn === 'function') {
try {
Function Expect
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
var Expect = function Expect (condition) {
var self = this;
Indeed.apply(this, arguments);
this.calls = ['expect'];
Function _testIllegalMethod
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
Base.prototype._testIllegalMethod = function(currentMethod, prevMethods, negate, condition) {
// If two methods have already been called, throw an exception
if (this.current.length === 2) {
throw new Error('IllegalMethodException: "' + currentMethod + '" cannot be called with "' + prevMethods + '"');
} else {
- 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"