cra16/cake-core

View on GitHub
generators/dart/lists.js

Summary

Maintainability
F
5 days
Test Coverage

File lists.js has 252 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * @license
 * Visual Blocks Language
 *
 * Copyright 2014 Google Inc.
Severity: Minor
Found in generators/dart/lists.js - About 2 hrs to fix

Avoid deeply nested control flow statements.
Open

  } else if (where == 'RANDOM') {
    Blockly.Dart.definitions_['import_dart_math'] =
        'import \'dart:math\' as Math;';
    var functionName = Blockly.Dart.provideFunction_(
        'lists_get_random_item',
Severity: Major
Found in generators/dart/lists.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

  } else if (where == 'RANDOM') {
    Blockly.Dart.definitions_['import_dart_math'] =
        'import \'dart:math\' as Math;';
    var code = cacheList();
    var xVar = Blockly.Dart.variableDB_.getDistinctName(
Severity: Major
Found in generators/dart/lists.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

    if (mode == 'GET') {
      var functionName = Blockly.Dart.provideFunction_(
          'lists_get_from_end',
          [ 'dynamic ' + Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_ +
              '(List myList, num x) {',
Severity: Major
Found in generators/dart/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 + '.insert(' + list + '.length - ' + at + ', ' +
Severity: Major
Found in generators/dart/lists.js - About 45 mins to fix

Consider simplifying this complex logical expression.
Open

  if ((where1 == 'FIRST' || where1 == 'FROM_START' && Blockly.isNumber(at1)) &&
      (where2 == 'LAST' || where2 == 'FROM_START' && Blockly.isNumber(at2))) {
    // Simple case that can be done inline.
    at1 = where1 == 'FIRST' ? 0 : parseInt(at1, 10) - 1;
    if (where2 == 'LAST') {
Severity: Major
Found in generators/dart/lists.js - About 40 mins to fix

Avoid too many return statements within this function.
Open

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

Avoid too many return statements within this function.
Open

      return [code, Blockly.Dart.ORDER_UNARY_POSTFIX];
Severity: Major
Found in generators/dart/lists.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

      return [code, Blockly.Dart.ORDER_UNARY_POSTFIX];
Severity: Major
Found in generators/dart/lists.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

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

Avoid too many return statements within this function.
Open

        return [code, Blockly.Dart.ORDER_UNARY_POSTFIX];
Severity: Major
Found in generators/dart/lists.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

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

Avoid too many return statements within this function.
Open

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

Avoid too many return statements within this function.
Open

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

Avoid too many return statements within this function.
Open

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

Avoid too many return statements within this function.
Open

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

Avoid too many return statements within this function.
Open

      return [code, Blockly.Dart.ORDER_UNARY_POSTFIX];
Severity: Major
Found in generators/dart/lists.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

      return list + '.removeAt(' + at + ');\n';
Severity: Major
Found in generators/dart/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/dart/lists.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

      return [code, Blockly.Dart.ORDER_UNARY_POSTFIX];
Severity: Major
Found in generators/dart/lists.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

      return [code, Blockly.Dart.ORDER_UNARY_POSTFIX];
Severity: Major
Found in generators/dart/lists.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

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

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

Blockly.Dart['lists_indexOf'] = function(block) {
  // Find an item in the list.
  var operator = block.getFieldValue('END') == 'FIRST' ?
      'indexOf' : 'lastIndexOf';
  var argument0 = Blockly.Dart.valueToCode(block, 'FIND',
Severity: Major
Found in generators/dart/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/text.js on lines 84..94
generators/javascript/lists.js on lines 82..92
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.Dart['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.Dart.valueToCode(block, 'ADD' + n,
Severity: Major
Found in generators/dart/lists.js and 3 other locations - About 5 hrs to fix
generators/cake/lists.js on lines 37..46
generators/javascript/lists.js on lines 37..46
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 3 locations. Consider refactoring.
Open

    if (mode == 'GET') {
      var functionName = Blockly.Dart.provideFunction_(
          'lists_get_from_end',
          [ 'dynamic ' + Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_ +
              '(List myList, num x) {',
Severity: Major
Found in generators/dart/lists.js and 2 other locations - About 4 hrs to fix
generators/cake/lists.js on lines 143..160
generators/javascript/lists.js on lines 143..160

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.Dart.ORDER_UNARY_POSTFIX];
    } else if (mode == 'GET_REMOVE') {
      var code = list + '.removeAt(' + at + ')';
Severity: Major
Found in generators/dart/lists.js and 1 other location - About 4 hrs to fix
generators/javascript/lists.js on lines 133..141

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

  if (where == 'FIRST') {
    if (mode == 'GET') {
      var code = list + '.first';
      return [code, Blockly.Dart.ORDER_UNARY_POSTFIX];
    } else if (mode == 'GET_REMOVE') {
Severity: Major
Found in generators/dart/lists.js and 3 other locations - About 3 hrs to fix
generators/dart/lists.js on lines 106..180
generators/javascript/lists.js on lines 104..179
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

  } else if (where == 'LAST') {
    if (mode == 'GET') {
      var code = list + '.last';
      return [code, Blockly.Dart.ORDER_UNARY_POSTFIX];
    } else if (mode == 'GET_REMOVE') {
Severity: Major
Found in generators/dart/lists.js and 3 other locations - About 3 hrs to fix
generators/dart/lists.js on lines 96..180
generators/javascript/lists.js on lines 104..179
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 8 locations. Consider refactoring.
Open

Blockly.Dart['lists_length'] = function(block) {
  // List length.
  var argument0 = Blockly.Dart.valueToCode(block, 'VALUE',
      Blockly.Dart.ORDER_UNARY_POSTFIX) || '[]';
  return [argument0 + '.length', Blockly.Dart.ORDER_UNARY_POSTFIX];
Severity: Major
Found in generators/dart/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 67..72
generators/dart/text.js on lines 70..75
generators/dart/text.js on lines 77..82
generators/javascript/lists.js on lines 68..73
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

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

Blockly.Dart['lists_isEmpty'] = function(block) {
  // Is the list empty?
  var argument0 = Blockly.Dart.valueToCode(block, 'VALUE',
      Blockly.Dart.ORDER_UNARY_POSTFIX) || '[]';
  return [argument0 + '.isEmpty', Blockly.Dart.ORDER_UNARY_POSTFIX];
Severity: Major
Found in generators/dart/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/text.js on lines 70..75
generators/dart/text.js on lines 77..82
generators/javascript/lists.js on lines 68..73
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

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

    if (Blockly.isNumber(at)) {
      // If the index is a naked number, decrement it right now.
      at = parseInt(at, 10) - 1;
    } else {
      // If the index is dynamic, decrement it in code.
Severity: Minor
Found in generators/dart/lists.js and 1 other location - About 40 mins to fix
generators/dart/lists.js on lines 223..229

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

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

    if (Blockly.isNumber(at)) {
      // If the index is a naked number, decrement it right now.
      at = parseInt(at, 10) - 1;
    } else {
      // If the index is dynamic, decrement it in code.
Severity: Minor
Found in generators/dart/lists.js and 1 other location - About 40 mins to fix
generators/dart/lists.js on lines 118..124

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