preceptorjs/taxi

View on GitHub
lib/helpers/screenshot.js

Summary

Maintainability
F
4 days
Test Coverage

File screenshot.js has 426 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

var logMethods = require('../log');
var type = require('../type');
var when = require('../when');
Severity: Minor
Found in lib/helpers/screenshot.js - About 6 hrs to fix

Function _gatherSections has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Screenshot.prototype._gatherSections = function (area, padding, initData, maxImageResolution, needsStitching) {

    var sections = [], section,
        sectionCount, sectionHeight,
        i, index = 0,
Severity: Minor
Found in lib/helpers/screenshot.js - About 1 hr to fix

Function _takeScreenshot has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Screenshot.prototype._takeScreenshot = function (fn, options) {

    var DevicePixelRatio = require('./devicePixelRatio'),
        devicePixelRatio = new DevicePixelRatio(this.getDriver()),

Severity: Minor
Found in lib/helpers/screenshot.js - About 1 hr to fix

Function _determineBlockOuts has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Screenshot.prototype._determineBlockOuts = function (area, context, blockOuts, blockOutColor) {

    var defaultColor = blockOutColor || { red: 0, green: 0, blue: 0 };

    return when(this.getDriver().utils().map(blockOuts, function (blockOutEl) {
Severity: Minor
Found in lib/helpers/screenshot.js - About 1 hr to fix

Function _browserPadding has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Screenshot.prototype._browserPadding = function (padding) {

    var paddingViewPortTop = 0, paddingViewPortBottom = 0,
        paddingViewPortLeft = 0, paddingViewPortRight = 0,
        paddingScreenshotTop = 0, paddingScreenshotBottom = 0,
Severity: Minor
Found in lib/helpers/screenshot.js - About 1 hr to fix

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 _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 _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 _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

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

Screenshot.prototype.areaScreenshot = function (x, y, width, height, options) {
Severity: Minor
Found in lib/helpers/screenshot.js - About 35 mins to fix

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

Screenshot.prototype._gatherSections = function (area, padding, initData, maxImageResolution, needsStitching) {
Severity: Minor
Found in lib/helpers/screenshot.js - About 35 mins to fix

Similar blocks of code found in 3 locations. Consider refactoring.
Open

Screenshot.prototype._execute = function (script, args) {
    if (script) {
        return this.getDriver().browser().activeWindow().execute(script, args);

    } else { // Ignore script if there is nothing - might happen with screenshot requests
Severity: Major
Found in lib/helpers/screenshot.js and 2 other locations - About 3 hrs to fix
lib/helpers/devicePixelRatio.js on lines 159..166
lib/helpers/stitching.js on lines 194..201

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 95.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    if (item.x < area.x) {
        item.width -= Math.abs(item.x - area.x);
        item.x = area.x;
    }
Severity: Major
Found in lib/helpers/screenshot.js and 1 other location - About 1 hr to fix
lib/helpers/screenshot.js on lines 310..313

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 65.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    if (item.y < area.y) {
        item.height -= Math.abs(item.y - area.y);
        item.y = area.y;
    }
Severity: Major
Found in lib/helpers/screenshot.js and 1 other location - About 1 hr to fix
lib/helpers/screenshot.js on lines 301..304

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 65.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    if (item.x > area.x + area.width) {
        item.x = area.x + area.width;
        item.width = 0;
    }
Severity: Major
Found in lib/helpers/screenshot.js and 1 other location - About 1 hr to fix
lib/helpers/screenshot.js on lines 314..317

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 61.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    if (item.y > area.y + area.height) {
        item.y = area.y + area.height;
        item.height = 0;
    }
Severity: Major
Found in lib/helpers/screenshot.js and 1 other location - About 1 hr to fix
lib/helpers/screenshot.js on lines 305..308

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 61.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    if (area.x + area.width > initData.document.width) {
        area.width = initData.document.width - area.x;
    }
Severity: Major
Found in lib/helpers/screenshot.js and 1 other location - About 1 hr to fix
lib/helpers/screenshot.js on lines 589..591

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 58.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    if (area.y + area.height > initData.document.height) {
        area.height = initData.document.height - area.y;
    }
Severity: Major
Found in lib/helpers/screenshot.js and 1 other location - About 1 hr to fix
lib/helpers/screenshot.js on lines 586..588

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 58.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 23 locations. Consider refactoring.
Open

Screenshot.prototype._logMethodCall = function (event) {
    event.target = 'Screenshot';
    this._driver._logMethodCall(event);
};
Severity: Major
Found in lib/helpers/screenshot.js and 22 other locations - About 55 mins to fix
lib/alert.js on lines 35..38
lib/browser.js on lines 40..43
lib/chain.js on lines 74..77
lib/comparison/blinkdiff.js on lines 43..46
lib/compatibility.js on lines 35..38
lib/compatibility/nightwatch.js on lines 35..38
lib/cookieStorage.js on lines 39..42
lib/frame.js on lines 34..37
lib/globalMouse.js on lines 36..39
lib/globalTouch.js on lines 33..36
lib/helpers/comparison.js on lines 40..43
lib/helpers/devicePixelRatio.js on lines 38..41
lib/helpers/stitching.js on lines 38..41
lib/ime.js on lines 33..36
lib/localStorage.js on lines 33..36
lib/mouse.js on lines 68..71
lib/navigator.js on lines 34..37
lib/sessionStorage.js on lines 33..36
lib/timeOut.js on lines 80..83
lib/touch.js on lines 36..39
lib/utils.js on lines 36..39
lib/window.js on lines 36..39

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 54.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        return {
            x: initData.viewPort.x,
            y: initData.viewPort.y,
            width: initData.viewPort.width,
            height: initData.viewPort.height
Severity: Minor
Found in lib/helpers/screenshot.js and 1 other location - About 55 mins to fix
lib/scripts/structure.js on lines 16..21

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 54.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

        viewPortWidth = initData.viewPort.width - padding.viewPort.left - padding.viewPort.right - padding.screenshot.right,
Severity: Major
Found in lib/helpers/screenshot.js and 2 other locations - About 40 mins to fix
lib/helpers/screenshot.js on lines 626..626
lib/helpers/screenshot.js on lines 712..712

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 49.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

        viewPortHeight = initData.viewPort.height - padding.viewPort.top - padding.viewPort.bottom - padding.screenshot.bottom;
Severity: Major
Found in lib/helpers/screenshot.js and 2 other locations - About 40 mins to fix
lib/helpers/screenshot.js on lines 711..711
lib/helpers/screenshot.js on lines 712..712

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 49.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

        viewPortHeight = initData.viewPort.height - padding.viewPort.top - padding.viewPort.bottom - padding.screenshot.bottom,
Severity: Major
Found in lib/helpers/screenshot.js and 2 other locations - About 40 mins to fix
lib/helpers/screenshot.js on lines 626..626
lib/helpers/screenshot.js on lines 711..711

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 49.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 14 locations. Consider refactoring.
Open

Screenshot.prototype._requestJSON = function (method, path, body) {
    return this._driver._requestJSON(method, path, body);
};
Severity: Major
Found in lib/helpers/screenshot.js and 13 other locations - About 35 mins to fix
lib/alert.js on lines 52..54
lib/browser.js on lines 56..58
lib/chain.js on lines 91..93
lib/comparison/blinkdiff.js on lines 60..62
lib/compatibility.js on lines 52..54
lib/compatibility/nightwatch.js on lines 52..54
lib/globalMouse.js on lines 53..55
lib/helpers/comparison.js on lines 57..59
lib/helpers/devicePixelRatio.js on lines 55..57
lib/helpers/stitching.js on lines 55..57
lib/mouse.js on lines 85..87
lib/navigator.js on lines 51..53
lib/utils.js on lines 53..55

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 47.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    if (area.y >= initData.document.height) {
        area.y = initData.document.height - 1;
    }
Severity: Minor
Found in lib/helpers/screenshot.js and 1 other location - About 35 mins to fix
lib/helpers/screenshot.js on lines 576..578

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 46.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    if (area.x >= initData.document.width) {
        area.x = initData.document.width - 1;
    }
Severity: Minor
Found in lib/helpers/screenshot.js and 1 other location - About 35 mins to fix
lib/helpers/screenshot.js on lines 582..584

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 46.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

There are no issues that match your filters.

Category
Status