yahoo/pngjs-image

View on GitHub

Showing 322 of 322 total issues

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

                        if (options.bitDepth !== undefined) {
                            it('should have the correct bit-depth', function () {
                                expect(this.header.bitDepth).to.be.equal(options.bitDepth);
                            });
                        }
Severity: Major
Found in test/png/testGen.js and 4 other locations - About 1 hr to fix
test/png/testGen.js on lines 104..108
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

Function compose has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    compose: function (stream, options) {

        var headerChunk, paletteChunk,
            colorType, color,
            i,
Severity: Minor
Found in lib/png/chunks/tRNS.js - About 1 hr to fix

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

var Encoder = function () {
    this._chunks = {};
    this._chunkData = {};

    utils.loadModule(path.join(__dirname, 'utils', 'chunkUtils.js'), this);
Severity: Major
Found in lib/png/encoder.js and 1 other location - About 1 hr to fix
lib/png/decoder.js on lines 22..27

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

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

var Decoder = function () {
    this._chunks = {};
    this._chunkData = {};

    utils.loadModule(path.join(__dirname, 'utils', 'chunkUtils.js'), this);
Severity: Major
Found in lib/png/decoder.js and 1 other location - About 1 hr to fix
lib/png/encoder.js on lines 22..27

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

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

        for (i = 0, len = buffer.length; i < len; i++) {
            if (buffer.readUInt8(i) === 0) {
                foundIndex = i;
                break;
            }
Severity: Major
Found in lib/png/chunks/tEXt.js and 4 other locations - About 1 hr to fix
lib/png/chunks/iCCP.js on lines 103..108
lib/png/chunks/sCAL.js on lines 141..146
lib/png/chunks/zTXt.js on lines 99..104
lib/png/custom/jsOn.js on lines 88..93

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

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

        for(i = 0, len = buffer.length; i < len; i++) {
            if (buffer.readUInt8(i) === 0) {
                foundIndex = i;
                break;
            }
Severity: Major
Found in lib/png/chunks/iCCP.js and 4 other locations - About 1 hr to fix
lib/png/chunks/sCAL.js on lines 141..146
lib/png/chunks/tEXt.js on lines 94..99
lib/png/chunks/zTXt.js on lines 99..104
lib/png/custom/jsOn.js on lines 88..93

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

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

        for(i = 0, len = buffer.length; i < len; i++) {
            if (buffer.readUInt8(i) === 0) {
                foundIndex = i;
                break;
            }
Severity: Major
Found in lib/png/chunks/zTXt.js and 4 other locations - About 1 hr to fix
lib/png/chunks/iCCP.js on lines 103..108
lib/png/chunks/sCAL.js on lines 141..146
lib/png/chunks/tEXt.js on lines 94..99
lib/png/custom/jsOn.js on lines 88..93

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

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

        for (i = 0, len = buffer.length; i < len; i++) {
            if (buffer.readUInt8(i) === 0) {
                foundIndex = i;
                break;
            }
Severity: Major
Found in lib/png/custom/jsOn.js and 4 other locations - About 1 hr to fix
lib/png/chunks/iCCP.js on lines 103..108
lib/png/chunks/sCAL.js on lines 141..146
lib/png/chunks/tEXt.js on lines 94..99
lib/png/chunks/zTXt.js on lines 99..104

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

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

        for (i = 0, len = buffer.length; i < len; i++) {
            if (buffer.readUInt8(i) === 0) {
                foundIndex = i;
                break;
            }
Severity: Major
Found in lib/png/chunks/sCAL.js and 4 other locations - About 1 hr to fix
lib/png/chunks/iCCP.js on lines 103..108
lib/png/chunks/tEXt.js on lines 94..99
lib/png/chunks/zTXt.js on lines 99..104
lib/png/custom/jsOn.js on lines 88..93

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

        for (i = 0, len = colors.length; i < len; i++) {
            stream.writeUInt8(colors[i].red);
            stream.writeUInt8(colors[i].green);
            stream.writeUInt8(colors[i].blue);
        }
Severity: Major
Found in lib/png/chunks/PLTE.js and 1 other location - About 1 hr to fix
lib/png/chunks/tRNS.js on lines 323..327

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

                for (i = 0; i < length; i++) {
                    stream.writeUInt16BE(colors[i].red);
                    stream.writeUInt16BE(colors[i].green);
                    stream.writeUInt16BE(colors[i].blue);
                }
Severity: Major
Found in lib/png/chunks/tRNS.js and 1 other location - About 1 hr to fix
lib/png/chunks/PLTE.js on lines 305..309

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

Function processPasses has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Interlace.prototype.processPasses = function (cb) {

    var headerChunk = this.getHeaderChunk(),

        height = headerChunk.getHeight(),
Severity: Minor
Found in lib/png/processor/interlace.js - About 1 hr to fix

Function decode has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    decode: function (image, strict, options) {

        var i, len, index,
            r, g, b, alpha,
            headerChunk,
Severity: Minor
Found in lib/png/chunks/tRNS.js - About 1 hr to fix

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

    compose: function (stream, options) {

        var headerChunk, paletteChunk,
            colorType, color,
            i,
Severity: Minor
Found in lib/png/chunks/tRNS.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 _adam7 has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

Interlace.prototype._adam7 = function (data, width, height, revert) {

    // Suggested implementation from the spec:
    // http://www.libpng.org/pub/png/spec/1.1/PNG-Decoders.html

Severity: Minor
Found in lib/png/processor/interlace.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

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

            try {
                this.encode(this.outputFile, this.image, options.width, options.height, options.encodeOptions);
            } catch (err) {
                if (options.expectFailure) {
                    if (options.expectMessage != err.message) {
Severity: Major
Found in test/png/testGen.js and 1 other location - About 1 hr to fix
test/png/testGen.js on lines 34..44

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

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

            try {
                this.decode(this.file, options.decodeOptions);
            } catch (err) {
                if (options.expectFailure) {
                    if (options.expectMessage != err.message) {
Severity: Major
Found in test/png/testGen.js and 1 other location - About 1 hr to fix
test/png/testGen.js on lines 160..170

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

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 _parseChunk has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Decoder.prototype._parseChunk = function (stream, strict, options) {

    var chunkLength,
        chunkType,
        chunkCrc,
Severity: Minor
Found in lib/png/decoder.js - About 1 hr to fix

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

    applyFilters: function (filters, returnResult) {

        var image,
            newFilters;

Severity: Minor
Found in index.js - About 1 hr to fix

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

    encodeData: function (image, options) {

        if (options.chromaticities) {

            var chunk = this.createChunk(this.getType(), this.getChunks());
Severity: Minor
Found in lib/png/chunks/cHRM.js - About 1 hr to fix
Severity
Category
Status
Source
Language