Showing 63 of 72 total issues
File doc.js
has 512 lines of code (exceeds 250 allowed). Consider refactoring. Open
import types from 'ottypes'
import {EventEmitter} from 'events'
import {isNoOp, tryCompose, xf} from './ops'
File session.js
has 476 lines of code (exceeds 250 allowed). Consider refactoring. Open
// This implements the network API for ShareJS.
//
// The wire protocol is speccced out here:
// https://github.com/josephg/ShareJS/wiki/Wire-Protocol
//
Function _handleMessage
has 153 lines of code (exceeds 25 allowed). Consider refactoring. Open
Session.prototype._handleMessage = function(req, callback) {
// First some checks of the incoming request. Error will be set to a value if a problem is found.
var error;
if ((error = this._checkRequest(req))) {
console.warn('Warning: Invalid request from ', this.agent.sessionId, req, 'Error: ', error);
Function _onMessage
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
_onMessage(msg) {
if ((msg.a === 'qfetch') !== (this.type === 'fetch')) {
if (console) console.warn('Invalid message sent to query', msg, this)
return
}
- Read upRead up
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 _handleMessage
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
Session.prototype._handleMessage = function(req, callback) {
// First some checks of the incoming request. Error will be set to a value if a problem is found.
var error;
if ((error = this._checkRequest(req))) {
console.warn('Warning: Invalid request from ', this.agent.sessionId, req, 'Error: ', error);
- Read upRead up
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
Doc
has 35 functions (exceeds 20 allowed). Consider refactoring. Open
class Doc extends EventEmitter {
constructor(connection, collection, name) {
super()
this.connection = connection
Function handleMessage
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
handleMessage(msg) {
const {
// action
a,
// collection name
- Read upRead up
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 json-api.js
has 325 lines of code (exceeds 250 allowed). Consider refactoring. Open
// JSON document API for the 'json0' type.
import types from 'ottypes'
import Context from '../context'
Function _otApply
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
_otApply(opData, context) {
this.locked = true
if (opData.create) {
// If the type is currently set, it means we tried creating the document
- Read upRead up
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 _onMessage
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
_onMessage(msg) {
if (msg.c !== this.collection || msg.d !== this.name) {
// This should never happen - its a sanity check for bugs
// in the connection code.
throw new Error(
- Read upRead up
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 exports
has 82 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function(share) {
var router = new Router();
var auth = function(req, res, next) {
if (req.session && req.session.shareAgent) {
File connection.js
has 286 lines of code (exceeds 250 allowed). Consider refactoring. Open
import {EventEmitter} from 'events'
import Doc from './doc'
import Query from './query'
Function _checkRequest
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
Session.prototype._checkRequest = function(req) {
if (req.a === 'qsub' || req.a === 'qfetch' || req.a === 'qunsub') {
// Query messages need an ID property.
if (typeof req.id !== 'number') return 'Missing query ID';
} else if (req.a === 'op' || req.a === 'sub' || req.a === 'unsub' || req.a === 'fetch') {
- Read upRead up
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 _onMessage
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
_onMessage(msg) {
if (msg.c !== this.collection || msg.d !== this.name) {
// This should never happen - its a sanity check for bugs
// in the connection code.
throw new Error(
Function _onMessage
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
_onMessage(msg) {
if ((msg.a === 'qfetch') !== (this.type === 'fetch')) {
if (console) console.warn('Invalid message sent to query', msg, this)
return
}
File useragent.js
has 266 lines of code (exceeds 250 allowed). Consider refactoring. Open
var hat = require('hat');
var TransformStream = require('stream').Transform;
var async = require('async');
Function bindToSocket
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
bindToSocket(socket) {
if (this.socket) {
delete this.socket.onopen
delete this.socket.onclose
delete this.socket.onmessage
- Read upRead up
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 _onOp
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
_onOp(op) {
op.forEach(c => {
this._fixComponentPaths(c)
if (c.lm !== void 0) {
Function handleMessage
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
handleMessage(msg) {
const {
// action
a,
// collection name
Function _processQueryResults
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
Session.prototype._processQueryResults = function(collection, results, qopts) {
var self = this;
var messages = [];
if (qopts.docMode === 'sub') {
var subscribeRequest = {};