Showing 59 of 59 total issues
Function compile
has 203 lines of code (exceeds 25 allowed). Consider refactoring. Open
function compile(modelDefinition) {
var ARTIFACT = pageService.ARTIFACT; // Easy alias
logger.info('Starting model compile', modelDefinition.name);
Function compile
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
function compile(modelDefinition) {
var ARTIFACT = pageService.ARTIFACT; // Easy alias
logger.info('Starting model compile', modelDefinition.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 desktop
has 80 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.desktop = function (req, res, appLocals) {
if (!req.user) {
res.redirect('/login');
return;
}
Function buildSteps
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
function buildSteps(modelDefinition, todo) {
if (_.isEmpty(modelDefinition.steps)) {
return;
}
Function start
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
var start = function () {
var app = express();
app.locals = _.extend(app.locals, config.locals || {});
Identical blocks of code found in 2 locations. Consider refactoring. Open
service.getDefinition(service.ARTIFACT.MODEL, page.model)
.then(function (model) {
attachModelToPage(page, model);
return renderDesktop(page, menu);
})
- 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 84.
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
service.getDefinition(service.ARTIFACT.PAGE, req.pageName)
.then(function (page) {
if (page.model) {
service.getDefinition(service.ARTIFACT.MODEL, page.model)
.then(function (model) {
- 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 84.
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 updateData
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
function updateData(modelDefinition, row) {
return new BluebirdPromise(function (resolve, reject) {
logger.debug('starting updateData() for ', modelDefinition.name);
checkConnection();
File modelSaver.js
has 259 lines of code (exceeds 250 allowed). Consider refactoring. Open
'use strict';
var _ = require('lodash'),
BluebirdPromise = require('bluebird'),
knex = require('knex').knex,
Identical blocks of code found in 2 locations. Consider refactoring. Open
function convertErrorToJson(err) {
if (typeof err === 'string') {
logger.warn('Try throwing an error instead for message: ' + err);
return {
code: 'Error',
- 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 77.
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
function convertErrorToJson(err) {
if (typeof err === 'string') {
logger.warn('Try throwing an error instead for message: ' + err);
return {
code: 'Error',
- 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 77.
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 mapFields
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
function mapFields(modelDefinition) {
if (!modelDefinition.fields) {
logger.warn('Model had no fields');
return;
}
Function getModelByName
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getModelByName(modelName) {
return new BluebirdPromise(function (resolveGetModelByName, rejectGetModelByName) {
logger.debug('starting modelService.getModelByName for ', modelName);
var names = toWhere(modelName);
Function compile
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
function compile(menuDefinition) {
logger.info('Starting compile', menuDefinition.name);
var pageNames = [];
Similar blocks of code found in 2 locations. Consider refactoring. Open
function addDataApi(app) {
var dataController = require('../controllers/dataController');
app.get('/data/:pageName', function (req, res) {
dataController.query(req, res);
- 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 73.
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
function addSourceEtl(app) {
var sourceEtlController = require('../controllers/sourceEtlController');
app.get('/exportAll', function (req, res) {
sourceEtlController.exportAll(req, res);
- 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 73.
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 apply
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
function apply(filterString, sql, fields) {
if (!filterString) {
return;
}
Function parseAndCompile
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
function parseAndCompile(modelDefinition) {
logger.info('Running parseAndCompile for ' + modelDefinition.name);
//logger.debug(modelDefinition);
var todo = [];
Function queryModelData
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
function queryModelData(model) {
return new BluebirdPromise(function (resolve, reject) {
logger.debug('starting queryModelData');
var sql = convertModelToKnexSql(model);
Function convertModelToKnexSql
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
function convertModelToKnexSql(model) {
logger.debug('starting convertModelToKnexSql for ' + model.name);
//logger.debug(JSON.stringify(model));
if (!knex) {