lib/sync.js

Summary

Maintainability
F
3 days
Test Coverage

Function Client has 209 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var Client = (function(){

    var Options = {
        OVERWRITE_ALWAYS: 0,
        OVERWRITE_NEVER: 1,
Severity: Major
Found in lib/sync.js - About 1 day to fix

    Function Client has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

    var Client = (function(){
    
        var Options = {
            OVERWRITE_ALWAYS: 0,
            OVERWRITE_NEVER: 1,
    Severity: Minor
    Found in lib/sync.js - About 4 hrs 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 syncImpl has 58 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        Client.prototype.syncImpl = function(localQueries, remoteQueries, overwrite, deleteOrphaned, simulate, isOriginRemote){
            var that = this;
            var promises = [];
            var origin = isOriginRemote ? remoteQueries : localQueries;
            var target = isOriginRemote ? localQueries : remoteQueries;
    Severity: Major
    Found in lib/sync.js - About 2 hrs to fix

      Function commit has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          Client.prototype.commit = function(simulate, diffs){
              var that = this;
              var modulePromises = [];
              var queryPromises = [];
              diffs.forEach(function(diff){
      Severity: Minor
      Found in lib/sync.js - About 1 hr to fix

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

            Client.prototype.syncImpl = function(localQueries, remoteQueries, overwrite, deleteOrphaned, simulate, isOriginRemote){
        Severity: Minor
        Found in lib/sync.js - About 45 mins to fix

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

              Client.prototype.sync = function(overwrite, deleteOrphaned, simulate, ignore, isOriginRemote, concurrency){
          Severity: Minor
          Found in lib/sync.js - About 45 mins to fix

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

                Client.prototype.upload = function(overwrite, deleteOrphaned, simulate, ignore, concurrency){
            Severity: Minor
            Found in lib/sync.js - About 35 mins to fix

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

                  Client.prototype.download = function(overwrite, deleteOrphaned, simulate, ignore, concurrency){
              Severity: Minor
              Found in lib/sync.js - About 35 mins to fix

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                            } else if(diff.type === 'write'){
                                if(diff.isOriginRemote) {
                                    container.push(function(){ return that.writeLocalQuery(diff); });
                                } else {
                                    container.push(function(){ return that.writeRemoteQuery(diff); });
                Severity: Major
                Found in lib/sync.js and 1 other location - About 1 hr to fix
                lib/sync.js on lines 161..167

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 72.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                            } else {
                                if(diff.isOriginRemote) {
                                    container.push(function(){ return that.deleteLocalQuery(diff); });
                                } else {
                                    container.push(function(){ return that.deleteRemoteQuery(diff); });
                Severity: Major
                Found in lib/sync.js and 1 other location - About 1 hr to fix
                lib/sync.js on lines 155..161

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 72.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                            function(){
                                var promises = [];
                                modulePromises.forEach(function(promise){
                                    promises.push(promise());
                                });
                Severity: Major
                Found in lib/sync.js and 1 other location - About 1 hr to fix
                lib/sync.js on lines 191..197

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 64.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                            function(){
                                var promises = [];
                                queryPromises.forEach(function(promise){
                                    promises.push(promise());
                                });
                Severity: Major
                Found in lib/sync.js and 1 other location - About 1 hr to fix
                lib/sync.js on lines 184..190

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 64.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 3 locations. Consider refactoring.
                Open

                    Client.prototype.deleteRemoteQuery = function(diff){
                        return this.vfs.deleteRemoteQuery(diff.query).then(function(){ logDiff(diff); });
                    };
                Severity: Major
                Found in lib/sync.js and 2 other locations - About 1 hr to fix
                lib/sync.js on lines 124..126
                lib/sync.js on lines 139..141

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 60.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 3 locations. Consider refactoring.
                Open

                    Client.prototype.writeLocalQuery = function(diff){
                        return this.vfs.writeLocalQuery(diff.query).then(function(){ logDiff(diff); });
                    };
                Severity: Major
                Found in lib/sync.js and 2 other locations - About 1 hr to fix
                lib/sync.js on lines 139..141
                lib/sync.js on lines 143..145

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 60.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 3 locations. Consider refactoring.
                Open

                    Client.prototype.deleteLocalQuery = function(diff){
                        return this.vfs.deleteLocalQuery(diff.query).then(function(){ logDiff(diff); });
                    };
                Severity: Major
                Found in lib/sync.js and 2 other locations - About 1 hr to fix
                lib/sync.js on lines 124..126
                lib/sync.js on lines 143..145

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 60.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                There are no issues that match your filters.

                Category
                Status