src/modules/Shadow/Module.js
Function canvasResize
has a Cognitive Complexity of 141 (exceeds 5 allowed). Consider refactoring. Open
Open
module.exports = function canvasResize(options, UI) {
var defaults = require('./../../util/getDefaults.js')(require('./info.json'));
const pixelSetter = require('../../util/pixelSetter.js');
- Read upRead up
- Create a ticketCreate a ticket
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
Open
module.exports = function canvasResize(options, UI) {
var defaults = require('./../../util/getDefaults.js')(require('./info.json'));
const pixelSetter = require('../../util/pixelSetter.js');
- Create a ticketCreate a ticket
Function draw
has 117 lines of code (exceeds 25 allowed). Consider refactoring. Open
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);
- Create a ticketCreate a ticket
Function extraManipulation
has 97 lines of code (exceeds 25 allowed). Consider refactoring. Open
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;
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
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);
}
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
Open
if (k >= w && l >= h && ((k - w) >= (l - h))) {
continue;
}
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
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);
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
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);
}
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
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);
}
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
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;
}
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
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);
}
- Create a ticketCreate a ticket