Showing 10 of 15 total issues
Function lastModifiedPlugin
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
const plugin = function lastModifiedPlugin(schema, opts = {}) {
if (opts.uri) {
const mongoVersion = parseInt(mongoose.version);
if (mongoVersion < 5) {
mongoose.connect(opts.uri, { useMongoClient: true }).catch(e => {
File diffHistory.js
has 282 lines of code (exceeds 250 allowed). Consider refactoring. Open
const mongoose = require('mongoose');
const omit = require('omit-deep');
const pick = require('lodash.pick');
const empty = require('deep-empty-object');
Function getHistories
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
const getHistories = (modelName, id, expandableFields, cb) => {
expandableFields = expandableFields || [];
if (typeof expandableFields === 'function') {
cb = expandableFields;
expandableFields = [];
Function saveDiffHistory
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
const saveDiffHistory = (queryObject, currentObject, opts) => {
const queryUpdate = queryObject.getUpdate();
const schemaOptions = queryObject.model.schema.options || {};
let keysToBeModified = [];
Function saveDiffObject
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
function saveDiffObject(currentObject, original, updated, opts, queryObject) {
const { __user: user, __reason: reason, __session: session } =
(queryObject && queryObject.options) || currentObject;
let diff = diffPatcher.diff(
Function saveDiffHistory
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
const saveDiffHistory = (queryObject, currentObject, opts) => {
const queryUpdate = queryObject.getUpdate();
const schemaOptions = queryObject.model.schema.options || {};
let keysToBeModified = [];
- Read upRead up
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 getVersion
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
const getVersion = (model, id, version, queryOpts, cb) => {
if (typeof queryOpts === 'function') {
cb = queryOpts;
queryOpts = undefined;
}
Function lastModifiedPlugin
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
const plugin = function lastModifiedPlugin(schema, opts = {}) {
if (opts.uri) {
const mongoVersion = parseInt(mongoose.version);
if (mongoVersion < 5) {
mongoose.connect(opts.uri, { useMongoClient: true }).catch(e => {
- Read upRead up
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 saveDiffObject
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function saveDiffObject(currentObject, original, updated, opts, queryObject) {
Function checkRequired
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function checkRequired(opts, queryObject, updatedObject) {
if (queryObject && !queryObject.options && !updatedObject) {
return;
}
const { __user: user, __reason: reason } =
- Read upRead up
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"