node-modli/modli-dynamodb

View on GitHub
src/index.js

Summary

Maintainability
D
2 days
Test Coverage

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

const Promise = require('bluebird');
const _ = require('lodash');
import { tables } from './dynamo-data';
import { helpers } from './helpers';
let AWS = require('aws-sdk');
Severity: Minor
Found in src/index.js - About 5 hrs to fix

    `` has 22 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export default class {
      constructor(config) {
        this.schemas = {};
        const dynDb = new AWS.DynamoDB(config);
        this.ddb = new DOC.DynamoDB(dynDb);
    Severity: Minor
    Found in src/index.js - About 2 hrs to fix

      Function readPaginate has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        readPaginate(obj, options = {}) {
          return new Promise((resolve, reject) => {
            let opts = {};
            opts.version = options.version || false;
            opts.limit = options.limit || 1000;
      Severity: Minor
      Found in src/index.js - About 1 hr to fix

        Function update has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          update(hashObject, updatedValuesArray, paramVersion = false, partial = false) {
            const version = (paramVersion === false) ? this.defaultVersion : paramVersion;
        
            return this.validate(updatedValuesArray, version, partial)
              .then(data => {
        Severity: Minor
        Found in src/index.js - About 1 hr to fix

          Function getItemsInArray has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            getItemsInArray(hash, array, paramVersion = false) {
              return new Promise((resolve, reject) => {
                const version = (paramVersion === false) ? this.defaultVersion : paramVersion;
                if (!array) {
                  reject(new Error('Array empty'));
          Severity: Minor
          Found in src/index.js - About 1 hr to fix

            Function scan has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              scan(filterObject, options = {}) {
                return new Promise((resolve, reject) => {
                  let opts = {};
                  opts.version = options.version || false;
                  opts.limit = options.limit || 1000;
            Severity: Minor
            Found in src/index.js - About 1 hr to fix

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

                generateSecondaryIndex(params) {
                  let newIndex = _.clone(tables.secondaryIndex, true);
                  if (params.projectionType) {
                    newIndex.Projection.ProjectionType = params.projectionType;
                    if (params.nonKeyAttributes) {
              Severity: Minor
              Found in src/index.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

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

                    if (opts.lastKey) {
                      try {
                        params.ExclusiveStartKey = JSON.parse(opts.lastKey);
                      } catch (err) {
                        reject(err);
              Severity: Major
              Found in src/index.js and 1 other location - About 1 hr to fix
              src/index.js on lines 231..237

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

              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 (opts.lastKey) {
                      try {
                        scanObject.ExclusiveStartKey = JSON.parse(opts.lastKey);
                      } catch (err) {
                        reject(err);
              Severity: Major
              Found in src/index.js and 1 other location - About 1 hr to fix
              src/index.js on lines 326..332

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

              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 {
                        this.ddb.createTable(params, (createErr, res) => {
                          if (createErr) {
                            reject(createErr);
                          } else {
              Severity: Minor
              Found in src/index.js and 1 other location - About 50 mins to fix
              src/index.js on lines 188..196

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

              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

                  return new Promise((resolve, reject) => {
                    this.ddb.deleteTable(params, (err, res) => {
                      if (err) {
                        reject(err);
                      } else {
              Severity: Minor
              Found in src/index.js and 1 other location - About 50 mins to fix
              src/index.js on lines 133..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 51.

              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 {
                    newIndex.IndexName = params.value + '-index';
                    newIndex.KeySchema.push(this.generateKey(params));
                  }
              Severity: Minor
              Found in src/index.js and 1 other location - About 30 mins to fix
              src/index.js on lines 62..65

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

              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

                    params.values.forEach(obj => {
                      newIndex.IndexName += obj.value + '-';
                      newIndex.KeySchema.push(this.generateKey(obj));
                    });
              Severity: Minor
              Found in src/index.js and 1 other location - About 30 mins to fix
              src/index.js on lines 67..70

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

              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