cra16/cake-core

View on GitHub
core/realtime.js

Summary

Maintainability
C
1 day
Test Coverage

File realtime.js has 387 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * @license
 * Visual Blocks Editor
 *
 * Copyright 2014 Google Inc.
Severity: Minor
Found in core/realtime.js - About 5 hrs to fix

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

Blockly.Realtime.onObjectChange_ = function(evt) {
  var events = evt.events;
  var eventCount = evt.events.length;
  for (var i = 0; i < eventCount; i++) {
    var event = events[i];
Severity: Minor
Found in core/realtime.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 afterCreate_ has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Blockly.Realtime.afterCreate_ = function(fileId) {
  var resource = {
    'type': 'anyone',
    'role': 'writer',
    'value': 'default',
Severity: Minor
Found in core/realtime.js - About 1 hr to fix

Function blockChanged has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

Blockly.Realtime.blockChanged = function(block) {
  if (block.workspace == Blockly.mainWorkspace &&
      Blockly.Realtime.isEnabled() &&
      !Blockly.Realtime.withinSync) {
    var rootBlock = block.getRootBlock();
Severity: Minor
Found in core/realtime.js - About 45 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

Avoid deeply nested control flow statements.
Open

            if (!block.svg_) {
              // If this is a move of a newly disconnected (i.e newly top
              // level) block it will not have any svg (because it has been
              // disposed of by it's parent), so we need to handle that here.
              Blockly.Realtime.placeBlockOnWorkspace_(block, false);
Severity: Major
Found in core/realtime.js - About 45 mins to fix

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

Blockly.Realtime.placeBlockOnWorkspace_ = function(block, addToTop) {
  Blockly.Realtime.doWithinSync_(function() {
//    if (!Blockly.Realtime.blocksMap_.has(block.id)) {
//      Blockly.Realtime.blocksMap_.set(block.id, block);
//    }
Severity: Minor
Found in core/realtime.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

There are no issues that match your filters.

Category
Status