Showing 12 of 43 total issues
Function initSocketHandler
has 105 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function initSocketHandler(db, logger, opts, currentDBRevision) {
// connID to callback
const subscriptions = new Map();
const connToClientIdentity = new Map();
const clientIDToRevision = new Map();
Function applyClientChanges
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function applyClientChanges(db, baseRevision, currentRevision, clientChanges, clientIdentity) {
function handleCreate(change) {
return db.addData(change.table, change.key, change.obj)
.then(() => {
return db.addChangesData({
Function initPollHandler
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function initPollHandler(db, logger, opts, currentDBRevision) {
return function handler({
baseRevision,
changes = [],
clientIdentity,
Function resolveConflicts
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
module.exports = function resolveConflicts(clientChanges, serverChangeSet) {
const resolved = [];
clientChanges
.forEach((clientChange) => {
const id = `${clientChange.table}:${clientChange.key}`;
Function setByKeyPath
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
Open
module.exports = function setByKeyPath(obj, keyPath, value) {
if (!obj || typeof keyPath !== 'string') {
return;
}
const period = keyPath.indexOf('.');
- 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 getServerChanges
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function getServerChanges(db, syncedRevision, clientIdentity, partialsThreshold, currentDBRevision) {
// Get all changes after syncedRevision that was not performed by the client we're talking to.
return db.getChangesData(syncedRevision, clientIdentity)
// Compact changes so that multiple changes on same object are merged into a single change.
.then((changes) => reduceChanges(changes))
Function sync
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function sync() {
const dataToSend = {
baseRevision,
changes,
clientIdentity,
Function combineUpdateAndUpdate
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
module.exports = function combineUpdateAndUpdate(prevChange, nextChange) {
// Clone object before modifying since the earlier change in db.changes[] would otherwise be altered.
const clonedChange = deepClone(prevChange);
Object
.keys(nextChange.mods)
Function initSocketHandler
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
Open
function initSocketHandler(db, logger, opts, currentDBRevision) {
// connID to callback
const subscriptions = new Map();
const connToClientIdentity = new Map();
const clientIDToRevision = new Map();
- 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 handleClientChanges
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
function handleClientChanges(db, baseRevision, nextRevision, partial, clientID, changes) {
Function applyClientChanges
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
function applyClientChanges(db, baseRevision, currentRevision, clientChanges, clientIdentity) {
Function getServerChanges
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
function getServerChanges(db, syncedRevision, clientIdentity, partialsThreshold, currentDBRevision) {