Showing 97 of 97 total issues
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;
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (err) {
tidyUpInlineMembershipError(req, null, req.created_memberships, req.updated_memberships, function(innerErr) {
if ( innerErr ) {
return res.send(400, {errors: [innerErr]});
}
- Read upRead up
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 80.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (err) {
tidyUpInlineMembershipError(req, null, req.created_memberships, req.updated_memberships, function(innerErr) {
if ( innerErr ) {
return res.send(400, {errors: [innerErr]});
}
- Read upRead up
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 80.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
var mySocietySchemas = {
"organization": require('./popolo+mysociety/organization.json'),
"person": require('./popolo+mysociety/person.json'),
"membership": require('./popolo+mysociety/membership.json'),
"post": require('./popolo+mysociety/post.json'),
- Read upRead up
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 79.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
var popoloSchemas = {
"contact_detail": require('./popolo/contact_detail.json'),
"identifier": require('./popolo/identifier.json'),
"link": require('./popolo/link.json'),
"membership": require('./popolo/membership.json'),
- Read upRead up
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 79.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
doc.embedDocuments(req, true, function(err) {
if (err instanceof InvalidEmbedError) {
// Send a 400 error to indicate the client needs to alter their request
return res.send(400, {errors: [err.message, err.explaination]});
}
- Read upRead up
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 79.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
doc.embedDocuments(req, function(err) {
if (err instanceof InvalidEmbedError) {
// Send a 400 error to indicate the client needs to alter their request
return res.send(400, {errors: [err.message, err.explaination]});
}
- Read upRead up
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 79.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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;
Function exports
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function(app) {
app.post('/:collection', validateBody, function (req, res, next) {
var body = req.body;
// if there's an image and no body.images then add one as the popit front end uses