cra16/cake-core

View on GitHub
generators/javascript/lists.js

Summary

Maintainability
F
1 wk
Test Coverage

Avoid deeply nested control flow statements.
Open

  } else if (where == 'RANDOM') {
    var code = cacheList();
    var xVar = Blockly.JavaScript.variableDB_.getDistinctName(
        'tmp_x', Blockly.Variables.NAME_TYPE);
    code += 'var ' + xVar + ' = Math.floor(Math.random() * ' + list +
Severity: Major
Found in generators/javascript/lists.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

    if (mode == 'GET') {
      var code = list + '.slice(-' + at + ')[0]';
      return [code, Blockly.JavaScript.ORDER_FUNCTION_CALL];
    } else if (mode == 'GET_REMOVE' || mode == 'REMOVE') {
      var functionName = Blockly.JavaScript.provideFunction_(
Severity: Major
Found in generators/javascript/lists.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

  } else if (where == 'RANDOM') {
    var functionName = Blockly.JavaScript.provideFunction_(
        'lists_get_random_item',
        [ 'function ' + Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_ +
            '(list, remove) {',
Severity: Major
Found in generators/javascript/lists.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

    if (mode == 'SET') {
      code += list + '[' + list + '.length - ' + at + '] = ' + value + ';\n';
      return code;
    } else if (mode == 'INSERT') {
      code += list + '.splice(' + list + '.length - ' + at + ', 0, ' + value +
Severity: Major
Found in generators/javascript/lists.js - About 45 mins to fix

Avoid too many return statements within this function.
Open

      return list + '.pop();\n';
Severity: Major
Found in generators/javascript/lists.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

      return list + '.splice(' + at + ', 0, ' + value + ');\n';
Severity: Major
Found in generators/javascript/lists.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

      return code;
Severity: Major
Found in generators/javascript/lists.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

      return code;
Severity: Major
Found in generators/javascript/lists.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

      return [code, Blockly.JavaScript.ORDER_FUNCTION_CALL];
Severity: Major
Found in generators/javascript/lists.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

      return code + ';\n';
Severity: Major
Found in generators/javascript/lists.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

      return list + '[' + at + '] = ' + value + ';\n';
Severity: Major
Found in generators/javascript/lists.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

      return [code, Blockly.JavaScript.ORDER_MEMBER];
Severity: Major
Found in generators/javascript/lists.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

      return [code, Blockly.JavaScript.ORDER_FUNCTION_CALL];
Severity: Major
Found in generators/javascript/lists.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

      return [code, Blockly.JavaScript.ORDER_MEMBER];
Severity: Major
Found in generators/javascript/lists.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

      return list + '.splice(' + at + ', 1);\n';
Severity: Major
Found in generators/javascript/lists.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

        return code + ';\n';
Severity: Major
Found in generators/javascript/lists.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

      return [code, Blockly.JavaScript.ORDER_FUNCTION_CALL];
Severity: Major
Found in generators/javascript/lists.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

      return code;
Severity: Major
Found in generators/javascript/lists.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

        return [code, Blockly.JavaScript.ORDER_FUNCTION_CALL];
Severity: Major
Found in generators/javascript/lists.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

      return code;
Severity: Major
Found in generators/javascript/lists.js - About 30 mins to fix

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

Blockly.JavaScript['lists_setIndex'] = function(block) {
  // Set element at index.
  // Note: Until February 2013 this block did not have MODE or WHERE inputs.
  var list = Blockly.JavaScript.valueToCode(block, 'LIST',
      Blockly.JavaScript.ORDER_MEMBER) || '[]';
Severity: Major
Found in generators/javascript/lists.js and 1 other location - About 4 days to fix
generators/cake/lists.js on lines 183..259

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

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

Blockly.JavaScript['lists_repeat'] = function(block) {
  // Create a list with one element repeated.
  var functionName = Blockly.JavaScript.provideFunction_(
      'lists_repeat',
      [ 'function ' + Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_ +
Severity: Major
Found in generators/javascript/lists.js and 1 other location - About 6 hrs to fix
generators/cake/lists.js on lines 48..66

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

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

Blockly.JavaScript['lists_indexOf'] = function(block) {
  // Find an item in the list.
  var operator = block.getFieldValue('END') == 'FIRST' ?
      'indexOf' : 'lastIndexOf';
  var argument0 = Blockly.JavaScript.valueToCode(block, 'FIND',
Severity: Major
Found in generators/javascript/lists.js and 5 other locations - About 6 hrs to fix
generators/cake/lists.js on lines 82..92
generators/cake/text.js on lines 89..99
generators/dart/lists.js on lines 74..84
generators/dart/text.js on lines 84..94
generators/javascript/text.js on lines 89..99

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

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

Blockly.JavaScript['lists_create_with'] = function(block) {
  // Create a list with any number of elements of any type.
  var code = new Array(block.itemCount_);
  for (var n = 0; n < block.itemCount_; n++) {
    code[n] = Blockly.JavaScript.valueToCode(block, 'ADD' + n,
Severity: Major
Found in generators/javascript/lists.js and 3 other locations - About 5 hrs to fix
generators/cake/lists.js on lines 37..46
generators/dart/lists.js on lines 39..48
generators/python/lists.js on lines 37..46

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

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 (where == 'FROM_END') {
    if (mode == 'GET') {
      var code = list + '.slice(-' + at + ')[0]';
      return [code, Blockly.JavaScript.ORDER_FUNCTION_CALL];
    } else if (mode == 'GET_REMOVE' || mode == 'REMOVE') {
Severity: Major
Found in generators/javascript/lists.js and 1 other location - About 5 hrs to fix
generators/cake/lists.js on lines 142..179

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

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 (mode == 'GET') {
      var code = list + '.slice(-' + at + ')[0]';
      return [code, Blockly.JavaScript.ORDER_FUNCTION_CALL];
    } else if (mode == 'GET_REMOVE' || mode == 'REMOVE') {
      var functionName = Blockly.JavaScript.provideFunction_(
Severity: Major
Found in generators/javascript/lists.js and 2 other locations - About 4 hrs to fix
generators/cake/lists.js on lines 143..160
generators/dart/lists.js on lines 135..159

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

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 (mode == 'GET') {
      var code = list + '[' + at + ']';
      return [code, Blockly.JavaScript.ORDER_MEMBER];
    } else if (mode == 'GET_REMOVE') {
      var code = list + '.splice(' + at + ', 1)[0]';
Severity: Major
Found in generators/javascript/lists.js and 1 other location - About 4 hrs to fix
generators/dart/lists.js on lines 125..133

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

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

  } else if (where == 'LAST') {
    if (mode == 'GET') {
      var code = list + '.slice(-1)[0]';
      return [code, Blockly.JavaScript.ORDER_MEMBER];
    } else if (mode == 'GET_REMOVE') {
Severity: Major
Found in generators/javascript/lists.js and 3 other locations - About 3 hrs to fix
generators/dart/lists.js on lines 96..180
generators/dart/lists.js on lines 106..180
generators/javascript/lists.js on lines 104..179

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

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

  if (where == 'FIRST') {
    if (mode == 'GET') {
      var code = list + '[0]';
      return [code, Blockly.JavaScript.ORDER_MEMBER];
    } else if (mode == 'GET_REMOVE') {
Severity: Major
Found in generators/javascript/lists.js and 3 other locations - About 3 hrs to fix
generators/dart/lists.js on lines 96..180
generators/dart/lists.js on lines 106..180
generators/javascript/lists.js on lines 114..179

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

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

Blockly.JavaScript['lists_isEmpty'] = function(block) {
  // Is the list empty?
  var argument0 = Blockly.JavaScript.valueToCode(block, 'VALUE',
      Blockly.JavaScript.ORDER_MEMBER) || '[]';
  return ['!' + argument0 + '.length', Blockly.JavaScript.ORDER_LOGICAL_NOT];
Severity: Major
Found in generators/javascript/lists.js and 3 other locations - About 2 hrs to fix
generators/cake/lists.js on lines 75..80
generators/python/lists.js on lines 58..63
generators/python/text.js on lines 79..84

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

Blockly.JavaScript['lists_length'] = function(block) {
  // List length.
  var argument0 = Blockly.JavaScript.valueToCode(block, 'VALUE',
      Blockly.JavaScript.ORDER_FUNCTION_CALL) || '[]';
  return [argument0 + '.length', Blockly.JavaScript.ORDER_MEMBER];
Severity: Major
Found in generators/javascript/lists.js and 7 other locations - About 1 hr to fix
generators/cake/lists.js on lines 68..73
generators/cake/text.js on lines 75..80
generators/dart/lists.js on lines 60..65
generators/dart/lists.js on lines 67..72
generators/dart/text.js on lines 70..75
generators/dart/text.js on lines 77..82
generators/javascript/text.js on lines 75..80

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

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