publiclab/image-sequencer

View on GitHub

Showing 267 of 267 total issues

Function ColorTemperature has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = function ColorTemperature(options, UI) {
  
  const pixelSetter = require('../../util/pixelSetter.js');
  var defaults = require('./../../util/getDefaults.js')(require('./info.json'));

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

function DefaultHtmlSequencerUi(_sequencer, options) {

  options = options || {};
  var addStepSel = options.addStepSel = options.addStepSel || '#addStep';
  var removeStepSel = options.removeStepSel = options.removeStepSel || 'button.remove';
Severity: Major
Found in examples/lib/defaultHtmlSequencerUi.js - About 2 hrs to fix

Function formatInput has 69 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function formatInput(args, format, images) {
  var json_q = {};
  var format_i = format;
  if (format == '+')
    format = ['string_a', 'o_object'];
Severity: Major
Found in src/FormatInput.js - About 2 hrs to fix

Function Dither has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = function Dither(pixels, type) {
  type = type;
  let bayerThresholdMap = [
    [15, 135, 45, 165],
    [195, 75, 225, 105],
Severity: Minor
Found in src/modules/Dither/Dither.js - About 2 hrs 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

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

        case 4:
          if (!((grads[x][y] >= grads[x + 1][y - 1]) && (grads[x][y] >= grads[x - 1][y + 1]))) {
            pixelsToBeSupressed.push([x, y]);
          }
          break;
Severity: Major
Found in src/modules/EdgeDetect/EdgeUtils.js and 1 other location - About 2 hrs to fix
src/modules/EdgeDetect/EdgeUtils.js on lines 162..166

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

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

        case 2:
          if (!((grads[x][y] >= grads[x + 1][y + 1]) && (grads[x][y] >= grads[x - 1][y - 1]))){
            pixelsToBeSupressed.push([x, y]);
          }
          break;
Severity: Major
Found in src/modules/EdgeDetect/EdgeUtils.js and 1 other location - About 2 hrs to fix
src/modules/EdgeDetect/EdgeUtils.js on lines 174..178

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

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

var setupCache = function() {
  let newWorker; // When sw.js is changed, this is the new service worker generated.
  
  // Toggle a CSS class to display a popup prompting the user to fetch a new version.
  function showUpdateModal() {
Severity: Major
Found in examples/lib/cache.js - About 2 hrs to fix

Function Run has 65 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function Run(ref, json_q, callback, ind, progressObj) {
  if (!progressObj) progressObj = { stop: function() { } };

  function drawStep(drawarray, pos) {
    if (pos == drawarray.length && drawarray[pos - 1] !== undefined) {
Severity: Major
Found in src/Run.js - About 2 hrs to fix

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

  function draw(input, callback, progressObj) {

    progressObj.stop(true);
    progressObj.overrideFlag = true;

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

Function Rotate has 65 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

  let output;

  function draw(input, callback, progressObj) {
Severity: Major
Found in src/modules/Rotate/Module.js - About 2 hrs to fix

Function DefaultHtmlSequencerUi has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

function DefaultHtmlSequencerUi(_sequencer, options) {

  options = options || {};
  var addStepSel = options.addStepSel = options.addStepSel || '#addStep';
  var removeStepSel = options.removeStepSel = options.removeStepSel || 'button.remove';
Severity: Minor
Found in examples/lib/defaultHtmlSequencerUi.js - About 2 hrs 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 LoadImage has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

function LoadImage(ref, name, src, main_callback) {
  function makeImage(datauri) {
    var image = {
      src: datauri,
      format: datauri.split(':')[1].split(';')[0].split('/')[1]
Severity: Minor
Found in src/ui/LoadImage.js - About 2 hrs 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 exports has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = function (program, sequencer, outputFilename) {
  utils.makedir(program.output, () => {
    console.log('Files will be exported to "' + program.output + '"');

    if (program.basic)
Severity: Minor
Found in src/cli/sequencerSteps.js - About 2 hrs 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 CropModuleUi has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function CropModuleUi(step, ui) {

  let inputWidth = 0,
    inputHeight = 0;

Severity: Major
Found in src/modules/Crop/Ui.js - About 2 hrs to fix

Function onComplete has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function onComplete(step) {
    let {$step, $stepAll} = step;
    $step('img').show();
    $stepAll('.load-spin').hide();
    $step('.load').hide();
Severity: Major
Found in examples/lib/defaultHtmlStepUi.js - About 2 hrs to fix

Function exports has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function (program, sequencer, outputFilename) {
  utils.makedir(program.output, () => {
    console.log('Files will be exported to "' + program.output + '"');

    if (program.basic)
Severity: Major
Found in src/cli/sequencerSteps.js - About 2 hrs to fix

Function Noise has 63 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function Noise(pixels, method) {
  let neighbourX = [-1, -1, -1, 0, 0, 0, 1, 1, 1];
  let neighbourY = [-1, 0, 1, -1, 0, 1, -1, 0, 1];

  if(method == 'Median Filtering'){
Severity: Major
Found in src/modules/NoiseReduction/NoiseReduction.js - About 2 hrs to fix

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

  function draw(input, callback, progressObj) {

    options.offset = parseInt(options.offset || defaults.offset);

    progressObj.stop(true);
Severity: Major
Found in src/modules/Overlay/Module.js - About 2 hrs to fix

Function Mask has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function Mask(options, UI, util) {
  var defaults = require('./../../util/getDefaults.js')(require('./info.json'));
  options.offset = options.offset || defaults.offset;
  options.resize = options.resize || defaults.resize;

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

Function warpWebGl has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  var warpWebGl = function warpWebGl(id, matrix1, matrix2, download) {

    // try to create a WebGL canvas (will fail if WebGL isn't supported)
    try {
      var canvas = fx.canvas(1500, 1500);
Severity: Major
Found in src/modules/WebglDistort/Module.js - About 2 hrs to fix
Severity
Category
Status
Source
Language