Showing 414 of 414 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
function check(doc) {
var defer = Q.defer();
if (!doc) {
res.statusCode = statusCode.NOT_FOUND;
defer.reject('Document not found');
- 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
File file-injector.js
has 260 lines of code (exceeds 250 allowed). Consider refactoring. Open
var mkdirp = require('mkdirp');
var fs = require('fs');
var glob = require('glob');
var async = require('async');
var path = require('path');
Function bargraph
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports.bargraph = function (Model, bargraph) {
var groupBy = bargraph.groupBy || "";
var axis = bargraph.xAxisField;
var defaultQuery = bargraph.query || {};
Function fromDB
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
Model.injector()._references.fromDB = function (doc, cb) {
var defer = Q.defer();
var promises = [];
var doc2 = doc.toObject();
Function QueryUtils
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
var QueryUtils = /** @class */ (function () {
function QueryUtils() {
}
//TODO: Add population key if present
QueryUtils.findOne = function (operation, model, req, cb) {
Similar blocks of code found in 2 locations. Consider refactoring. Open
var Unauthorized = /** @class */ (function (_super) {
__extends(Unauthorized, _super);
function Unauthorized(msg) {
return _super.call(this, "Unauthorized", msg) || this;
}
- 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
app.post(injector.config.routes.prefix + '/' + baseConfig.plural + '/' + key + '/:' + refConfig.id,
baseConfig.search.middleware || [],
typeBased.indirectReferencePost(Model, refModel, key)
);
- 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
app.get(injector.config.routes.prefix + '/' + baseConfig.plural + '/' + key + '/:' + refConfig.id,
baseConfig.search.middleware || [],
typeBased.indirectReferenceGet(Model, refModel, key)
);
- 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 NotFound = /** @class */ (function (_super) {
__extends(NotFound, _super);
function NotFound(msg) {
return _super.call(this, "Not Found", msg) || this;
}
- 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
ExpressManager
has 21 functions (exceeds 20 allowed). Consider refactoring. Open
class ExpressManager {
static logger = Logger.getLogger();
public app = express();
private config;
private pluginRegistry: PluginRegistry;
Function RouteLoader
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
var RouteLoader = /** @class */ (function () {
function RouteLoader(config, pluginRegistry) {
RouteLoader.logger.trace("Creating RouteLoader instance");
this.config = config;
this.pluginRegistry = pluginRegistry;
Function validate
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports.validate = function (Model) {
var config = Model.injector();
var additionalId = (config.id != '_id') ? config.id : undefined;
var shardKey = (config.shard && config.shard.shardKey) ? config.shard.shardKey : undefined;
Function mainGetFn
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
function mainGetFn() {
var query = {};
for (var i in config.mongo.query) {
//COPY the object
query[i] = config.mongo.query[i];
Function injectImages
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.injectImages = function (_app, param) {
var imageConf = injector.config.env.images;
imagePath = imageConf.path;
cachePath = imageConf.cache;
Function injectImages
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.injectImages = function (_app, param) {
var imageConf = injector.config.env.images;
imagePath = imageConf.path;
cachePath = imageConf.cache;
Function iterate
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
function iterate(path, obj) {
if (matches = path.match(/([^.]+)\.(.*)/)) {
var key = matches[1];
if (!obj[key]) {
// Humanize object title
Function Configurations
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
var Configurations = /** @class */ (function () {
function Configurations() {
if (Configurations.configHolder) {
throw new Error("Don't instantiate directly a configuration");
}
Function configureForm
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
module.exports.configureForm = function (Model) {
var inj = Model.injector();
if (inj.form && inj.form.tabs) {
for (var t in inj.form.tabs) {
var tab = inj.form.tabs[t];
- 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 isRoleAcceptable
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
private isRoleAcceptable(role, user) {
var config = this.config;
var restrictions = this.config.env.restrictions;
if (config.permissions.adminRole && user.role == config.permissions.adminRole) {
return true;
- 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 iterateCursor
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
HooksUtils.iterateCursor = function (cursor, limit, func, ctx) { return __awaiter(_this, void 0, void 0, function () {
var partial, state, doc_1, next, _a, result, _b, err_1;
return __generator(this, function (_c) {
switch (_c.label) {
case 0: