yahoo/pngjs-image

View on GitHub

Showing 322 of 322 total issues

Function getBlurPixelAtIndex has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    getBlurPixelAtIndex: function (idx, funcName) {

        var colors = 0,
            colorCounter = 0,
            fn,
Severity: Minor
Found in lib/conversion.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 finalizeDecode has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    finalizeDecode: function (image, strict, options) {

        var i, len,
            imageStream, outputStream,
            r, g, b, a,
Severity: Minor
Found in lib/png/chunks/gAMA.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 _determineWriter has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Normalizer.prototype._determineWriter = function () {

    var headerChunk = this.getHeaderChunk(),
        isColor, hasAlpha, isIndexed,
        result = null;
Severity: Minor
Found in lib/png/processor/normalizer.js - About 1 hr to fix

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

            it('should set red color', function () {
                this.instance.setAtIndex(0, {red: 1});
                expect(this.blob[0]).to.be.equal(1);
            });
Severity: Major
Found in test/tests.js and 3 other locations - About 1 hr to fix
test/tests.js on lines 497..500
test/tests.js on lines 507..510
test/tests.js on lines 517..520

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

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

            it('should set blue color', function () {
                this.instance.setAtIndex(0, {blue: 3});
                expect(this.blob[2]).to.be.equal(3);
            });
Severity: Major
Found in test/tests.js and 3 other locations - About 1 hr to fix
test/tests.js on lines 487..490
test/tests.js on lines 497..500
test/tests.js on lines 517..520

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

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

            it('should set green color', function () {
                this.instance.setAtIndex(1, {green: 2});
                expect(this.blob[5]).to.be.equal(2);
            });
Severity: Major
Found in test/tests.js and 3 other locations - About 1 hr to fix
test/tests.js on lines 487..490
test/tests.js on lines 507..510
test/tests.js on lines 517..520

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

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

            it('should set alpha value', function () {
                this.instance.setAtIndex(0, {alpha: 4});
                expect(this.blob[3]).to.be.equal(4);
            });
Severity: Major
Found in test/tests.js and 3 other locations - About 1 hr to fix
test/tests.js on lines 487..490
test/tests.js on lines 497..500
test/tests.js on lines 507..510

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

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

Function postDecode has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    postDecode: function (image, strict, options) {

        var i, len, index, alpha,
            color, colors, colorsLength,
            imageStream, outputStream,
Severity: Minor
Found in lib/png/chunks/PLTE.js - About 1 hr to fix

Function postDecode has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    postDecode: function (image, strict, options) {

        var i, len,
            imageStream, outputStream,
            backgroundColor,
Severity: Minor
Found in lib/png/chunks/bKGD.js - About 1 hr to fix

Function _parse1bit has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Parser.prototype._parse1bit = function (paddingAt) {

    var byteCounter = 0;

    return function (value, output) {
Severity: Minor
Found in lib/png/processor/parser.js - About 1 hr to fix

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

                        if (options.interlace !== undefined) {
                            it('should have the correct interlace method', function () {
                                expect(this.header.interlace).to.be.equal(options.interlace);
                            });
                        }
Severity: Major
Found in test/png/testGen.js and 4 other locations - About 1 hr to fix
test/png/testGen.js on lines 98..102
test/png/testGen.js on lines 104..108
test/png/testGen.js on lines 110..114
test/png/testGen.js on lines 116..120

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

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

                        if (options.compression !== undefined) {
                            it('should have the correct compression method', function () {
                                expect(this.header.compression).to.be.equal(options.compression);
                            });
                        }
Severity: Major
Found in test/png/testGen.js and 4 other locations - About 1 hr to fix
test/png/testGen.js on lines 98..102
test/png/testGen.js on lines 104..108
test/png/testGen.js on lines 110..114
test/png/testGen.js on lines 122..126

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

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

        it('should apply grayScale filter', function () {
            this.instance.applyFilters("grayScale");
            expect(this.instance.getRed(0)).to.be.equal(25);
        });
Severity: Major
Found in test/tests.js and 5 other locations - About 1 hr to fix
test/tests.js on lines 696..699
test/tests.js on lines 706..709
test/tests.js on lines 711..714
test/tests.js on lines 716..719
test/tests.js on lines 721..724

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

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

                        if (options.filter !== undefined) {
                            it('should have the correct filter method', function () {
                                expect(this.header.filter).to.be.equal(options.filter);
                            });
                        }
Severity: Major
Found in test/png/testGen.js and 4 other locations - About 1 hr to fix
test/png/testGen.js on lines 98..102
test/png/testGen.js on lines 104..108
test/png/testGen.js on lines 116..120
test/png/testGen.js on lines 122..126

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

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

        it('should apply luma filter', function () {
            this.instance.applyFilters("luma");
            expect(this.instance.getRed(0)).to.be.equal(22);
        });
Severity: Major
Found in test/tests.js and 5 other locations - About 1 hr to fix
test/tests.js on lines 696..699
test/tests.js on lines 701..704
test/tests.js on lines 706..709
test/tests.js on lines 716..719
test/tests.js on lines 721..724

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

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

        it('should apply lightness filter', function () {
            this.instance.applyFilters("lightness");
            expect(this.instance.getRed(0)).to.be.equal(27);
        });
Severity: Major
Found in test/tests.js and 5 other locations - About 1 hr to fix
test/tests.js on lines 696..699
test/tests.js on lines 701..704
test/tests.js on lines 711..714
test/tests.js on lines 716..719
test/tests.js on lines 721..724

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

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

        it('should apply luminosity filter', function () {
            this.instance.applyFilters("luminosity");
            expect(this.instance.getRed(0)).to.be.equal(22);
        });
Severity: Major
Found in test/tests.js and 5 other locations - About 1 hr to fix
test/tests.js on lines 696..699
test/tests.js on lines 701..704
test/tests.js on lines 706..709
test/tests.js on lines 711..714
test/tests.js on lines 721..724

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

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

        it('should apply blur filter', function () {
            this.instance.applyFilters("blur");
            expect(this.instance.getRed(0)).to.be.equal(88);
        });
Severity: Major
Found in test/tests.js and 5 other locations - About 1 hr to fix
test/tests.js on lines 701..704
test/tests.js on lines 706..709
test/tests.js on lines 711..714
test/tests.js on lines 716..719
test/tests.js on lines 721..724

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

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

        it('should apply sepia filter', function () {
            this.instance.applyFilters("sepia");
            expect(this.instance.getRed(0)).to.be.equal(30);
        });
Severity: Major
Found in test/tests.js and 5 other locations - About 1 hr to fix
test/tests.js on lines 696..699
test/tests.js on lines 701..704
test/tests.js on lines 706..709
test/tests.js on lines 711..714
test/tests.js on lines 716..719

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

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

                        if (options.colorType !== undefined) {
                            it('should have the correct color-type', function () {
                                expect(this.header.colorType).to.be.equal(options.colorType);
                            });
                        }
Severity: Major
Found in test/png/testGen.js and 4 other locations - About 1 hr to fix
test/png/testGen.js on lines 98..102
test/png/testGen.js on lines 110..114
test/png/testGen.js on lines 116..120
test/png/testGen.js on lines 122..126

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

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