publiclab/image-sequencer

View on GitHub
src/modules/_nomodule/PixelManipulation.js

Summary

Maintainability
D
1 day
Test Coverage

Function PixelManipulation has 205 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function PixelManipulation(image, options) {
  // To handle the case where pixelmanipulation is called on the input object itself
  // like input.pixelManipulation(options)

  const isGIF = image.src.includes('image/gif');
Severity: Major
Found in src/modules/_nomodule/PixelManipulation.js - About 1 day to fix

Function generateOutput has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function generateOutput() {
      if (!(renderableFrames < numFrames) && !(resolvedFrames < numFrames)) {

        if (isGIF) {
          const dataPromises = []; // Array of all DataURI promises
Severity: Minor
Found in src/modules/_nomodule/PixelManipulation.js - About 1 hr to fix

Avoid deeply nested control flow statements.
Open

            if (pixels.data[curr + channels - 1] === 0) {
              const prev = prevIndex + j * channels;
  
              for (let k = 0; k < channels; ++k) {
                pixels.data[curr + k] = pixels.data[prev + k];
Severity: Major
Found in src/modules/_nomodule/PixelManipulation.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

            for (let c = 0; c < channels; c++) {
              frames[f].set(x, y, c, pixels.get(f, x, y, c));
            }
Severity: Major
Found in src/modules/_nomodule/PixelManipulation.js - About 45 mins to fix

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

              WebAssembly.instantiate(buf, imports).then(results => {
                results.instance.exports.manipulatePixel(framePix.shape[0], framePix.shape[1], inBrowser, test);
                
                wasmSuccess = true;
                resolvedFrames++;
Severity: Major
Found in src/modules/_nomodule/PixelManipulation.js and 1 other location - About 1 hr to fix
src/modules/_nomodule/PixelManipulation.js on lines 235..245

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

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

            fetch('../../../dist/manipulation.wasm').then(response =>
              response.arrayBuffer()
            ).then(bytes =>
              WebAssembly.instantiate(bytes, imports)
            ).then(results => {
Severity: Major
Found in src/modules/_nomodule/PixelManipulation.js and 1 other location - About 1 hr to fix
src/modules/_nomodule/PixelManipulation.js on lines 259..265

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

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

            }).catch(err => {
              console.log(err);
              console.log('WebAssembly acceleration errored; falling back to JavaScript in PixelManipulation');
              perPixelManipulation();
              
Severity: Minor
Found in src/modules/_nomodule/PixelManipulation.js and 1 other location - About 45 mins to fix
src/modules/_nomodule/PixelManipulation.js on lines 267..275

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

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

            catch(err){
              console.log(err);
              console.log('WebAssembly acceleration errored; falling back to JavaScript in PixelManipulation');
              perPixelManipulation();
              
Severity: Minor
Found in src/modules/_nomodule/PixelManipulation.js and 1 other location - About 45 mins to fix
src/modules/_nomodule/PixelManipulation.js on lines 245..253

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

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