neotoma/sync-server

View on GitHub

Showing 278 of 278 total issues

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

        result: function(itemPutUrl, done) {
          assert.equal(itemPutUrl, templateCompiler('https://${host}/test-path${path}?foo=bar&access_token=${accessToken}', {
            host: this.context.host,
            path: this.params[0],
            accessToken: this.params[1].storageToken
Severity: Major
Found in tests/models.js and 1 other location - About 2 hrs to fix
tests/models.js on lines 118..125

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 79.

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

        result: function(itemPutUrl, done) {
          assert.equal(itemPutUrl, templateCompiler('https://${host}${path}?access_token=${accessToken}', {
            host: this.context.host,
            path: this.params[0],
            accessToken: this.params[1].storageToken
Severity: Major
Found in tests/models.js and 1 other location - About 2 hrs to fix
tests/models.js on lines 106..113

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 79.

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

Function before has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    before: function(done) {
      var storage, userStorageAuth;

      var saveContentType = (done) => {
        wh.oneSaved('contentType', {
Severity: Major
Found in tests/controllers/item/storeItemData.js - About 2 hrs to fix

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

      }, {
        when: 'relationships parameter has no user property',
        params: [wh.itemDataObject(), wh.itemRelationships()],
        error: 'Parameter relationships has no user property',
        before: function(done) {
    Severity: Major
    Found in tests/controllers/item/persistItemDataObject.js and 4 other locations - About 2 hrs to fix
    tests/controllers/item/persistItemDataObject.js on lines 22..33
    tests/controllers/item/persistItemDataObject.js on lines 44..55
    tests/controllers/item/persistItemDataObject.js on lines 55..66
    tests/controllers/item/persistItemDataObject.js on lines 66..77

    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 77.

    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 5 locations. Consider refactoring.
    Open

      }, {
        when: 'relationships parameter has no contentType property',
        params: [wh.itemDataObject(), wh.itemRelationships()],
        error: 'Parameter relationships has no contentType property',
        before: function(done) {
    Severity: Major
    Found in tests/controllers/item/persistItemDataObject.js and 4 other locations - About 2 hrs to fix
    tests/controllers/item/persistItemDataObject.js on lines 22..33
    tests/controllers/item/persistItemDataObject.js on lines 33..44
    tests/controllers/item/persistItemDataObject.js on lines 44..55
    tests/controllers/item/persistItemDataObject.js on lines 55..66

    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 77.

    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 5 locations. Consider refactoring.
    Open

      }, {
        when: 'itemDataObject parameter has no id property',
        params: [wh.itemDataObject(), wh.itemRelationships()],
        error: 'Parameter itemDataObject has no id property',
        before: function(done) {
    Severity: Major
    Found in tests/controllers/item/persistItemDataObject.js and 4 other locations - About 2 hrs to fix
    tests/controllers/item/persistItemDataObject.js on lines 33..44
    tests/controllers/item/persistItemDataObject.js on lines 44..55
    tests/controllers/item/persistItemDataObject.js on lines 55..66
    tests/controllers/item/persistItemDataObject.js on lines 66..77

    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 77.

    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 5 locations. Consider refactoring.
    Open

      }, {
        when: 'relationships parameter has no storage property',
        params: [wh.itemDataObject(), wh.itemRelationships()],
        error: 'Parameter relationships has no storage property',
        before: function(done) {
    Severity: Major
    Found in tests/controllers/item/persistItemDataObject.js and 4 other locations - About 2 hrs to fix
    tests/controllers/item/persistItemDataObject.js on lines 22..33
    tests/controllers/item/persistItemDataObject.js on lines 33..44
    tests/controllers/item/persistItemDataObject.js on lines 55..66
    tests/controllers/item/persistItemDataObject.js on lines 66..77

    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 77.

    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 5 locations. Consider refactoring.
    Open

      }, {
        when: 'relationships parameter has no source property',
        params: [wh.itemDataObject(), wh.itemRelationships()],
        error: 'Parameter relationships has no source property',
        before: function(done) {
    Severity: Major
    Found in tests/controllers/item/persistItemDataObject.js and 4 other locations - About 2 hrs to fix
    tests/controllers/item/persistItemDataObject.js on lines 22..33
    tests/controllers/item/persistItemDataObject.js on lines 33..44
    tests/controllers/item/persistItemDataObject.js on lines 44..55
    tests/controllers/item/persistItemDataObject.js on lines 66..77

    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 77.

    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

    Function exports has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    module.exports = function(user, source, storage, contentType, pagination, job, done) {
      var ids, page, userSourceAuth, log = logger.scopedLog();
    
      var validate = (done) => {
        validateParams([{
    Severity: Minor
    Found in app/controllers/item/storeItemsPage.js - About 2 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

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

      }, {
        when: 'provided page with meta and code below 400',
        params: [wh.itemPage(wh.one('source'), wh.one('contentType'), wh.one('userSourceAuth'), {
          meta: {
            code: 399
    Severity: Major
    Found in tests/controllers/item/itemsPageError.js and 1 other location - About 2 hrs to fix
    tests/controllers/item/itemsPageError.js on lines 28..36

    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 75.

    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

      }, {
        when: 'provided page with meta and code below 300',
        params: [wh.itemPage(wh.one('source'), wh.one('contentType'), wh.one('userSourceAuth'), {
          meta: {
            code: 299
    Severity: Major
    Found in tests/controllers/item/itemsPageError.js and 1 other location - About 2 hrs to fix
    tests/controllers/item/itemsPageError.js on lines 20..28

    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 75.

    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

    Function exports has 50 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    module.exports = function(app) {
      debug('start routeModelResources');
    
      /**
       * Negotiate the Content-Type and Accept request headers
    Severity: Minor
    Found in app/lib/jsonapi/routeModelResources.js - About 2 hrs to fix

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

      module.exports = function(modelId) {
        var fixture = modelFixtures[modelId];
      
        if (!fixture) {
          throw new Error(`Unable to load fixture for ${modelId}`);
      Severity: Minor
      Found in app/lib/factory.js - About 1 hr to fix

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

        module.exports = function(description, assertion) {
          /**
           * Return description compiled with test data
           * @param {string} description - Base description
           * @param {test} test
        Severity: Minor
        Found in app/lib/assertions/it.js - About 1 hr to fix

          Function exports has 48 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          module.exports = function(user, source, storage, contentType, job, done) {
            var log = logger.scopedLog();
          
            var validate = (done) => {
              validateParams([{
          Severity: Minor
          Found in app/controllers/item/storeAllForUserStorageSourceContentType.js - About 1 hr to fix

            Function exports has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

            module.exports = function(item, data, job, done) {
              // eslint-disable-next-line global-require
              var app = require('app'),
                log = logger.scopedLog();
            
            
            Severity: Minor
            Found in app/controllers/item/storeItemData.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 exports has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

            module.exports = function(req, model, method, done) {
              validateParams([{
                name: 'req', variable: req, required: true
              }, {
                name: 'model', variable: model, required: true, requiredProperties: ['jsonapi']
            Severity: Minor
            Found in app/lib/jsonapi/modelQueryConditions.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 exports has 47 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            module.exports = function(app, Model) {
              routeModelResource(app, Model, 'get', '/' + _.kebabCase(Model.modelType()), (req, res) => {
                var compileConditions = (done) => {
                  var conditions = {};
                  var filter = req.query.filter ? req.query.filter : {};
            Severity: Minor
            Found in app/lib/jsonapi/routeModelGetObjectsResource.js - About 1 hr to fix

              Function formatData has 46 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                var formatData = (id, done) => {
                  var formattedData = {
                    'id': id,
                    'type': item.contentType.pluralLowercaseName(),
                    'attributes': {}
              Severity: Minor
              Found in app/controllers/item/storeItemData.js - About 1 hr to fix

                Function exports has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                module.exports = function(tests, done) {
                  var runTest = function(test, done) {
                    try {
                      if (test.required && !test.variable) {
                        throw new Error('Parameter ' + test.name + ' undefined or null');
                Severity: Minor
                Found in app/lib/validateParams.js - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language