cra16/cake-core

View on GitHub
generators/cake/stdio.js

Summary

Maintainability
F
6 days
Test Coverage

Function pointerTypeCheckInPrint has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

Blockly.cake.pointerTypeCheckInPrint = function(varName, checkDoubleAst) { // pointer type check
    var typeCode = '';
    var varList = Blockly.Variables.allVariables();

    if (checkDoubleAst == true){ // double pointer
Severity: Minor
Found in generators/cake/stdio.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 stdio.js has 383 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

goog.provide('Blockly.cake.stdio');

goog.require('Blockly.cake');
Severity: Minor
Found in generators/cake/stdio.js - About 5 hrs to fix

Consider simplifying this complex logical expression.
Open

            if(
                // childBlockType == 'math_number' || // issue #85
                childBlockType == 'math_arithmetic' ||
                childBlockType == 'math_modulo' ||
                childBlockType == 'library_math_abs' ||
Severity: Critical
Found in generators/cake/stdio.js - About 4 hrs to fix

Consider simplifying this complex logical expression.
Open

            else if (childBlockType == 'library_math_numcheck' ||
                childBlockType == 'library_math_numcompare' ||
                childBlockType == 'procedures_callreturn' ||
                childBlockType == 'logic_compare' ||
                childBlockType == 'logic_operation' ||
Severity: Critical
Found in generators/cake/stdio.js - About 2 hrs to fix

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

Blockly.cake.arrTypeCheckInScan = function(varName, childConnection) {
    var typeCode = '';
    var childBlock = childConnection.targetBlock();
    var arrList = Blockly.Blocks.getWantedBlockArray('a');

Severity: Minor
Found in generators/cake/stdio.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 pointerTypeCheckInPrint has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Blockly.cake.pointerTypeCheckInPrint = function(varName, checkDoubleAst) { // pointer type check
    var typeCode = '';
    var varList = Blockly.Variables.allVariables();

    if (checkDoubleAst == true){ // double pointer
Severity: Minor
Found in generators/cake/stdio.js - About 1 hr to fix

Function arrTypeCheckInScan has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Blockly.cake.arrTypeCheckInScan = function(varName, childConnection) {
    var typeCode = '';
    var childBlock = childConnection.targetBlock();
    var arrList = Blockly.Blocks.getWantedBlockArray('a');

Severity: Minor
Found in generators/cake/stdio.js - About 1 hr to fix

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

Blockly.cake.varTypeCheckInPrintScan = function(varName) { // variable type check
    var typeCode = '';
    var varList = Blockly.Variables.allVariables();

    for(var temp = 0 ; temp < varList.length ; temp++) {
Severity: Minor
Found in generators/cake/stdio.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

Avoid deeply nested control flow statements.
Open

            else if (childBlockType == 'variables_pointer_&')
            {
                if (childConnection.isSuperior()) {
                    childConnection.targetBlock().setParent(null);
                } else {
Severity: Major
Found in generators/cake/stdio.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                if (typeCode == '%c'){
                    typeCode = '%s';
                }
Severity: Major
Found in generators/cake/stdio.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                    if (type == 'dbchar') {
                        typeCode = '%s';
                    } else {
                        typeCode = '%p';
                    }
Severity: Major
Found in generators/cake/stdio.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                if (typeCode == '') {
                    inQutCode += argument;
                } else {
                    inQutCode += typeCode;
                    outQutCode += ', ' + argument;
Severity: Major
Found in generators/cake/stdio.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                    if (type == 'int') {
                        typeCode = '%d';
                    } else if (type == 'unsigned int') {
                        typeCode = '%u';
                    } else if (type == 'float') {
Severity: Major
Found in generators/cake/stdio.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

            else if (childBlockType == 'variables_pointer_get')
            {
                inQutCode += '%p';
                outQutCode += ', ' + argument;
            }
Severity: Major
Found in generators/cake/stdio.js - About 45 mins to fix

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

            if (type == 'int') {
                typeCode = '%d';
            } else if (type == 'unsigned int') {
                typeCode = '%u';
            } else if (type == 'float') {
Severity: Major
Found in generators/cake/stdio.js and 1 other location - About 3 hrs to fix
generators/cake/stdio.js on lines 365..377

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

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

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

            if (type == 'int') {
                typeCode = '%d';
            } else if (type == 'unsigned int') {
                typeCode = '%u';
            } else if (type == 'float') {
Severity: Major
Found in generators/cake/stdio.js and 1 other location - About 3 hrs to fix
generators/cake/stdio.js on lines 279..291

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

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

                childBlockType == 'math_arithmetic' ||
                childBlockType == 'math_modulo' ||
                childBlockType == 'library_math_abs' ||
                childBlockType == 'library_math_trig' ||
                childBlockType == 'library_math_logs' ||
Severity: Major
Found in generators/cake/stdio.js and 1 other location - About 2 hrs to fix
generators/cake/stdio.js on lines 116..127

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

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

Identical blocks of code found in 3 locations. Consider refactoring.
Open

            else if (childBlockType == 'library_math_numcheck' ||
                childBlockType == 'library_math_numcompare' ||
                childBlockType == 'procedures_callreturn' ||
                childBlockType == 'logic_compare' ||
                childBlockType == 'logic_operation' ||
Severity: Major
Found in generators/cake/stdio.js and 2 other locations - About 1 hr to fix
generators/cake/stdio.js on lines 226..257
generators/cake/stdio.js on lines 414..423

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

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

Identical blocks of code found in 3 locations. Consider refactoring.
Open

            else if (childBlockType == 'variables_pointer_&')
            {
                if (childConnection.isSuperior()) {
                    childConnection.targetBlock().setParent(null);
                } else {
Severity: Major
Found in generators/cake/stdio.js and 2 other locations - About 1 hr to fix
generators/cake/stdio.js on lines 116..147
generators/cake/stdio.js on lines 414..423

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

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

Identical blocks of code found in 3 locations. Consider refactoring.
Open

            if (childBlockType != 'library_stdio_text')
            {
                if (childConnection.isSuperior()) {
                    childConnection.targetBlock().setParent(null);
                } else {
Severity: Major
Found in generators/cake/stdio.js and 2 other locations - About 1 hr to fix
generators/cake/stdio.js on lines 116..147
generators/cake/stdio.js on lines 226..257

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

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.getParent()
        && (block.getParent().type == 'library_stdio_printf'
        || block.getParent().type == 'define_declare'
        || block.getParent().type == 'comment')) {
        return [code, Blockly.cake.ORDER_ATOMIC];
Severity: Major
Found in generators/cake/stdio.js and 2 other locations - About 1 hr to fix
core/blocks.js on lines 234..240
core/blocks.js on lines 261..265

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 (outQutCode == ''){
        code = 'scanf(\"' + inQutCode + '\");';
    } else {
        code = 'scanf(\"' + inQutCode + '\"' + outQutCode + ');';
    }
Severity: Major
Found in generators/cake/stdio.js and 1 other location - About 1 hr to fix
generators/cake/stdio.js on lines 151..155

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

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 (outQutCode == ''){
        code = 'printf(\"' + inQutCode + '\");';
    } else {
        code = 'printf(\"' + inQutCode + '\"' + outQutCode + ');';
    }
Severity: Major
Found in generators/cake/stdio.js and 1 other location - About 1 hr to fix
generators/cake/stdio.js on lines 261..265

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

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