Showing 76 of 76 total issues
Function create
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
create: function(args, elem, cb) {
var inst = model.create();
// Remove persistance related methods
delete inst.save;
Function serialize
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
serialize: function() {
var html = '';
if(!this.topSerialized) {
// Begin tag
if(!this._fragment) {
Function execMicroStatements
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
execMicroStatements: function(statements, elem) {
_.each(statements, function(statement) {
// Register action handlers
if(statement.statement == 'on' && _.onClient()) {
var eName = statement.event;
Function parseStatement
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
parseStatement: function(line) {
var m;
var out;
// if
if(m = line.match(/{{if\s+(.+)}}/)) {
- 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 serve
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
serve: function(expressApp, db) {
expressApp.post('/login', function(req, res) {
var users = db.collection('users');
users.findOne({_username: req.body.username}, function(err, user) {
if(!user || user._hash != sha256(req.body.password)) {
Function Subscriber
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
var Subscriber = function() {
var subscribers = {};
// Listen for server-sent events
var evtSource = new EventSource('/events');
Function resolvePath
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
resolvePath: function(path, args) {
var self = this;
// Cut away the arguments part
// These are supplied by the evaluator already
path = path.split('(')[0];
Function cleanTree
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
var cleanTree = function(node) {
if(node.children) {
for(var i = node.children.length - 1; i >= 0; i--) {
var child = node.children[i];
if(child.type == 'Alternative') {
- 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 promises
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
var promises = _.compact(_.flatten(_.values(_.map(node.attributes, function(attr, key) {
// Dynamic attribute
if(attr.type == 'dynamic') {
var expr = attr.expression;
// Collect two way binding
Similar blocks of code found in 2 locations. Consider refactoring. Open
for(var key in ref.queries) {
var query = ref.queries[key].clone();
inst.data.remote[key] = 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 62.
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
for(var key in ref.collections) {
var collection = ref.collections[key].clone();
inst.data.remote[key] = collection;
}
- 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 62.
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 Collection
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
var Collection = function(array) {
if(array && array.klass == 'Collection') return array;
var col = {
klass: 'Collection',
items: [],
- 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 get
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
get: function(key) {
// Catch remaining arguments as parameters for computed properties
var args = Array.prototype.slice.call(arguments).splice(1);
// Determine value
var value = this.data.local[key];
Function prepareBundle
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
var prepareBundle = function(cb) {
if(bundle) return cb(bundle);
process.stdout.write("Preparing Bundle...");
// Use executed application as main script on the client as well
var appPath = process.argv[1];
Function openCursor
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
var openCursor = function(cb) {
var loadCollection = function(cbb) {
db.collection('pubsub', {strict: true}, function(err, pubsub) {
if(err) {
Function subscribe
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
var subscribe = function() {
if(modelOrCollection.klass == 'Model') {
if(_.onClient()) {
console.log("subscribe " + modelOrCollection.name);
modelOrCollection.app.pubSub.subscribe('create update delete', modelOrCollection.name, function(data) {
Function one
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
one: function(id, cb, raw) {
var ajax = function(cbb) {
_.ajax({url: url + '/' + id}).then(function(data) {
cbb(data);
}).catch(function() {
Avoid deeply nested control flow statements. Open
if(_.last(expr) == '!') {
expr = expr.slice(0, -1);
save = true;
}
Avoid deeply nested control flow statements. Open
if(!newItems) newItems = _.clone(items.items);
Avoid deeply nested control flow statements. Open
if(!attr.oneTimeOnly) {
attributePaths.push({
type: 'CSS',
klassName: klassName,
expr: expr,