Showing 76 of 76 total issues
Function ClientDataInterface
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
var ClientDataInterface = function(model) {
var localStore = ClientStore(model.name);
var url = model.url();
var cache = {};
- 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
File parser.js
has 281 lines of code (exceeds 250 allowed). Consider refactoring. Open
var _ = require('./utils.js');
// Breadth-first walk the tree in reverse order
var inverseBreadth = function(node, cb) {
Function Publisher
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
var Publisher = function(express, db) {
var clients = [];
// Write data to all connected clients
var distribute = function(data) {
Function parseTemplate
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
parseTemplate: function(tmpl) {
var self = this;
var lines = tmpl.split('\n');
var lastIndent = 0;
var lineNum = 0;
Function ServerDataInterface
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
var ServerDataInterface = function(app, model) {
var name = model.name;
var remoteOnly = {_image: 0, _salt: 0, _hash: 0, _username: 0};
var init = function(data) {
File serverApplication.js
has 270 lines of code (exceeds 250 allowed). Consider refactoring. Open
require('http').globalAgent.maxSockets = Infinity;
var fs = require('fs');
var path = require('path');
var mongo = require('mongodb');
Function ServerApplication
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
var ServerApplication = function(options) {
// Create express app
var expressApp = express();
var environment = expressApp.get('env');
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
login: function(username, pw) {
return _.ajax({
verb: 'POST',
url: '/login',
data: {
- 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 REST
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
var REST = function(name, express, dataInterface) {
var baseUrl = '/api/' + name;
return {
serveResource: function() {
var self = this;
Similar blocks of code found in 2 locations. Consider refactoring. Open
signup: function(username, pw) {
return _.ajax({
verb: 'POST',
url: '/signup',
data: {
- 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 Model
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
var Model = function(dbCollection, reference, constructor) {
var ref = separateMethods(reference);
var model = {
klass: 'Model',
name: dbCollection,
Function parseTag
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
parseTag: function(line) {
var self = this;
var m = line.match(/(([\w-#\.]+\s*>\s*)*)([\w-]+)?(#([\w-]+))?((\.[\w-]+)*)(\((.*)\))?(\+)?( (.*))?/);
var multiTags = m[1];
var tag = m[3] || 'div';
Function UndoManager
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
var UndoManager = function(items) {
var milestones = [{}];
var reverseIndex = 0;
var dontRecord = false;
Function LocalStore
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
var LocalStore = function(modelName) {
// Iterate all items in local storage belonging to our model
var all = function(cb) {
for(var i = 0; i < localStorage.length; i++) {
var key = localStorage.key(i);
- 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 ViewModel
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
var ViewModel = function(name, reference, constructor) {
var model = Model('_view', reference);
return {
klass: 'ViewModel',
name: name,
Function evalExpr
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
var evalExpr = function(scope, expr, node) {
var m;
// Negation
var negate = (expr[0] == '!');
if(negate) expr = expr.slice(1);
Function serveResource
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
serveResource: function() {
var self = this;
console.log("Serving resource " + baseUrl);
// Get all items
Function Router
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
var Router = function() {
var listeners = {};
var suppressNextPopstate = false;
var scrollTo = function(id) {
Function evalCompoundExpr
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
var evalCompoundExpr = function(scope, expr, node) {
var booleans = ['||', '&&'];
var comparisons = ['==', '!=', '>', '<', '>=', '<='];
var allOps = _.union(booleans, comparisons);
// Separate expression into values and operators
Function save
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
save: function(values) {
var self = this;
return _.promise(function(ok, fail) {
// Detect event object to allow calling from actions
if(values && values.target) {