nponiros/sync_server

View on GitHub

Showing 12 of 43 total issues

Function initSocketHandler has 105 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function initSocketHandler(db, logger, opts, currentDBRevision) {
  // connID to callback
  const subscriptions = new Map();
  const connToClientIdentity = new Map();
  const clientIDToRevision = new Map();
Severity: Major
Found in lib/sync/socket_handler.js - About 4 hrs to fix

    Function applyClientChanges has 64 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function applyClientChanges(db, baseRevision, currentRevision, clientChanges, clientIdentity) {
      function handleCreate(change) {
        return db.addData(change.table, change.key, change.obj)
          .then(() => {
            return db.addChangesData({
    Severity: Major
    Found in lib/sync/apply_client_changes.js - About 2 hrs to fix

      Function initPollHandler has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function initPollHandler(db, logger, opts, currentDBRevision) {
        return function handler({
            baseRevision,
            changes = [],
            clientIdentity,
      Severity: Minor
      Found in lib/sync/poll_handler.js - About 1 hr to fix

        Function resolveConflicts has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        module.exports = function resolveConflicts(clientChanges, serverChangeSet) {
          const resolved = [];
          clientChanges
            .forEach((clientChange) => {
              const id = `${clientChange.table}:${clientChange.key}`;
        Severity: Minor
        Found in lib/sync/resolve_conflicts.js - About 1 hr to fix

          Function setByKeyPath has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          module.exports = function setByKeyPath(obj, keyPath, value) {
            if (!obj || typeof keyPath !== 'string') {
              return;
            }
            const period = keyPath.indexOf('.');
          Severity: Minor
          Found in lib/sync/set_key_path.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 sync has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            function sync() {
              const dataToSend = {
                baseRevision,
                changes,
                clientIdentity,
          Severity: Minor
          Found in samples/ajax/index.js - About 1 hr to fix

            Function getServerChanges has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            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))
            Severity: Minor
            Found in lib/sync/get_server_changes.js - About 1 hr to fix

              Function combineUpdateAndUpdate has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              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)
              Severity: Minor
              Found in lib/sync/combine_update_and_update.js - About 1 hr to fix

                Function initSocketHandler has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                function initSocketHandler(db, logger, opts, currentDBRevision) {
                  // connID to callback
                  const subscriptions = new Map();
                  const connToClientIdentity = new Map();
                  const clientIDToRevision = new Map();
                Severity: Minor
                Found in lib/sync/socket_handler.js - About 55 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

                Function handleClientChanges has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                function handleClientChanges(db, baseRevision, nextRevision, partial, clientID, changes) {
                Severity: Minor
                Found in lib/sync/handle_client_changes.js - About 45 mins to fix

                  Function applyClientChanges has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  function applyClientChanges(db, baseRevision, currentRevision, clientChanges, clientIdentity) {
                  Severity: Minor
                  Found in lib/sync/apply_client_changes.js - About 35 mins to fix

                    Function getServerChanges has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    function getServerChanges(db, syncedRevision, clientIdentity, partialsThreshold, currentDBRevision) {
                    Severity: Minor
                    Found in lib/sync/get_server_changes.js - About 35 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language