yahoo/pngjs-image

View on GitHub

Showing 322 of 322 total issues

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

    preEncode: function (image, options) {

        var imageStream, scaledStream, reducedStream, withdrawnStream,
            interlace;

Severity: Minor
Found in lib/png/chunks/IHDR.js - About 1 hr to fix

Function finalizeDecode has 30 lines of code (exceeds 25 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

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

Filter.prototype._optimalEncode = function (info, options) {

    var filterList = [4, 3, 2, 1, 0],
        filterType,
        filterMapping,
Severity: Minor
Found in lib/png/processor/filter.js - About 1 hr to fix

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

Filter.prototype._getTopOutputPixel = function (info, x) {
    return (info.previousLineOffset === null) ? 0 : info.outputData[info.previousLineOffset + x];
};
Severity: Major
Found in lib/png/processor/filter.js and 1 other location - About 1 hr to fix
lib/png/processor/filter.js on lines 541..543

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

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

Filter.prototype._getTopInputPixel = function (info, x) {
    return (info.previousLineOffset === null) ? 0 : info.inputData[info.previousLineOffset + x];
};
Severity: Major
Found in lib/png/processor/filter.js and 1 other location - About 1 hr to fix
lib/png/processor/filter.js on lines 501..503

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

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

    chunks.forEach(function (chunkType) {
        module = require(path.join(__dirname, 'custom', chunkType));
        this.addChunkType(chunkType, module);
    }.bind(this));
Severity: Major
Found in lib/png/chunk.js and 1 other location - About 1 hr to fix
lib/png/chunk.js on lines 461..464

Duplicated Code

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

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

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

Tuning

This issue has a mass of 58.

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

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

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

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

Refactorings

Further Reading

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

    chunks.forEach(function (chunkType) {
        module = require(path.join(__dirname, 'chunks', chunkType));
        this.addChunkType(chunkType, module);
    }.bind(this));
Severity: Major
Found in lib/png/chunk.js and 1 other location - About 1 hr to fix
lib/png/chunk.js on lines 477..480

Duplicated Code

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

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

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

Tuning

This issue has a mass of 58.

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

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

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

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

Refactorings

Further Reading

Function encode has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Encoder.prototype.encode = function (image, width, height, options) {

    options = options || {};

    var i, len,
Severity: Minor
Found in lib/png/encoder.js - About 1 hr to fix

Function parse has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    parse: function (stream, length, strict, options) {

        var i, len,
            foundIndex = null,
            buffer, string,
Severity: Minor
Found in lib/png/chunks/zTXt.js - About 1 hr to fix

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

Parser.prototype.decode = function (image) {

    var headerChunk = this.getHeaderChunk(),
        interlace = new Interlace(headerChunk),

Severity: Minor
Found in lib/png/processor/parser.js - About 1 hr to fix

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

    filterMapping = {
        0: this._decodeNone,
        1: this._decodeSub,
        2: this._decodeUp,
        3: this._decodeAverage,
Severity: Major
Found in lib/png/processor/filter.js and 1 other location - About 1 hr to fix
lib/png/processor/filter.js on lines 164..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 57.

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

    filterMapping = {
        0: this._encodeNone,
        1: this._encodeSub,
        2: this._encodeUp,
        3: this._encodeAverage,
Severity: Major
Found in lib/png/processor/filter.js and 1 other location - About 1 hr to fix
lib/png/processor/filter.js on lines 340..346

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

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 BufferedStream has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

var BufferedStream = function (data, offset, length) {

    this.readOffset = 0;
    this.writeOffset = 0;

Severity: Minor
Found in lib/png/utils/bufferedStream.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 preEncode has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    preEncode: function (image, options) {

        var imageStream, scaledStream, reducedStream, withdrawnStream,
            interlace;

Severity: Minor
Found in lib/png/chunks/IHDR.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 setAtIndex has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    setAtIndex: function (idx, color) {
        if (typeof color === 'object') {
            if (color.red !== undefined) this.setRed(idx, color.red, color.opacity);
            if (color.green !== undefined) this.setGreen(idx, color.green, color.opacity);
            if (color.blue !== undefined) this.setBlue(idx, color.blue, color.opacity);
Severity: Minor
Found in lib/pixel.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 addEncodeTests has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    addEncodeTests: function (options) {

        before(function () {
            this.file = this.resource(options.resourceGroup, options.resourceFile + '.raw');
            this.finalFile = this.resource((options.outputGroup || options.resourceGroup), (options.outputFile || options.resourceFile) + '_enc.png');
Severity: Minor
Found in test/png/testGen.js - About 1 hr to fix

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

        if (!this.hasAlphaChannel()) {
            withdrawnStream = new BufferedStream(null, null, imageStream.length * 0.75);
            //scale.withdraw(imageStream, withdrawnStream, 4);
        } else {
            withdrawnStream = imageStream; // Nothing to do
Severity: Major
Found in lib/png/chunks/IHDR.js and 1 other location - About 1 hr to fix
lib/png/chunks/IHDR.js on lines 706..711

Duplicated Code

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

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

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

Tuning

This issue has a mass of 56.

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

        it('should have no compressed text', function () {
            expect(this.data.volatile && this.data.volatile.compressedTexts).to.be.undefined;
        });
Severity: Major
Found in test/png/decode/ancillary/text.js and 1 other location - About 1 hr to fix
test/png/decode/ancillary/text.js on lines 28..30

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

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

        it('should have no plain text', function () {
            expect(this.data.volatile && this.data.volatile.texts).to.be.undefined;
        });
Severity: Major
Found in test/png/decode/ancillary/text.js and 1 other location - About 1 hr to fix
test/png/decode/ancillary/text.js on lines 32..34

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

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

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

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

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

Refactorings

Further Reading

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

        if (!this.isColor()) {
            reducedStream = new BufferedStream(null, null, withdrawnStream.length / 3);
            //scale.reduce(withdrawnStream, reducedStream, 3);
        } else {
            reducedStream = withdrawnStream; // Nothing to do
Severity: Major
Found in lib/png/chunks/IHDR.js and 1 other location - About 1 hr to fix
lib/png/chunks/IHDR.js on lines 698..703

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

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