uccser/cs-field-guide

View on GitHub
csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js

Summary

Maintainability
F
1 wk
Test Coverage

File pixel-viewer.js has 1036 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// Settings and intialize layout
this.MAX_HEIGHT = 133;
this.CELL_SIZE = 50;
this.MAX_NOISE = 15;

Severity: Major
Found in csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js - About 2 days to fix

Function getSurroundingPixels has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
Open

function getSurroundingPixels(col, row, returnGrid=true){
  // Gets the r, g and b values for  pixels surrounding the pixel at (row, col)
  // Grey scale is whether to return greyscale values
  // ReturnGrid: whether to return a grid (array of arrays) or flattened array of values.
  // Former is more useful for weighted blurring and latter is more useful for median and mean blurring
Severity: Minor
Found in csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js - About 6 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 paint has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

var paint = function(row, col, left, top, width, height, zoom) {
  // Get data for pixel
  var show_pixel_fill = document.getElementById('pixel-viewer-interactive-show-pixel-fill').checked;
  var pixelData;
  if (filter != null){
Severity: Minor
Found in csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js - About 3 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 Blur has 61 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function Blur(parent_element){
  // A Blur widget for blur mode
  this.main_div = $("<div></div>");
  this.main_div.attr("id", "pixel-viewer-blur").appendTo($(parent_element));

Severity: Major
Found in csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js - About 2 hrs to fix

Function getSurroundingPixels has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function getSurroundingPixels(col, row, returnGrid=true){
  // Gets the r, g and b values for  pixels surrounding the pixel at (row, col)
  // Grey scale is whether to return greyscale values
  // ReturnGrid: whether to return a grid (array of arrays) or flattened array of values.
  // Former is more useful for weighted blurring and latter is more useful for median and mean blurring
Severity: Major
Found in csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js - About 2 hrs to fix

Function EdgeDetector has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function EdgeDetector(parent_element){
  // Widget set for edge detection functionality
  this.main_div = $("<div></div>");
  this.main_div.attr("id", "pixel-viewer-edge-detector").appendTo($(parent_element));

Severity: Minor
Found in csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js - About 1 hr to fix

Function setUpMode has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function setUpMode(){
  // Sets up widgets and descriptions appropriate to mode
  if (mode == 'threshold'){
    addDescription(gettext("Colour Threshold Interactive"),
    gettext("Create an expression to threshold the image. Any pixels that match the\
Severity: Minor
Found in csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js - About 1 hr to fix

Function paint has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var paint = function(row, col, left, top, width, height, zoom) {
  // Get data for pixel
  var show_pixel_fill = document.getElementById('pixel-viewer-interactive-show-pixel-fill').checked;
  var pixelData;
  if (filter != null){
Severity: Minor
Found in csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js - About 1 hr to fix

Function applyBlur has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function applyBlur(){
  // Apply a blur filter to the image. What kind of blur is applied depends on user input.

  var blur_type = $("#blur-type").val();
  // Set the global gridsize based on user input
Severity: Minor
Found in csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js - About 1 hr to fix

Function Thresholder has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function Thresholder(parent_element){
  // Colour thresholder widget
  logic_order = $(document.createElement("p")).text(gettext("Note: The 'AND' operator will always be evaluated before the 'OR' operator."));
  $(parent_element).append(logic_order);
  this.main_div = $("<div></div>");
Severity: Minor
Found in csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js - About 1 hr to fix

Function applyConvolutionalKernel has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

function applyConvolutionalKernel(rgb, convo_k){
  // Applies a convolutional kernel to an rgb grid and returns an array of red green and blue values
  response = Array();

  // Save some calculations if it's greyscale
Severity: Minor
Found in csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.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 load_resize_image has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function load_resize_image(src, user_upload=true){
  var image = new Image();
  image.onload = function(){
    var canvas = document.getElementById("pixel-viewer-interactive-source-canvas");
    if(image.height > MAX_HEIGHT) {
Severity: Minor
Found in csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js - About 1 hr to fix

Function paint has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

var paint = function(row, col, left, top, width, height, zoom) {
Severity: Major
Found in csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js - About 50 mins to fix

Function addNoise has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

function addNoise(){
  // Adds salt and pepper noise to the image
  if (salt == null){
    salt = new Array(contentWidth);
    for (var i = 0; i < contentWidth; i++){
Severity: Minor
Found in csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js - About 45 mins 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

Avoid deeply nested control flow statements.
Open

          if (returnGrid){
            rgb[k][i][j] = pixelData[k];
          }
          else{
            rgb[k].push(pixelData[k]);
Severity: Major
Found in csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js - About 45 mins to fix

Function toggleGreyscale has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function toggleGreyscale(){
  // Turns greyscale mode on or off depending on user input
  if ($("#greyscale-or-rgb").val() == "greyscale"){
    isGreyscale = true;
    if (filter == null || filter == salter){
Severity: Minor
Found in csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js - About 35 mins 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

Avoid too many return statements within this function.
Open

        return surroundingPixels.map(function(list){
          list = list.sort();
          return list[Math.floor(list.length / 2)];
        });
Severity: Major
Found in csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

        return [val, val, val];
Severity: Major
Found in csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js - About 30 mins to fix

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

    $(document.createElement("label"))
    .text(gettext("Number of grids:"))
    .attr("class", "col-12 pl-0")
    .append(
      $(document.createElement("select"))
csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js on lines 461..472

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

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

  return $(document.createElement("label"))
    .attr("class", "col-12 pl-0")
    .text(gettext("Grid size:"))
    .append(
      $(document.createElement("select"))
csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js on lines 266..277

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

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

  $("#blur-grid").append(
    $(document.createElement("label")).text(gettext("Use absolute value of result: ")).append(
      $(document.createElement("input")).attr({"id":"use_abs_val","type":"checkbox"})));
csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js on lines 581..583

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

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

  $("#grids-div").append(
    $(document.createElement("label")).text(gettext("Use absolute value of result: ")).append(
      $(document.createElement("input")).attr({"id":"use_abs_val","type":"checkbox"})));
csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js on lines 593..595

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

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

      $(document.createElement("select"))
      .attr({"id": "greyscale-or-rgb", "class": "form-control w-auto d-inline mx-1"})
      .append($("<option value=greyscale>greyscale</option>"))
      .append($("<option value=rgb>rgb</option>"))
      .on("input", toggleGreyscale)
csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js on lines 356..360

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

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

      $(document.createElement("select"))
      .attr({"id": "blur-type", "class": "form-control w-auto d-inline mx-1"})
      .append($("<option value=median>median</option>"))
      .append($("<option value=mean>mean</option>"))
      .append($("<option value=gaussian>gaussian</option>"))
csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js on lines 451..455

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

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 5 locations. Consider refactoring.
Open

  this.main_div.append($(document.createElement("button"))
  .text(gettext("Apply Threshold"))
  .attr("class", "btn btn-primary mx-1")
  .click(applyThreshold));
csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js on lines 297..303
csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js on lines 374..378
csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js on lines 380..386
csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js on lines 423..426

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 5 locations. Consider refactoring.
Open

  this.main_div.append($(document.createElement("button"))
  .text(gettext("Remove Threshold"))
  .attr("class", "btn btn-primary mx-1")
  .click(removeFilters));
csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js on lines 297..303
csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js on lines 374..378
csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js on lines 380..386
csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js on lines 419..422

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 5 locations. Consider refactoring.
Open

  this.main_div.append(
    $(document.createElement("button"))
    .text(gettext("Apply blur"))
    .attr("class", "btn btn-primary mr-1")
    .click(applyBlur));
csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js on lines 297..303
csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js on lines 380..386
csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js on lines 419..422
csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js on lines 423..426

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 5 locations. Consider refactoring.
Open

  this.main_div
    .append(
    $(document.createElement("button"))
    .text(gettext("Remove blur"))
    .attr("class", "btn btn-primary")
csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js on lines 297..303
csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js on lines 374..378
csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js on lines 419..422
csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js on lines 423..426

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 5 locations. Consider refactoring.
Open

  this.main_div
    .append(
    $(document.createElement("button"))
    .text(gettext("Restore Image"))
    .attr("class", "btn btn-primary")
csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js on lines 374..378
csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js on lines 380..386
csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js on lines 419..422
csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js on lines 423..426

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

    context.strokeRect(Math.round(left), Math.round(top), Math.round(width)+1, Math.round(height)+1);
csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js on lines 1082..1082

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

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

    context.fillRect(Math.round(left), Math.round(top), Math.round(width)+1, Math.round(height)+1);
csfieldguide/static/interactives/pixel-viewer/js/pixel-viewer.js on lines 1084..1084

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

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

target.addEventListener("drop", function(e){
  e.preventDefault();
  loadImage(e.dataTransfer.files[0]);
}, true);
csfieldguide/static/interactives/image-bit-comparer/js/image-bit-comparer.js on lines 90..93

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

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