uccser/cs-field-guide

View on GitHub
csfieldguide/static/interactives/parity/js/parity.js

Summary

Maintainability
D
2 days
Test Coverage

File parity.js has 391 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var Parity = {};

$(document).ready(function(){
  // Create the grid on load
  Parity.grid = $('#interactive-parity-grid');
Severity: Minor
Found in csfieldguide/static/interactives/parity/js/parity.js - About 5 hrs to fix

Function setRandomBits has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

function setRandomBits() {
  for (var row = 0; row < Parity.grid_values.length - 1; row++) {
    for (var col = 0; col < Parity.grid_values.length - 1; col++) {
      if (Parity.initial_bits) {
        let char_position = row * (Parity.grid_values.length - 1) + col;
Severity: Minor
Found in csfieldguide/static/interactives/parity/js/parity.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 setupMode has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

function setupMode() {
  var header = $('#interactive-parity-mode');

  // Hide all controls
  $('.interactive-parity-controls').hide()
Severity: Minor
Found in csfieldguide/static/interactives/parity/js/parity.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 setupGrid has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

function setupGrid(){
  // Get grid size and set it
  Parity.grid_size = parseInt($('#interactive-parity-grid-size').val());

  // Create 2D array of bit values - true is on (white) while false is off (black)
Severity: Minor
Found in csfieldguide/static/interactives/parity/js/parity.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 setupMode has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function setupMode() {
  var header = $('#interactive-parity-mode');

  // Hide all controls
  $('.interactive-parity-controls').hide()
Severity: Minor
Found in csfieldguide/static/interactives/parity/js/parity.js - About 1 hr to fix

Function setupGrid has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function setupGrid(){
  // Get grid size and set it
  Parity.grid_size = parseInt($('#interactive-parity-grid-size').val());

  // Create 2D array of bit values - true is on (white) while false is off (black)
Severity: Minor
Found in csfieldguide/static/interactives/parity/js/parity.js - About 1 hr to fix

Function setParityBits has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

function setParityBits() {

  column_counts = new Array(Parity.grid_values.length).fill(0);
  for (var row = 0; row < Parity.grid_values.length-1; row++) {
    var black_bit_count = 0;
Severity: Minor
Found in csfieldguide/static/interactives/parity/js/parity.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 updateCircler has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

function updateCircler(axis, index) {
    var circler, top, left, bottom, right;
    var gridUnitPercentage = 100 / Parity.grid_size;
    if (axis == 'x') {
        circler = Parity.rowCircler;
Severity: Minor
Found in csfieldguide/static/interactives/parity/js/parity.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 checkParity has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

function checkParity() {
  var parity_status = true;

  column_counts = new Array(Parity.grid_values.length).fill(0);
  for (var row = 0; row < Parity.grid_values.length; row++) {
Severity: Minor
Found in csfieldguide/static/interactives/parity/js/parity.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 updateCircler has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function updateCircler(axis, index) {
    var circler, top, left, bottom, right;
    var gridUnitPercentage = 100 / Parity.grid_size;
    if (axis == 'x') {
        circler = Parity.rowCircler;
Severity: Minor
Found in csfieldguide/static/interactives/parity/js/parity.js - About 1 hr to fix

Avoid deeply nested control flow statements.
Open

      if (!Parity.hide_size_controls) {
        $('.interactive-parity-size-controls').show();
      }
Severity: Major
Found in csfieldguide/static/interactives/parity/js/parity.js - About 45 mins to fix

There are no issues that match your filters.

Category
Status