File realtime.js
has 387 lines of code (exceeds 250 allowed). Consider refactoring. Open
/**
* @license
* Visual Blocks Editor
*
* Copyright 2014 Google Inc.
- Create a ticketCreate a ticket
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];
- Read upRead up
- Create a ticketCreate a ticket
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',
- Create a ticketCreate a ticket
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();
- Read upRead up
- Create a ticketCreate a ticket
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);
- Create a ticketCreate a ticket
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);
// }
- Read upRead up
- Create a ticketCreate a ticket
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"