checnev/sequelize-nested-sets

View on GitHub

Showing 5 of 20 total issues

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

module.exports = (sequelize, modelName, attributes, options = {}, Model = null) => {
  /* eslint-disable no-param-reassign */
  options = prepareOptions(options);
  attributes = prepareAttributes(attributes, options);
  Model = initModel(sequelize, modelName, attributes);
Severity: Major
Found in index.js - About 1 day to fix

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

    module.exports = (sequelize, modelName, attributes, options = {}, Model = null) => {
      /* eslint-disable no-param-reassign */
      options = prepareOptions(options);
      attributes = prepareAttributes(attributes, options);
      Model = initModel(sequelize, modelName, attributes);
    Severity: Minor
    Found in index.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 index.js has 252 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    const cloneDeep = require('clone-deep');
    const { Op } = require('sequelize');
    const {
      prepareOptions,
      prepareAttributes,
    Severity: Minor
    Found in index.js - About 2 hrs to fix

      Function moveNode has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        Model.prototype.moveNode = async function moveNode(node, start, depth) {
          if (node.isChildOf(this)) {
            throw new Error('Can not move a node when the target node is child.');
          }
      
      
      Severity: Minor
      Found in index.js - About 1 hr to fix

        Function prepareAttributes has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        exports.prepareAttributes = (attributes, options = {}) => {
          const baseAttributes = {
            lft: {
              type: DataTypes.INTEGER,
              field: options.leftAttribute,
        Severity: Minor
        Found in utils.js - About 1 hr to fix
          Severity
          Category
          Status
          Source
          Language