cra16/cake-core

View on GitHub
blockly/apps/blockfactory/factory.js

Summary

Maintainability
F
5 days
Test Coverage

Function getFields has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

function getFields(block) {
  var fields = [];
  while (block) {
    if (!block.disabled && !block.getInheritedDisabled()) {
      switch (block.type) {
Severity: Minor
Found in blockly/apps/blockfactory/factory.js - About 5 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 factory.js has 372 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * Blockly Apps: Block Factory
 *
 * Copyright 2012 Google Inc.
 * https://blockly.googlecode.com/
Severity: Minor
Found in blockly/apps/blockfactory/factory.js - About 4 hrs to fix

Function updateLanguage has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

function updateLanguage() {
  // Generate name.
  var code = [];
  code.push("Blockly.Blocks['" + blockType + "'] = {");
  var rootBlock = getRootBlock();
Severity: Minor
Found in blockly/apps/blockfactory/factory.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 getFields has 82 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function getFields(block) {
  var fields = [];
  while (block) {
    if (!block.disabled && !block.getInheritedDisabled()) {
      switch (block.type) {
Severity: Major
Found in blockly/apps/blockfactory/factory.js - About 3 hrs to fix

Function updateGenerator has 73 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function updateGenerator() {
  function makeVar(root, name) {
    name = name.toLowerCase().replace(/\W/g, '_');
    return '  var ' + root + '_' + name;
  }
Severity: Major
Found in blockly/apps/blockfactory/factory.js - About 2 hrs to fix

Function updateLanguage has 66 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function updateLanguage() {
  // Generate name.
  var code = [];
  code.push("Blockly.Blocks['" + blockType + "'] = {");
  var rootBlock = getRootBlock();
Severity: Major
Found in blockly/apps/blockfactory/factory.js - About 2 hrs to fix

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

function init() {
  if ('BlocklyStorage' in window) {
    BlocklyStorage.HTTPREQUEST_ERROR =
      'There was a problem with the request.\n';
    BlocklyStorage.LINK_ALERT =
Severity: Minor
Found in blockly/apps/blockfactory/factory.js - About 1 hr to fix

Function getTypesFrom_ has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

function getTypesFrom_(block, name) {
  var typeBlock = block.getInputTargetBlock(name);
  var types;
  if (!typeBlock || typeBlock.disabled) {
    types = [];
Severity: Minor
Found in blockly/apps/blockfactory/factory.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 updateGenerator has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

function updateGenerator() {
  function makeVar(root, name) {
    name = name.toLowerCase().replace(/\W/g, '_');
    return '  var ' + root + '_' + name;
  }
Severity: Minor
Found in blockly/apps/blockfactory/factory.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 init has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function init() {
  if ('BlocklyStorage' in window) {
    BlocklyStorage.HTTPREQUEST_ERROR =
      'There was a problem with the request.\n';
    BlocklyStorage.LINK_ALERT =
Severity: Minor
Found in blockly/apps/blockfactory/factory.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 5 locations. Consider refactoring.
Open

        case 'field_variable_pointer':
          // Result:
          // new Blockly.FieldVariablePointer('item'), 'VAR'
          var varname = block.getFieldValue('TEXT');
          varname = varname ? escapeString(varname) : 'null';
Severity: Major
Found in blockly/apps/blockfactory/factory.js and 4 other locations - About 2 hrs to fix
blockly/apps/blockfactory/factory.js on lines 191..198
blockly/apps/blockfactory/factory.js on lines 209..216
blockly/apps/blockfactory/factory.js on lines 218..225
blockly/apps/blockfactory/factory.js on lines 227..234

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

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

        case 'field_variable':
          // Result:
          // new Blockly.FieldVariable('item'), 'VAR'
          var varname = block.getFieldValue('TEXT');
          varname = varname ? escapeString(varname) : 'null';
Severity: Major
Found in blockly/apps/blockfactory/factory.js and 4 other locations - About 2 hrs to fix
blockly/apps/blockfactory/factory.js on lines 200..207
blockly/apps/blockfactory/factory.js on lines 209..216
blockly/apps/blockfactory/factory.js on lines 218..225
blockly/apps/blockfactory/factory.js on lines 227..234

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

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

        case 'field_variable_array':
          // Result:
          // new Blockly.FieldVariableArray('item'), 'VAR'
          var varname = block.getFieldValue('TEXT');
          varname = varname ? escapeString(varname) : 'null';
Severity: Major
Found in blockly/apps/blockfactory/factory.js and 4 other locations - About 2 hrs to fix
blockly/apps/blockfactory/factory.js on lines 191..198
blockly/apps/blockfactory/factory.js on lines 200..207
blockly/apps/blockfactory/factory.js on lines 218..225
blockly/apps/blockfactory/factory.js on lines 227..234

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

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

        case 'field_variable_define':
          // Result:
          // new Blockly.FieldVariableArray('item'), 'VAR'
          var varname = block.getFieldValue('TEXT');
          varname = varname ? escapeString(varname) : 'null';
Severity: Major
Found in blockly/apps/blockfactory/factory.js and 4 other locations - About 2 hrs to fix
blockly/apps/blockfactory/factory.js on lines 191..198
blockly/apps/blockfactory/factory.js on lines 200..207
blockly/apps/blockfactory/factory.js on lines 209..216
blockly/apps/blockfactory/factory.js on lines 227..234

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

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

        case 'field_structure':
          // Result:
          // new Blockly.FieldVariableArray('item'), 'VAR'
          var varname = block.getFieldValue('TEXT');
          varname = varname ? escapeString(varname) : 'null';
Severity: Major
Found in blockly/apps/blockfactory/factory.js and 4 other locations - About 2 hrs to fix
blockly/apps/blockfactory/factory.js on lines 191..198
blockly/apps/blockfactory/factory.js on lines 200..207
blockly/apps/blockfactory/factory.js on lines 209..216
blockly/apps/blockfactory/factory.js on lines 218..225

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

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

        case 'input_statement':
          var name = block.getFieldValue('INPUTNAME');
          code.push(makeVar('statements', name) +
            " = Blockly." + language + ".statementToCode(block, '" +
            name + "');");
Severity: Major
Found in blockly/apps/blockfactory/factory.js and 1 other location - About 1 hr to fix
blockly/apps/blockfactory/factory.js on lines 378..384

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

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

        case 'field_variable':
          var name = block.getFieldValue('FIELDNAME');
          code.push(makeVar('variable', name) +
            " = Blockly." + language +
            ".variableDB_.getName(block.getFieldValue('" + name +
Severity: Major
Found in blockly/apps/blockfactory/factory.js and 1 other location - About 1 hr to fix
blockly/apps/blockfactory/factory.js on lines 391..396

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

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

        case 'field_input':
          // Result: new Blockly.FieldTextInput('Hello'), 'GREET'
          fields.push('new Blockly.FieldTextInput(' +
            escapeString(block.getFieldValue('TEXT')) + '), ' +
            escapeString(block.getFieldValue('FIELDNAME')));
Severity: Major
Found in blockly/apps/blockfactory/factory.js and 3 other locations - About 55 mins to fix
blockly/apps/blockfactory/factory.js on lines 173..178
blockly/apps/blockfactory/factory.js on lines 179..184
blockly/apps/blockfactory/factory.js on lines 185..190

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

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

        case 'field_colour':
          // Result: new Blockly.FieldColour('#ff0000'), 'COLOUR'
          fields.push('new Blockly.FieldColour(' +
            escapeString(block.getFieldValue('COLOUR')) + '), ' +
            escapeString(block.getFieldValue('FIELDNAME')));
Severity: Major
Found in blockly/apps/blockfactory/factory.js and 3 other locations - About 55 mins to fix
blockly/apps/blockfactory/factory.js on lines 167..172
blockly/apps/blockfactory/factory.js on lines 173..178
blockly/apps/blockfactory/factory.js on lines 179..184

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

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

        case 'field_checkbox':
          // Result: new Blockly.FieldCheckbox('TRUE'), 'CHECK'
          fields.push('new Blockly.FieldCheckbox(' +
            escapeString(block.getFieldValue('CHECKED')) + '), ' +
            escapeString(block.getFieldValue('FIELDNAME')));
Severity: Major
Found in blockly/apps/blockfactory/factory.js and 3 other locations - About 55 mins to fix
blockly/apps/blockfactory/factory.js on lines 167..172
blockly/apps/blockfactory/factory.js on lines 173..178
blockly/apps/blockfactory/factory.js on lines 185..190

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

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

        case 'field_angle':
          // Result: new Blockly.FieldAngle(90), 'ANGLE'
          fields.push('new Blockly.FieldAngle(' +
            escapeString(block.getFieldValue('ANGLE')) + '), ' +
            escapeString(block.getFieldValue('FIELDNAME')));
Severity: Major
Found in blockly/apps/blockfactory/factory.js and 3 other locations - About 55 mins to fix
blockly/apps/blockfactory/factory.js on lines 167..172
blockly/apps/blockfactory/factory.js on lines 179..184
blockly/apps/blockfactory/factory.js on lines 185..190

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

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

        case 'field_checkbox':
          var name = block.getFieldValue('FIELDNAME');
          code.push(makeVar('checkbox', name) +
            " = block.getFieldValue('" + name + "') == 'TRUE';");
          break;
Severity: Major
Found in blockly/apps/blockfactory/factory.js and 4 other locations - About 40 mins to fix
blockly/apps/blockfactory/factory.js on lines 353..357
blockly/apps/blockfactory/factory.js on lines 358..362
blockly/apps/blockfactory/factory.js on lines 363..367
blockly/apps/blockfactory/factory.js on lines 373..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 48.

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

        case 'field_angle':
          var name = block.getFieldValue('FIELDNAME');
          code.push(makeVar('angle', name) +
            " = block.getFieldValue('" + name + "');");
          break;
Severity: Major
Found in blockly/apps/blockfactory/factory.js and 4 other locations - About 40 mins to fix
blockly/apps/blockfactory/factory.js on lines 353..357
blockly/apps/blockfactory/factory.js on lines 363..367
blockly/apps/blockfactory/factory.js on lines 368..372
blockly/apps/blockfactory/factory.js on lines 373..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 48.

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

        case 'field_dropdown':
          var name = block.getFieldValue('FIELDNAME');
          code.push(makeVar('dropdown', name) +
            " = block.getFieldValue('" + name + "');");
          break;
Severity: Major
Found in blockly/apps/blockfactory/factory.js and 4 other locations - About 40 mins to fix
blockly/apps/blockfactory/factory.js on lines 353..357
blockly/apps/blockfactory/factory.js on lines 358..362
blockly/apps/blockfactory/factory.js on lines 368..372
blockly/apps/blockfactory/factory.js on lines 373..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 48.

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

        case 'field_colour':
          var name = block.getFieldValue('FIELDNAME');
          code.push(makeVar('colour', name) +
            " = block.getFieldValue('" + name + "');");
          break;
Severity: Major
Found in blockly/apps/blockfactory/factory.js and 4 other locations - About 40 mins to fix
blockly/apps/blockfactory/factory.js on lines 353..357
blockly/apps/blockfactory/factory.js on lines 358..362
blockly/apps/blockfactory/factory.js on lines 363..367
blockly/apps/blockfactory/factory.js on lines 368..372

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

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

        case 'field_input':
          var name = block.getFieldValue('FIELDNAME');
          code.push(makeVar('text', name) +
            " = block.getFieldValue('" + name + "');");
          break;
Severity: Major
Found in blockly/apps/blockfactory/factory.js and 4 other locations - About 40 mins to fix
blockly/apps/blockfactory/factory.js on lines 358..362
blockly/apps/blockfactory/factory.js on lines 363..367
blockly/apps/blockfactory/factory.js on lines 368..372
blockly/apps/blockfactory/factory.js on lines 373..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 48.

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