Showing 143 of 143 total issues
File document.js
has 951 lines of code (exceeds 250 allowed). Consider refactoring. Open
'use strict';
const Promise = require('bluebird'),
Errors = require('./errors'),
util = require('./util');
Identical blocks of code found in 2 locations. Consider refactoring. Open
&& (joins[field].leftKey === joins[field].rightKey)) {
query = this._query(joins[field].leftKey).do(leftKey => {
return joinedModel.get(joinedDocument[joinedModel._pk]).bracket(joins[field].rightKey).do(rightKey => {
if (model.getTableName() < joinedModel.getTableName()) {
return linkModel.getAll(leftKey.add('_').add(rightKey)).delete()._query;
- 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 307.
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
} else {
query = this._query(joins[field].leftKey).do(leftKey => {
return joinedModel.get(joinedDocument[joinedModel._pk]).bracket(joins[field].rightKey).do(rightKey => {
if (model.getTableName() < joinedModel.getTableName()) {
return linkModel.getAll(leftKey.add('_').add(rightKey)).delete()._query;
- 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 307.
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
File model.js
has 724 lines of code (exceeds 250 allowed). Consider refactoring. Open
'use strict';
const Promise = require('bluebird'),
EventEmitter = require('events'),
Document = require('./document'),
Errors = require('./errors'),
File query.js
has 597 lines of code (exceeds 250 allowed). Consider refactoring. Open
'use strict';
const Promise = require('bluebird'),
Errors = require('./errors'),
Feed = require('./feed'),
util = require('./util');
Similar blocks of code found in 2 locations. Consider refactoring. Open
util.loopKeys(this.__proto__._parents._belongsLinks, (belongsLinks, key) => { // eslint-disable-line
for (let i = 0, ii = belongsLinks[key].length; i < ii; ++i) {
let parentDoc = belongsLinks[key][i].doc;
let field = belongsLinks[key][i].key;
for (let j = 0, jj = parentDoc[field].length; j < jj; ++j) {
- 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 183.
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
util.loopKeys(this.__proto__._parents._hasMany, (hasMany, key) => { // eslint-disable-line
for (let i = 0, ii = hasMany[key].length; i < ii; ++i) {
let parentDoc = hasMany[key][i].doc;
let field = hasMany[key][i].key;
for (let j = 0, jj = parentDoc[field].length; j < jj; ++j) {
- 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 183.
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
post(ev, fn) {
if (typeof fn !== 'function') {
throw new Errors.ThinkAgainError('Second argument to `pre` must be a function');
}
if (fn.length > 1) {
- 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 181.
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
pre(ev, fn) {
if (typeof fn !== 'function') {
throw new Errors.ThinkAgainError('Second argument to `pre` must be a function');
}
if (fn.length > 1) {
- 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 181.
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 _deleteHook
has 145 lines of code (exceeds 25 allowed). Consider refactoring. Open
_deleteHook(docToDelete, deleteAll, deletedDocs, deleteSelf, updateParents, callback) {
let model = this._getModel(); // instance of Model
let r = model._thinkagain.r;
let promises = [];
Document
has 42 functions (exceeds 20 allowed). Consider refactoring. Open
class Document {
/**
* Create a document of a model (returned by `thinkagain.createModel`).
* @param {function} model The model of this document
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (this._getModel()._name < joins[key].model._getModel()._name) {
linksPks.push(this[joins[key].leftKey] + '_' + this[key][i][joins[key].rightKey]);
} else {
linksPks.push(this[key][i][joins[key].rightKey] + '_' + this[joins[key].leftKey]);
}
- 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 147.
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
} else if (this._getModel()._name < joins[key].model._getModel()._name) {
linksPks.push(this[joins[key].leftKey] + '_' + this[key][i][joins[key].rightKey]);
} else {
linksPks.push(this[key][i][joins[key].rightKey] + '_' + this[joins[key].leftKey]);
}
- 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 147.
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
Model
has 36 functions (exceeds 20 allowed). Consider refactoring. Open
class Model extends EventEmitter {
/*
* Constructor for a Model. Note that this is not what `thinkagain.createModel`
* returns. It is the prototype of what `thinkagain.createModel` returns.
Function getJoin
has 109 lines of code (exceeds 25 allowed). Consider refactoring. Open
getJoin(modelToGet, _getAll, gotModel) {
let r = this._model._getModel()._thinkagain.r;
let model = this._model;
let joins = this._model._getModel()._joins;
Function removeRelation
has 105 lines of code (exceeds 25 allowed). Consider refactoring. Open
removeRelation(field, joinedDocument) {
let model = this._model;
let joins = this._model._getModel()._joins;
let joinedModel = joins[field].model;
let r = this._model._thinkagain.r;
Function setSaved
has 100 lines of code (exceeds 25 allowed). Consider refactoring. Open
setSaved(all) {
this.__proto__._saved = true; // eslint-disable-line
if (all !== true) return;
util.loopKeys(this._getModel()._joins, (joins, key) => {
switch (joins[key].type) { // eslint-disable-line
Function hasAndBelongsToMany
has 100 lines of code (exceeds 25 allowed). Consider refactoring. Open
hasAndBelongsToMany(joinedModel, fieldDoc, leftKey, rightKey, options) {
let link;
let thinkagain = this._getModel()._thinkagain;
options = options || {};
Function addRelation
has 99 lines of code (exceeds 25 allowed). Consider refactoring. Open
addRelation(field, joinedDocument) {
let model = this._model;
let joins = this._model._getModel()._joins;
let joinedModel = joins[field].model;
let r = this._model._thinkagain.r;
Function _saveLinks
has 85 lines of code (exceeds 25 allowed). Consider refactoring. Open
_saveLinks(docToSave, saveAll) {
let model = this._getModel();
let constructor = this.getModel();
let r = model._thinkagain.r;