alekzonder/maf

View on GitHub

Showing 90 of 90 total issues

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

                if (methodData.schema.query) {
                    routeArgs.push((req, res, next) => {

                        var joiOptions = {
                            convert: true,
Severity: Major
Found in src/Rest/index.js and 1 other location - About 1 day to fix
src/Rest/index.js on lines 247..294

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

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

                if (methodData.schema && methodData.schema.body) {
                    routeArgs.push((req, res, next) => {

                        var joiOptions = {
                            convert: true,
Severity: Major
Found in src/Rest/index.js and 1 other location - About 1 day to fix
src/Rest/index.js on lines 196..245

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

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

    add (resource, di) {

        return new Promise((resolve, reject) => {

            if (!resource.resource) {
Severity: Major
Found in src/Rest/index.js - About 1 day to fix

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

    module.exports = function (options) {
    
        var continueRequestProcessing = false;
    
        if (options && options.continue) {
    Severity: Major
    Found in src/express/response/helpers/index.js - About 6 hrs to fix

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

          getByName (name, fields) {
      
              return new Promise((resolve, reject) => {
      
                  var timer = this._createTimer(this.entity + ':getByName');
      Severity: Major
      Found in src/Api/Abstract.js and 1 other location - About 6 hrs to fix
      src/Api/Abstract.js on lines 230..253

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

      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

          getById (id, fields) {
      
              return new Promise((resolve, reject) => {
      
                  var timer = this._createTimer(this.entity + ':getById');
      Severity: Major
      Found in src/Api/Abstract.js and 1 other location - About 6 hrs to fix
      src/Api/Abstract.js on lines 199..221

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

      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

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

          mapToChain (data) {
      
              for (var name in data) {
                  if (!this[name]) {
                      var error = new ModelError(ModelError.CODES.FIND_CURSOR_CHAIN_NO_METHOD);
      Severity: Major
      Found in src/Model/Tingodb/FindCursorChain.js and 1 other location - About 4 hrs to fix
      src/Model/Mongodb/FindCursorChain.js on lines 118..135

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

      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

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

          mapToChain (data) {
      
              for (var name in data) {
                  if (!this[name]) {
                      var error = new ModelError(ModelError.CODES.FIND_CURSOR_CHAIN_NO_METHOD);
      Severity: Major
      Found in src/Model/Mongodb/FindCursorChain.js and 1 other location - About 4 hrs to fix
      src/Model/Tingodb/FindCursorChain.js on lines 106..123

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

      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 31 (exceeds 5 allowed). Consider refactoring.
      Open

      module.exports = (logger, di) => {
      
          var checkToken = true;
      
          if (di.config.private) {
      Severity: Minor
      Found in src/Rest/Middleware/AuthToken.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

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

          _prepareFields (fields) {
              var result = {};
      
              if (!fields) {
                  return null;
      Severity: Major
      Found in src/Model/Tingodb/index.js and 1 other location - About 4 hrs to fix
      src/Model/Mongodb/index.js on lines 575..593

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

      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

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

          _prepareFields (fields) {
              var result = {};
      
              if (!fields) {
                  return null;
      Severity: Major
      Found in src/Model/Mongodb/index.js and 1 other location - About 4 hrs to fix
      src/Model/Tingodb/index.js on lines 532..550

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

      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

      File index.js has 342 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      'use strict';
      
      var path = require('path');
      
      var ModelError = require(path.join(__dirname, '..', 'Error'));
      Severity: Minor
      Found in src/Model/Mongodb/index.js - About 4 hrs to fix

        File index.js has 318 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        'use strict';
        
        var path = require('path');
        
        var _ = require('lodash');
        Severity: Minor
        Found in src/Model/Tingodb/index.js - About 3 hrs to fix

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

                      this._validate(data, this._modificationSchema)
                      .then((data) => {
          
                          if (this._isEmptyData(data)) {
                              return reject(new this.Error(this.Error.CODES.INVALID_DATA, 'empty data'));
          Severity: Major
          Found in src/Api/Abstract.js and 1 other location - About 3 hrs to fix
          src/Api/Abstract.js on lines 275..309

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

          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

                      this._validate(data, this._modificationSchema)
                      .then((data) => {
          
                          if (this._isEmptyData(data)) {
                              return reject(new this.Error(this.Error.CODES.INVALID_DATA));
          Severity: Major
          Found in src/Api/Abstract.js and 1 other location - About 3 hrs to fix
          src/Api/Abstract.js on lines 344..378

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

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

          module.exports = (logger, di) => {
          
              var checkToken = true;
          
              if (di.config.private) {
          Severity: Major
          Found in src/Rest/Middleware/AuthToken.js - About 2 hrs to fix

            File index.js has 267 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            'use strict';
            
            var _ = require('lodash');
            var joi = require('joi');
            var joiToJsonSchema = require('joi-to-json-schema');
            Severity: Minor
            Found in src/Rest/index.js - About 2 hrs to fix

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

                          this._collection.remove(filter, options, (error, result) => {
                              if (error) {
                                  timer.error(error.message);
                                  return reject(this.Error.ensureError(error));
                              }
              Severity: Major
              Found in src/Model/Tingodb/index.js and 1 other location - About 2 hrs to fix
              src/Model/Tingodb/index.js on lines 466..475

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

              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

                          this._collection.count(filter, options, (error, result) => {
                              if (error) {
                                  timer.error(error.message);
                                  return reject(this.Error.ensureError(error));
                              }
              Severity: Major
              Found in src/Model/Tingodb/index.js and 1 other location - About 2 hrs to fix
              src/Model/Tingodb/index.js on lines 415..424

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

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

                  ensureIndexes (/* options */) {
              
                      return new Promise((resolve, reject) => {
              
                          if (!this._indexes) {
              Severity: Major
              Found in src/Model/Mongodb/index.js - About 2 hrs to fix
                Severity
                Category
                Status
                Source
                Language