yahoo/blink-diff

View on GitHub

Showing 88 of 88 total issues

Function convertToPerceptual has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        convertToPerceptual: function () {

            var i, len,
                data,
                pixelList,
Severity: Minor
Found in lib/image.js - About 1 hr to fix

Function _loadImage has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        _loadImage: function (blob) {

            var decoder,
                data,
                headerChunk,
Severity: Minor
Found in lib/configuration/image.js - About 1 hr to fix

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

        compare: function (comparison, flagField) {

            var flagFieldIndexA, dataIndexA,
                flagFieldIndexB, dataIndexB,
                x, y, delta,
Severity: Minor
Found in lib/pixelComparator.js - About 1 hr to fix

Function loadDOMNode has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        function loadDOMNode (inputNode, parentNode) {

            var nodes, length, offset, newNode;

            if (capturedTags.indexOf(inputNode.tagName) !== -1) {
Severity: Minor
Found in lib/scripts/structure.js - About 1 hr to fix

Function _compare has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    _compare: function (imageA, imageB, imageOutput, deltaThreshold, outputMaskColor, outputShiftColor, backgroundColor, hShift, vShift, perceptual, gamma) {

        var result = {
            code: BlinkDiff.RESULT_UNKNOWN,
            differences: undefined,
Severity: Minor
Found in index.js - About 1 hr to fix

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

            color = {
                red: this._blockOutRed,
                green: this._blockOutGreen,
                blue: this._blockOutBlue,
                alpha: this._blockOutAlpha,
Severity: Major
Found in index.js and 1 other location - About 1 hr to fix
index.js on lines 396..402

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

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

Consider simplifying this complex logical expression.
Open

            if (this._gamma || this._gammaR || this._gammaG || this._gammaB) {
                gamma = {
                    r: this._gammaR || this._gamma, g: this._gammaG || this._gamma, b: this._gammaB || this._gamma
                };
            }
Severity: Major
Found in index.js - About 1 hr to fix

Function _shiftCompare has 8 arguments (exceeds 4 allowed). Consider refactoring.
Open

        _shiftCompare: function (x, y, colorIndex, comparison, imageSrc, areaSrc, imageDst, areaDst) {
Severity: Major
Found in lib/pixelComparator.js - About 1 hr to fix

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

            color = {
                red: this._blockOutRed,
                green: this._blockOutGreen,
                blue: this._blockOutBlue,
                alpha: this._blockOutAlpha,
Severity: Major
Found in index.js and 1 other location - About 1 hr to fix
index.js on lines 523..529

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

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

Consider simplifying this complex logical expression.
Open

            if (this._gamma || this._gammaR || this._gammaG || this._gammaB) {
                gamma = {
                    r: this._gammaR || this._gamma, g: this._gammaG || this._gamma, b: this._gammaB || this._gamma
                };
            }
Severity: Major
Found in index.js - About 1 hr to fix

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

                    data[i + 2] = 255 * ((pixelList[i + 2] - bounds[2].min) / bounds[2].max);
Severity: Minor
Found in lib/image.js and 1 other location - About 50 mins to fix
lib/image.js on lines 192..192

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

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

        } else {
            this.log("Images are similar");
            this.log(result.differences + " pixels are different");
            result.code = BlinkDiff.RESULT_SIMILAR;
            return result;
Severity: Minor
Found in index.js and 1 other location - About 50 mins to fix
index.js on lines 1199..1205

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

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

        } else if (this.isAboveThreshold(result.differences, result.dimension)) {
            this.log("Images are visibly different");
            this.log(result.differences + " pixels are different");
            result.code = BlinkDiff.RESULT_DIFFERENT;
            return result;
Severity: Minor
Found in index.js and 1 other location - About 50 mins to fix
index.js on lines 1205..1210

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

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

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

        PNGImage.log = function (text) {
            this.log('ERROR: ' + text);
            throw new Error('ERROR: ' + text);
        }.bind(this);
Severity: Minor
Found in index.js and 1 other location - About 50 mins to fix
index.js on lines 489..492

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

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

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

        PNGImage.log = function (text) {
            this.log('ERROR: ' + text);
            throw new Error('ERROR: ' + text);
        }.bind(this);
Severity: Minor
Found in index.js and 1 other location - About 50 mins to fix
index.js on lines 353..356

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

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

                    data[i + 1] = 255 * ((pixelList[i + 1] - bounds[1].min) / bounds[1].max);
Severity: Minor
Found in lib/image.js and 1 other location - About 50 mins to fix
lib/image.js on lines 193..193

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

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

Avoid deeply nested control flow statements.
Open

                            if ((Math.abs(delta - localDeltaThreshold) < deltaThreshold) &&
                                (localDeltaThreshold > deltaThreshold)) {
                                return true;
                            }
Severity: Major
Found in lib/pixelComparator.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                        if ((Math.abs(delta - localDeltaThreshold) < deltaThreshold) && (localDeltaThreshold > deltaThreshold)) {
                            return true;
                        }
Severity: Major
Found in index.js - About 45 mins to fix

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

        getSelector: function (suffix) {

            var id = this.getId(),
                tagName = this.getTagName(),
                classes = this.getClasses(),
Severity: Minor
Found in lib/configuration/structure/domElement.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

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

            if (this.shouldCopyImageA()) {
                imageA.getImage().bitblt(imageOutput.getImage(), 0, 0, imageA.getWidth(), imageA.getHeight(), 0, 0);

            } else if (this.shouldCopyImageB()) {
                imageB.getImage().bitblt(imageOutput.getImage(), 0, 0, imageB.getWidth(), imageB.getHeight(), 0, 0);
Severity: Minor
Found in lib/configuration/output.js and 1 other location - About 40 mins to fix
lib/configuration/output.js on lines 317..319

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

Severity
Category
Status
Source
Language