Showing 55 of 97 total issues
Function exports
has 233 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function(app) {
app.delete('/:collection/:id/image', function (req, res, next) {
var id = req.params.id;
Function elasticsearchPlugin
has 188 lines of code (exceeds 25 allowed). Consider refactoring. Open
function elasticsearchPlugin(schema) {
/**
* Convert the document into a format suitable for indexing in
* Elasticsearch. This uses the toJSON transform option to remove
Function esFilters
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open
module.exports = function esFilters() {
return {
esFilter: function esFilter(doc, ret, options) {
if (!doc) {
return;
- 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 embedPlugin
has 104 lines of code (exceeds 25 allowed). Consider refactoring. Open
function embedPlugin(schema) {
/**
* Taked the ?embed parameter and embeds any people, organizations or
* memberships that have been requested.
Function embedDocuments
has 102 lines of code (exceeds 25 allowed). Consider refactoring. Open
schema.methods.embedDocuments = function embedDocuments(req, newEmbedNames, callback) {
if (typeof newEmbedNames === 'function') {
callback = newEmbedNames;
newEmbedNames = false;
}
Function exports
has 87 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function(app) {
app.put('/:collection/:id(*)', validateBody, function (req, res, next) {
var id = req.params.id;
Function exports
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function(app) {
// Export all languages - can potentially produce invalid popolo
app.get('/export.json', function(req, res, next) {
exporter(req.db, req, function(err, exportObject) {
if (err) {
Function esFilters
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function esFilters() {
return {
esFilter: function esFilter(doc, ret, options) {
if (!doc) {
return;
Function membershipFinder
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
function membershipFinder(schema, options) {
schema.methods.findMemberships = function findMemberships(callback) {
var Membership = this.model('Membership');
var modelName = this.constructor.modelName;
Function setup
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
function setup(app, options) {
function importPopolo(req, res, next) {
var queue = kue.createQueue({
prefix: req.options.queuePrefix || 'popit-api-',
});
Function processMembership
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
function processMembership(membership, req, doc, done) {
var existing = false;
var Membership = req.db.model(models.memberships.modelName);
async.waterfall([
function callCheckMembership(cb) {
- 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 saveImagesMiddleware
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
function saveImagesMiddleware(req, res, next) {
function saveImages( doc, image, upload, dest_path, idx ) {
var options = {};
if ( typeof idx != 'undefined' ) {
options = { clobber: true };
Function saveImages
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
function saveImages( doc, image, upload, dest_path, idx ) {
var options = {};
if ( typeof idx != 'undefined' ) {
options = { clobber: true };
}
Function toElasticsearch
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
MembershipSchema.methods.toElasticsearch = function(callback) {
var Person = this.model('Person');
var Organization = this.model('Organization');
var Post = this.model('Post');
var self = this;
Function processMembership
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
function processMembership(membership, req, doc, done) {
var existing = false;
var Membership = req.db.model(models.memberships.modelName);
async.waterfall([
function callCheckMembership(cb) {
Function jsonSchemaFields
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
function jsonSchemaFields(jsonSchema) {
var fields = {};
for (var name in jsonSchema.properties) {
if (jsonSchema.properties.hasOwnProperty(name)) {
- 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 i18n
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
function i18n(objectWithLanguages, langs, defaultLang, includeTranslations) {
langs = langs || [];
includeTranslations = includeTranslations || false;
var obj = {};
// Detect keys that need translating
Function exports
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function(app) {
/**
* Merge two people together.
*
Function mergePlugin
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = exports = function mergePlugin(schema) {
schema.methods.merge = function merge(other, callback) {
var self = this;
var conflicts = [];
var pathsToMerge = Object.keys(other.toObject());
Function exports
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function(app) {
app.put('/:collection/:id(*)', validateBody, function (req, res, next) {
var id = req.params.id;