publiclab/image-sequencer

View on GitHub
src/modules/Shadow/Module.js

Summary

Maintainability
F
5 days
Test Coverage

Function canvasResize has a Cognitive Complexity of 141 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = function canvasResize(options, UI) {

  var defaults = require('./../../util/getDefaults.js')(require('./info.json'));
  const pixelSetter = require('../../util/pixelSetter.js');

Severity: Minor
Found in src/modules/Shadow/Module.js - About 2 days 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 canvasResize has 128 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function canvasResize(options, UI) {

  var defaults = require('./../../util/getDefaults.js')(require('./info.json'));
  const pixelSetter = require('../../util/pixelSetter.js');

Severity: Major
Found in src/modules/Shadow/Module.js - About 5 hrs to fix

Function draw has 117 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function draw(input, callback, progressObj) {

    options.X_value = parseInt(options.X_value || defaults.X_value);
    options.Y_value = parseInt(options.Y_value || defaults.Y_value);

Severity: Major
Found in src/modules/Shadow/Module.js - About 4 hrs to fix

Function extraManipulation has 97 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function extraManipulation(pixels) {
      let [w, h] = pixels.shape;
      let newPixels = require('ndarray')(new Uint8Array(4 * (w + Math.abs(options.X_value)) * (h + Math.abs(options.Y_value))).fill(0), [(w + Math.abs(options.X_value)), (h + Math.abs(options.Y_value)), 4]);
      let iMax = w,
        jMax = h;
Severity: Major
Found in src/modules/Shadow/Module.js - About 3 hrs to fix

Avoid deeply nested control flow statements.
Open

        for (let i = 0; i < iMax && i < w; i++) {
          for (let j = 0; j < jMax && j < h; j++) {
            let x = i, y = j + Math.abs(options.Y_value);
            pixelSetter(x, y, [pixels.get(i, j, 0), pixels.get(i, j, 1), pixels.get(i, j, 2), pixels.get(i, j, 3)], newPixels);
          }
Severity: Major
Found in src/modules/Shadow/Module.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

            if (k >= w && l >= h && ((k - w) >= (l - h))) {
              continue;
            }
Severity: Major
Found in src/modules/Shadow/Module.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

          for (var l = 0; l < (h + options.Y_value); l++) {
            if (l + (k * (options.Y_value / Math.abs(options.X_value))) - (options.Y_value + h) > 0 && l >= h) {
              continue;
            }
            let val = 255 - ((k / Math.abs(options.X_value)) * 255);
Severity: Major
Found in src/modules/Shadow/Module.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

          for (var l = h; l < (h + options.Y_value); l++) {
            let val = ((l - h) / options.Y_value * 255);
            pixelSetter(k, l, [val, val, val, 255], newPixels);
          }
Severity: Major
Found in src/modules/Shadow/Module.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

        for (var k = w; k < (w + options.X_value); k++) {
          for (var l = 0; l < (h + Math.abs(options.Y_value)); l++) {
            let val = (((k - w) / options.X_value) * 255);
            pixelSetter(k, l, [val, val, val, 255], newPixels);
          }
Severity: Major
Found in src/modules/Shadow/Module.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

        for (var k = 0; k < (w + options.X_value); k++) {
          for (var l = 0; l < Math.abs(options.Y_value); l++) {
            if (l >= ((options.X_value / Math.abs(options.Y_value)) * (w + options.X_value - k)) && k >= w) {
              continue;
            }
Severity: Major
Found in src/modules/Shadow/Module.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

          for (let j = 0; j < jMax && j < h; j++) {
            let x = i + Math.abs(options.X_value), y = j;
            pixelSetter(x, y, [pixels.get(i, j, 0), pixels.get(i, j, 1), pixels.get(i, j, 2), pixels.get(i, j, 3)], newPixels);
          }
Severity: Major
Found in src/modules/Shadow/Module.js - About 45 mins to fix

There are no issues that match your filters.

Category
Status