preceptorjs/taxi

View on GitHub
lib/comparison/blinkdiff.js

Summary

Maintainability
F
3 days
Test Coverage

Function compare has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

BlinkDiffComparison.prototype.compare = function (title, imageBlob, options) {

    var instance,
        diffPath, buildPath, approvedPath,
        result, passed, localOptions;
Severity: Minor
Found in lib/comparison/blinkdiff.js - About 2 hrs 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 compare has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

BlinkDiffComparison.prototype.compare = function (title, imageBlob, options) {

    var instance,
        diffPath, buildPath, approvedPath,
        result, passed, localOptions;
Severity: Minor
Found in lib/comparison/blinkdiff.js - About 1 hr to fix

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

BlinkDiffComparison.prototype._getApprovedImagePath = function (title, id) {
    var baseName = this._getBaseName(title, id || 1),
        folderName = this._getFolderName(),
        suffix = this._needsApprovedSuffix() ? '_approved' : '';

Severity: Major
Found in lib/comparison/blinkdiff.js and 2 other locations - About 3 hrs to fix
lib/comparison/blinkdiff.js on lines 243..249
lib/comparison/blinkdiff.js on lines 260..266

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 104.

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

BlinkDiffComparison.prototype._getBuildImagePath = function (title, id) {
    var baseName = this._getBaseName(title, id || 1),
        folderName = this._getFolderName(),
        suffix = this._needsBuildSuffix() ? '_build' : '';

Severity: Major
Found in lib/comparison/blinkdiff.js and 2 other locations - About 3 hrs to fix
lib/comparison/blinkdiff.js on lines 226..232
lib/comparison/blinkdiff.js on lines 260..266

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 104.

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

BlinkDiffComparison.prototype._getDiffImagePath = function (title, id) {
    var baseName = this._getBaseName(title, id || 1),
        folderName = this._getFolderName(),
        suffix = this._needsDiffSuffix() ? '_diff' : '';

Severity: Major
Found in lib/comparison/blinkdiff.js and 2 other locations - About 3 hrs to fix
lib/comparison/blinkdiff.js on lines 226..232
lib/comparison/blinkdiff.js on lines 243..249

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 104.

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

BlinkDiffComparison.prototype._needsApprovedSuffix = function () {
    var approvedPath = this.getApprovedPath(),
        buildPath = this.getBuildPath(),
        diffPath = this.getDiffPath();

Severity: Major
Found in lib/comparison/blinkdiff.js and 2 other locations - About 2 hrs to fix
lib/comparison/blinkdiff.js on lines 296..302
lib/comparison/blinkdiff.js on lines 314..320

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 77.

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

BlinkDiffComparison.prototype._needsDiffSuffix = function () {
    var approvedPath = this.getApprovedPath(),
        buildPath = this.getBuildPath(),
        diffPath = this.getDiffPath();

Severity: Major
Found in lib/comparison/blinkdiff.js and 2 other locations - About 2 hrs to fix
lib/comparison/blinkdiff.js on lines 278..284
lib/comparison/blinkdiff.js on lines 296..302

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 77.

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

BlinkDiffComparison.prototype._needsBuildSuffix = function () {
    var approvedPath = this.getApprovedPath(),
        buildPath = this.getBuildPath(),
        diffPath = this.getDiffPath();

Severity: Major
Found in lib/comparison/blinkdiff.js and 2 other locations - About 2 hrs to fix
lib/comparison/blinkdiff.js on lines 278..284
lib/comparison/blinkdiff.js on lines 314..320

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 77.

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

BlinkDiffComparison.prototype.shouldOutputOnSuccess = function () {

    var option = this.getDriver().getValue('blinkDiff.outputOnSuccess');

    if (option === undefined) {
Severity: Major
Found in lib/comparison/blinkdiff.js and 1 other location - About 1 hr to fix
lib/comparison/blinkdiff.js on lines 114..123

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 67.

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

BlinkDiffComparison.prototype.shouldFailOnDifference = function () {

    var option = this.getDriver().getValue('blinkDiff.failOnDifference');

    if (option === undefined) {
Severity: Major
Found in lib/comparison/blinkdiff.js and 1 other location - About 1 hr to fix
lib/comparison/blinkdiff.js on lines 97..106

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 67.

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

BlinkDiffComparison.prototype._logMethodCall = function (event) {
    event.target = 'BlinkDiffComparison';
    this._driver._logMethodCall(event);
};
Severity: Major
Found in lib/comparison/blinkdiff.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/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/screenshot.js on lines 39..42
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

BlinkDiffComparison.prototype.getDiffPath = function () {
    return this.getDriver().getValue('blinkDiff.diffPath') || this.getBuildPath();
};
Severity: Minor
Found in lib/comparison/blinkdiff.js and 1 other location - About 55 mins to fix
lib/comparison/blinkdiff.js on lines 173..175

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 53.

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

BlinkDiffComparison.prototype.getBuildPath = function () {
    return this.getDriver().getValue('blinkDiff.buildPath') || this.getApprovedPath();
};
Severity: Minor
Found in lib/comparison/blinkdiff.js and 1 other location - About 55 mins to fix
lib/comparison/blinkdiff.js on lines 183..185

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 53.

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

BlinkDiffComparison.prototype._requestJSON = function (method, path, body) {
    return this._driver._requestJSON(method, path, body);
};
Severity: Major
Found in lib/comparison/blinkdiff.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/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/screenshot.js on lines 56..58
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 3 locations. Consider refactoring.
Open

BlinkDiffComparison.prototype.shouldFailOnAdditions = function () {
    return !!this.getDriver().getValue('blinkDiff.failOnAdditions');
};
Severity: Minor
Found in lib/comparison/blinkdiff.js and 2 other locations - About 35 mins to fix
lib/comparison/blinkdiff.js on lines 131..133
lib/comparison/blinkdiff.js on lines 142..144

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 3 locations. Consider refactoring.
Open

BlinkDiffComparison.prototype.shouldBatchFailures = function () {
    return !!this.getDriver().getValue('blinkDiff.batchFailures');
};
Severity: Minor
Found in lib/comparison/blinkdiff.js and 2 other locations - About 35 mins to fix
lib/comparison/blinkdiff.js on lines 131..133
lib/comparison/blinkdiff.js on lines 152..154

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 3 locations. Consider refactoring.
Open

BlinkDiffComparison.prototype.shouldAutoApprove = function () {
    return !!this.getDriver().getValue('blinkDiff.autoApprove');
};
Severity: Minor
Found in lib/comparison/blinkdiff.js and 2 other locations - About 35 mins to fix
lib/comparison/blinkdiff.js on lines 142..144
lib/comparison/blinkdiff.js on lines 152..154

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