neotoma/sync-server

View on GitHub

Showing 278 of 278 total issues

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

  assertFunctionReturnsResult('controller itemDataObjectsFromPage', itemDataObjectsFromPage, [{
    when: 'provided source with itemDataObjectsFromPagePathTemplate property as parameter',
    params: [undefined, wh.one('source'), wh.one('contentType')],
    before: function(done) {
      this.params[0] = wh.itemPage(this.params[1], this.params[2]);
Severity: Major
Found in tests/controllers/item/itemDataObjectsFromPage.js and 1 other location - About 1 day to fix
tests/controllers/item/totalItemsAvailableFromPage.js on lines 10..30

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

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

  assertFunctionReturnsResult(totalItemsAvailableFromPage, [{
    when: 'provided source with totalItemsAvailableFromPagePathTemplate property as parameter',
    params: [undefined, wh.one('source'), wh.one('contentType')],
    before: function(done) {
      this.params[0] = wh.itemPage(this.params[1], this.params[2]);
Severity: Major
Found in tests/controllers/item/totalItemsAvailableFromPage.js and 1 other location - About 1 day to fix
tests/controllers/item/itemDataObjectsFromPage.js on lines 10..30

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

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 registerTask has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
Open

var registerTask = function(grunt) {
  /**
   * Remove database collections and seed them with resourceObjects stored in files
   * @param {string} [args] – rsync arguments
   */
Severity: Minor
Found in app/lib/tasks/grunt-data-seed.js - About 6 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 exports has a Cognitive Complexity of 43 (exceeds 5 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 6 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

File models.js has 421 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * Models expected by app and their testable properties
 */

var ObjectId = require('mongoose').Types.ObjectId;
Severity: Minor
Found in fixtures/models.js - About 6 hrs to fix

    Function exports has 141 lines of code (exceeds 25 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: Major
    Found in app/controllers/item/storeItemData.js - About 5 hrs to fix

      Function exports has a Cognitive Complexity of 32 (exceeds 5 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 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 exports has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
      Open

      module.exports = function(itemDataObject, relationships, done) {
        var conditions;
        var log = logger.scopedLog();
      
        var validate = (done) => {
      Severity: Minor
      Found in app/controllers/item/persistItemDataObject.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 exports has 114 lines of code (exceeds 25 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: Major
      Found in app/controllers/item/storeItemsPage.js - About 4 hrs to fix

        Function reqPassportDocument has 104 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        var reqPassportDocument = function(req, res, next) {
          if (!req.params.type || !req.params.id) {
            return next();
          }
        
        
        Severity: Major
        Found in app/routers/auths.js - About 4 hrs to fix

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

          module.exports = modelFactory.new('UserStorageAuth', {
            storage: { ref: 'Storage', required: true },
            storageToken: String,
            storageUser: String,
            user: { ref: 'User' }
          Severity: Major
          Found in app/models/userStorageAuth.js and 1 other location - About 4 hrs to fix
          app/models/userSourceAuth.js on lines 17..34

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

          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

          module.exports = modelFactory.new('UserSourceAuth', {
            source: { ref: 'Source', required: true },
            sourceToken: String,
            sourceUser: String,
            user: { ref: 'User' }
          Severity: Major
          Found in app/models/userSourceAuth.js and 1 other location - About 4 hrs to fix
          app/models/userStorageAuth.js on lines 17..34

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

          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 98 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          module.exports = function(itemDataObject, relationships, done) {
            var conditions;
            var log = logger.scopedLog();
          
            var validate = (done) => {
          Severity: Major
          Found in app/controllers/item/persistItemDataObject.js - About 3 hrs to fix

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

                result: function(itemDataObjects, done) {
                  assert.equal(itemDataObjects.length, 234);
                  assert(itemDataObjects[0].id);
                  assert(itemDataObjects[0].type);
                  assert(itemDataObjects[0].foo1);
            Severity: Major
            Found in tests/lib/warehouse.js and 1 other location - About 3 hrs to fix
            tests/lib/warehouse.js on lines 45..53

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

            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(itemDataObjects, done) {
                  assert.equal(itemDataObjects.length, 2);
                  assert(itemDataObjects[1].id);
                  assert(itemDataObjects[1].type);
                  assert(itemDataObjects[1].foo1);
            Severity: Major
            Found in tests/lib/warehouse.js and 1 other location - About 3 hrs to fix
            tests/lib/warehouse.js on lines 32..40

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

            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 containing code and errorDetail',
                params: [wh.itemPage(wh.one('source'), wh.one('contentType'), wh.one('userSourceAuth'), {
                  meta: {
                    code: 599,
            Severity: Major
            Found in tests/controllers/item/itemsPageError.js and 1 other location - About 3 hrs to fix
            tests/controllers/item/itemsPageError.js on lines 81..93

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

            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 containing code and errorType',
                params: [wh.itemPage(wh.one('source'), wh.one('contentType'), wh.one('userSourceAuth'), {
                  meta: {
                    code: 499,
            Severity: Major
            Found in tests/controllers/item/itemsPageError.js and 1 other location - About 3 hrs to fix
            tests/controllers/item/itemsPageError.js on lines 69..81

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

            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 87 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            module.exports = function(document, relationships, done) {
              var validate = function(done) {
                validateParams([{
                  name: 'document', variable: document, required: true, requiredType: ['object', 'constructor']
                }, {
            Severity: Major
            Found in app/lib/jsonapi/saveRelationshipsToDocument.js - About 3 hrs to fix

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

                }, {
                  when: 'provided page with meta containing server error code',
                  params: [wh.itemPage(wh.one('source'), wh.one('contentType'), wh.one('userSourceAuth'), {
                    meta: {
                      code: 550
              Severity: Major
              Found in tests/controllers/item/itemsPageError.js and 2 other locations - About 3 hrs to fix
              tests/controllers/item/itemsPageError.js on lines 36..47
              tests/controllers/item/itemsPageError.js on lines 47..58

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

              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

                }, {
                  when: 'provided page with meta and code above 1000',
                  params: [wh.itemPage(wh.one('source'), wh.one('contentType'), wh.one('userSourceAuth'), {
                    meta: {
                      code: 1001
              Severity: Major
              Found in tests/controllers/item/itemsPageError.js and 2 other locations - About 3 hrs to fix
              tests/controllers/item/itemsPageError.js on lines 47..58
              tests/controllers/item/itemsPageError.js on lines 58..69

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

              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

              Severity
              Category
              Status
              Source
              Language