cra16/cake-core

View on GitHub
core/blocks.js

Summary

Maintainability
F
1 wk
Test Coverage

Function showResult has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
Open

Blockly.Blocks.showResult = function(result){

    var tree = new Blockly.Toolbox.TreeControl(goog.html.SafeHtml.EMPTY,
        Blockly.Toolbox.CONFIG_);
    Blockly.Toolbox.tree_ = tree;
Severity: Minor
Found in core/blocks.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

File blocks.js has 418 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * @license
 * Visual Blocks Editor
 *
 * Copyright 2013 Google Inc.
Severity: Minor
Found in core/blocks.js - About 6 hrs to fix

Function searchTag has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

Blockly.Blocks.searchTag = function(searchingTag){
    var tree = Blockly.Toolbox.tree_;
    var blocks = [];
    for (var i = 0; i<tree.children_.length; i++) {
        var tree_i =tree.children_[i];
Severity: Minor
Found in core/blocks.js - About 4 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 addTemplate has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

Blockly.Blocks.addTemplate = function(details) {
    // Validate inputs.  TODO: Add more.
    goog.asserts.assert(details.blockName);
    goog.asserts.assert(Blockly.Blocks[details.blockName],
        'Blockly.Blocks already has a field named ', details.blockName);
Severity: Minor
Found in core/blocks.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 addTemplate has 69 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Blockly.Blocks.addTemplate = function(details) {
    // Validate inputs.  TODO: Add more.
    goog.asserts.assert(details.blockName);
    goog.asserts.assert(Blockly.Blocks[details.blockName],
        'Blockly.Blocks already has a field named ', details.blockName);
Severity: Major
Found in core/blocks.js - About 2 hrs to fix

Function variablePlaceCheck has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

Blockly.Blocks.variablePlaceCheck = function(block) {
    if(!block) {
        if (!this.workspace) {
            // Block has been deleted.
            return;
Severity: Minor
Found in core/blocks.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 showResult has 59 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Blockly.Blocks.showResult = function(result){

    var tree = new Blockly.Toolbox.TreeControl(goog.html.SafeHtml.EMPTY,
        Blockly.Toolbox.CONFIG_);
    Blockly.Toolbox.tree_ = tree;
Severity: Major
Found in core/blocks.js - About 2 hrs to fix

Function searchTag has 54 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Blockly.Blocks.searchTag = function(searchingTag){
    var tree = Blockly.Toolbox.tree_;
    var blocks = [];
    for (var i = 0; i<tree.children_.length; i++) {
        var tree_i =tree.children_[i];
Severity: Major
Found in core/blocks.js - About 2 hrs to fix

Function requireOutFunction has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

Blockly.Blocks.requireOutFunction=function(block){
    if(!block) {
        if (!this.workspace) {
            // Block has been deleted.
            return;
Severity: Minor
Found in core/blocks.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 init has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    block.init = function() {
        var thisBlock = this;
        // Set basic properties of block.
        this.setColour(details.colour);
        this.setHelpUrl(details.helpUrl);
Severity: Minor
Found in core/blocks.js - About 1 hr to fix

Function syncTrees has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function syncTrees(treeIn, treeOut) {
        for (var i = 0, childIn; childIn = treeIn.childNodes[i]; i++) {
            if (!childIn.tagName) {
                // Skip over text.
                continue;
Severity: Minor
Found in core/blocks.js - About 1 hr to fix

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

Blockly.Blocks.requireInFunction = function(block) {
    if(!block) {
        if (!this.workspace) {
            // Block has been deleted.
            return;
Severity: Minor
Found in core/blocks.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 setCheckPointer has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Blockly.Blocks.setCheckPointer = function(block, ptrType, inputName) {
    switch (ptrType) {
        case ('int'):
            block.getInput(inputName).setCheck(['PTR_INT', 'Address', 'Pointer', 'Array', 'Aster']);
            break;
Severity: Minor
Found in core/blocks.js - About 1 hr to fix

Avoid deeply nested control flow statements.
Open

                if(tree_j.blocks){
                    for(var k=0;k<tree_j.blocks.length;k++){
                        var block = Blockly.Xml.domToBlockObject(Blockly.mainWorkspace, tree_j.blocks[k]);
                        blocks.push(block);
                    }
Severity: Major
Found in core/blocks.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                        if(!child.tagName){
                            continue;
                        }
Severity: Major
Found in core/blocks.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                        if(childName == 'BLOCK'){
                            var check = Blockly.Blocks.checkResult(child.getAttribute('type').toUpperCase(), result);
                            if(check != -1){
                                result.splice(check, 1);
                                searchResult.blocks.push(child);
Severity: Major
Found in core/blocks.js - About 45 mins to fix

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

Blockly.Blocks.checkLegalName = function(msg, name){
    var err = 0;

    if(name.length>0){
        var chk = name.substring(0,1);
Severity: Minor
Found in core/blocks.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

Function getIndexArray has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

Blockly.Blocks.getIndexArray = function(arrList, arrName) {
    var idxList = [];
    var fixedIdx1, fixedIdx2, fixedIdx3;
    for (var temp = 0 ; temp < arrList.length ; temp++) {
        if (arrList[temp][2] == arrName) {
Severity: Minor
Found in core/blocks.js - About 25 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

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

        if(tree_i.blocks == 'PROCEDURE'){
            var proNoReturn = new Blockly.Block();
            proNoReturn.id = Blockly.genUid();
            proNoReturn.fill(Blockly.mainWorkspace, "procedures_defnoreturn");
            blocks.push(proNoReturn);
Severity: Major
Found in core/blocks.js and 1 other location - About 4 hrs to fix
core/blocks.js on lines 368..395

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

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

        else if(tree_i.blocks =='STRUCTURE'){
            var structDefine = new Blockly.Block();
            structDefine.id = Blockly.genUid();
            structDefine.fill(Blockly.mainWorkspace, "structure_define");
            blocks.push(structDefine);
Severity: Major
Found in core/blocks.js and 1 other location - About 4 hrs to fix
core/blocks.js on lines 357..395

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

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

                if(tree_j.blocks){
                    for(var k=0;k<tree_j.blocks.length;k++){
                        var block = Blockly.Xml.domToBlockObject(Blockly.mainWorkspace, tree_j.blocks[k]);
                        blocks.push(block);
                    }
Severity: Major
Found in core/blocks.js and 1 other location - About 2 hrs to fix
core/blocks.js on lines 379..395

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

        else if(tree_i.blocks.length){
            for(var j =0;j<tree_i.blocks.length;j++){
                var block = Blockly.Xml.domToBlockObject(Blockly.mainWorkspace, tree_i.blocks[j]);
                blocks.push(block);
            }
Severity: Major
Found in core/blocks.js and 1 other location - About 2 hrs to fix
core/blocks.js on lines 388..393

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

        if (varList[temp][1] == wantedType) {
            wantedList.push([varList[temp][0], varList[temp][1], varList[temp][2], varList[temp][3], varList[temp][4], varList[temp][5]]);
        }
Severity: Major
Found in core/blocks.js and 1 other location - About 1 hr to fix
core/variables.js on lines 116..118

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

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

        if (block.getSurroundParent() && (block.getSurroundParent().type == 'main_block' || block.getSurroundParent().type == 'procedures_defnoreturn' || block.getSurroundParent().type == 'procedures_defreturn')) {
            block.setWarningText(Blockly.Msg.PLZ_OUT_OF_FUNCTION);
        } else {
            block.setWarningText(null);
        }
Severity: Major
Found in core/blocks.js and 2 other locations - About 1 hr to fix
core/blocks.js on lines 234..240
generators/cake/stdio.js on lines 165..174

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

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

        if (this.getSurroundParent() && (this.getSurroundParent().type == 'main_block' || this.getSurroundParent().type == 'procedures_defnoreturn' || this.getSurroundParent().type == 'procedures_defreturn')) {
            this.setWarningText(Blockly.Msg.PLZ_OUT_OF_FUNCTION);
        } else {
            this.setWarningText(null);
        }
Severity: Major
Found in core/blocks.js and 1 other location - About 1 hr to fix
core/blocks.js on lines 221..227

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

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

        if (block.getSurroundParent() && (block.getSurroundParent().type == 'main_block' || block.getSurroundParent().type == 'procedures_defnoreturn' || block.getSurroundParent().type == 'procedures_defreturn')) {
            block.setWarningText(null);
        } else if (block.getSurroundParent()) {
            block.setWarningText(Blockly.Msg.PLZ_OUT_OF_BLOCK);
        } else {
Severity: Major
Found in core/blocks.js and 2 other locations - About 1 hr to fix
core/blocks.js on lines 261..265
generators/cake/stdio.js on lines 165..174

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

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

        if (this.getSurroundParent() && (this.getSurroundParent().type == 'main_block' || this.getSurroundParent().type == 'procedures_defnoreturn' || this.getSurroundParent().type == 'procedures_defreturn')) {
            this.setWarningText(null);
        } else if (this.getSurroundParent()) {
            this.setWarningText(Blockly.Msg.PLZ_OUT_OF_BLOCK);
        } else {
Severity: Major
Found in core/blocks.js and 1 other location - About 1 hr to fix
core/blocks.js on lines 250..254

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

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