preceptorjs/taxi

View on GitHub

Showing 53 of 286 total issues

Function type has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

function type (val) {
  switch (Object.prototype.toString.call(val)) {
    case '[object Date]':
      return 'Date';
    case '[object RegExp]':
Severity: Minor
Found in lib/type.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 _reduceRectItemToArea has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Screenshot.prototype._reduceRectItemToArea = function (item, area) {

    if (item.x < area.x) {
        item.width -= Math.abs(item.x - area.x);
        item.x = area.x;
Severity: Minor
Found in lib/helpers/screenshot.js - About 1 hr to fix

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

function logMethod (name, method) {
  var result = function () {
    var args = Array.prototype.slice.call(arguments);
    var event = {
      name: name,
Severity: Minor
Found in lib/log.js - About 1 hr to fix

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

        function deviceInfo () {
            return {
                userAgent: window.navigator.userAgent,

                app: {
Severity: Minor
Found in lib/scripts/structure.js - About 1 hr to fix

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

Screenshot.prototype._stitchImages = function (area, sections, devicePixelRatio) {

    var image;

    image = PNGImage.createImage(
Severity: Minor
Found in lib/helpers/screenshot.js - About 1 hr to fix

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

Screenshot.prototype._gatherViewPortSections = function (section, padding, initData, index) {

    var viewPorts = [],

        sectionWidth = section.width,
Severity: Minor
Found in lib/helpers/screenshot.js - About 1 hr to fix

Function saveScreenshot has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

ActiveWindow.prototype.saveScreenshot = function (path, options) {
  return when(this.captureDocument(options), function (buffer) {
    if (this._driver.isSync()) {
      fs.writeFileSync(path, buffer);
    } else {
Severity: Minor
Found in lib/activeWindow.js - About 55 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

Function compareArea has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

Chain.prototype.compareArea = function (title, x, y, width, height, options, callBack) {
Severity: Major
Found in lib/chain.js - About 50 mins to fix

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

    init: function (needsStitching) {

        var initData = {
                viewPort: {},
                document: {},
Severity: Minor
Found in lib/scripts/screenshot.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

Function drawRect has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

        function drawRect (image, x, y, width, height, color) {
Severity: Minor
Found in examples/structure.js - About 45 mins to fix

Function compareArea has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

ActiveWindow.prototype.compareArea = function (title, x, y, width, height, options) {
Severity: Minor
Found in lib/activeWindow.js - About 45 mins to fix

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

Screenshot.prototype._reduceRectItemToArea = function (item, area) {

    if (item.x < area.x) {
        item.width -= Math.abs(item.x - area.x);
        item.x = area.x;
Severity: Minor
Found in lib/helpers/screenshot.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

Function captureArea has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

Chain.prototype.captureArea = function (x, y, width, height, options, callBack) {
Severity: Minor
Found in lib/chain.js - About 45 mins to fix

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

Screenshot.prototype._validateArea = function (area, padding, initData) {

    if (area.width < 0) {
        throw new Error('Width of area to capture cannot be negative.');
    }
Severity: Minor
Found in lib/helpers/screenshot.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

Consider simplifying this complex logical expression.
Open

  } else if (res.statusCode >= 500 && res.statusCode < 600) { // 500s
    body = JSON.parse(res.body);

    hasScreenshot = body && body.value && body.value.screen;
    hasLogFolder = this._options && this._options.logDir;
Severity: Major
Found in lib/connection.js - About 40 mins to fix

Function parsedRequest has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

Connection.prototype.parsedRequest = function (session, method, path, options, retryCounter) {
Severity: Minor
Found in lib/connection.js - About 35 mins to fix

Function captureArea has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

ActiveWindow.prototype.captureArea = function (x, y, width, height, options) {
Severity: Minor
Found in lib/activeWindow.js - About 35 mins to fix

Function waitForElementVisible has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

Nightwatch.prototype.waitForElementVisible = function (selector, time, abortOnFailure, cb, message) {
Severity: Minor
Found in lib/compatibility/nightwatch.js - About 35 mins to fix

Function elementClickAt has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

Chain.prototype.elementClickAt = function (selector, xOffset, yOffset, button, callBack) {
Severity: Minor
Found in lib/chain.js - About 35 mins to fix

Function waitUntil has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

Utils.prototype.waitUntil = function (fn, timeOut, wait, message, timeOutFn) {
Severity: Minor
Found in lib/utils.js - About 35 mins to fix
Severity
Category
Status
Source
Language