tandrewnichols/indeed

View on GitHub

Showing 7 of 7 total issues

File base.js has 255 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var _ = require('lodash');
var utils = require('./utils');

/**
 * Base
Severity: Minor
Found in lib/base.js - About 2 hrs to fix

    Function Base has 47 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    var Base = function Base(condition, negate) {
      // Set up flags
      var self = this;
      this.flags = {
        not: false,
    Severity: Minor
    Found in lib/base.js - About 1 hr to fix

      Function _chain has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      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;
      
      
      Severity: Minor
      Found in lib/indeed.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

      Consider simplifying this complex logical expression.
      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 + '"');
      Severity: Critical
      Found in lib/indeed.js - About 1 hr to fix

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

        Expect.prototype.throws = function (exception) {
          var self = this;
          return this._compare(function(fn) {
            if (typeof fn === 'function') {
              try {
        Severity: Minor
        Found in lib/expect.js - About 1 hr to fix

          Function Expect has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          var Expect = function Expect (condition) {
            var self = this;
            Indeed.apply(this, arguments);
            this.calls = ['expect'];
          
          
          Severity: Minor
          Found in lib/expect.js - About 1 hr to fix

            Function _testIllegalMethod has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            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 {
            Severity: Minor
            Found in lib/base.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

            Severity
            Category
            Status
            Source
            Language