ocadotechnology/rapid-router

View on GitHub
game/static/game/js/blocklyCustomisations.js

Summary

Maintainability
F
4 days
Test Coverage

Function BlocklyCustomisations has a Cognitive Complexity of 99 (exceeds 5 allowed). Consider refactoring.
Open

ocargo.BlocklyCustomisations = function () {

    const TOOLBOX_REMAINING_CAPACITY_TEXT_COLUMN_WIDTH = 50;
    const QUANTITY_TEXT_OFFSET = 35;

Severity: Minor
Found in game/static/game/js/blocklyCustomisations.js - About 1 day 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 BlocklyCustomisations has 192 lines of code (exceeds 25 allowed). Consider refactoring.
Open

ocargo.BlocklyCustomisations = function () {

    const TOOLBOX_REMAINING_CAPACITY_TEXT_COLUMN_WIDTH = 50;
    const QUANTITY_TEXT_OFFSET = 35;

Severity: Major
Found in game/static/game/js/blocklyCustomisations.js - About 7 hrs to fix

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

        this.setupLimitedBlocks = function () {     
            if (limitedBlocks) {
                this.widenFlyout();
    
                // Override blockly flyout's show function to add in the quantity text elements
    Severity: Minor
    Found in game/static/game/js/blocklyCustomisations.js - About 1 hr to fix

      Function widenFlyout has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          this.widenFlyout = function () {
              var oldCaclulateWidthFunction = Blockly.VerticalFlyout.prototype.reflowInternal_;
      
              Blockly.VerticalFlyout.prototype.reflowInternal_ = function() {
                  this.workspace_.scale = this.targetWorkspace_.scale;
      Severity: Minor
      Found in game/static/game/js/blocklyCustomisations.js - About 1 hr to fix

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

                Blockly.VerticalFlyout.prototype.reflowInternal_ = function() {
                    this.workspace_.scale = this.targetWorkspace_.scale;
                    var flyoutWidth = 0;
                    var blocks = this.workspace_.getTopBlocks(false);
                    for (var i = 0, block; block = blocks[i]; i++) {
        Severity: Minor
        Found in game/static/game/js/blocklyCustomisations.js - About 1 hr to fix

          Function show has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                      Blockly.Flyout.prototype.show = function (xmlList) {
                          if (firstCall) {
                              // The first time this is called the flyout doesn't yet exist.
                              // By calling show we give this.width_ a non-zero value.
                              oldShowFunction.call(this, xmlList);
          Severity: Minor
          Found in game/static/game/js/blocklyCustomisations.js - About 1 hr to fix

            Function setupDoubleclick has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                this.setupDoubleclick = function () {
                    
                    Blockly.Flyout.prototype.addBlockListeners_ = function(root, block, rect) {
                        var block2 = block;
                        var isBlockAllowed = function (block) {
            Severity: Minor
            Found in game/static/game/js/blocklyCustomisations.js - About 1 hr to fix

              Function addBlockListeners_ has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      Blockly.Flyout.prototype.addBlockListeners_ = function(root, block, rect) {
                          var block2 = block;
                          var isBlockAllowed = function (block) {
                              for (var i = 0; i < BLOCKS.length; i++) {
                                  if (BLOCKS[i].type === block.type) {
              Severity: Minor
              Found in game/static/game/js/blocklyCustomisations.js - About 1 hr to fix

                There are no issues that match your filters.

                Category
                Status