game/static/game/js/blocklyCustomisations.js
Function BlocklyCustomisations
has a Cognitive Complexity of 99 (exceeds 5 allowed). Consider refactoring. Open
Open
ocargo.BlocklyCustomisations = function () {
const TOOLBOX_REMAINING_CAPACITY_TEXT_COLUMN_WIDTH = 50;
const QUANTITY_TEXT_OFFSET = 35;
- Read upRead up
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
Open
ocargo.BlocklyCustomisations = function () {
const TOOLBOX_REMAINING_CAPACITY_TEXT_COLUMN_WIDTH = 50;
const QUANTITY_TEXT_OFFSET = 35;
Function setupLimitedBlocks
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
this.setupLimitedBlocks = function () {
if (limitedBlocks) {
this.widenFlyout();
// Override blockly flyout's show function to add in the quantity text elements
Function widenFlyout
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
this.widenFlyout = function () {
var oldCaclulateWidthFunction = Blockly.VerticalFlyout.prototype.reflowInternal_;
Blockly.VerticalFlyout.prototype.reflowInternal_ = function() {
this.workspace_.scale = this.targetWorkspace_.scale;
Function reflowInternal_
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
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++) {
Function show
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
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);
Function setupDoubleclick
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
this.setupDoubleclick = function () {
Blockly.Flyout.prototype.addBlockListeners_ = function(root, block, rect) {
var block2 = block;
var isBlockAllowed = function (block) {
Function addBlockListeners_
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
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) {