jay-depot/turnpike

View on GitHub

Showing 36 of 58 total issues

Function turnpikeSession has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

SessionWrapper.turnpikeSession = function() {
  var settings = { secret: GlobalConfig.session_secret };
  var engine = function(req, res, next) {console.log('no session engine');next();};
  var session = require('express-session');
  var express_session;
Severity: Minor
Found in lib/server/middleware/SessionWrapper.js - About 1 hr to fix

Function ViewBuilder has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function ViewBuilder(files) {
  //list contents of path, and for each .jade file add an available mode.
  var modes = {};
  var i;

Severity: Minor
Found in lib/classes/base/view/ViewBuilder.js - About 1 hr to fix

Function do_project has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

TurnpikeCreate.prototype.do_project = function(subcmd, opts, name, cb) {
  var project = {};
  var pkg = {};
  var turnpike_pkg = fs.readJsonSync(path.join(moddir, 'package.json'));
  var config = {};
Severity: Minor
Found in bin/turnpike.js - About 1 hr to fix

Function legacy has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

router.legacy = function() {
  var action = require('./action');
  var fs = require('fs-extra');
  var name, path, route, routes, verb, expressVerb;

Severity: Minor
Found in lib/router.js - About 1 hr to fix

Function index has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

RestEndpointController.prototype.index = function(params, readyCallback) {
  if (this.model){
    var skip = this.connection.req.query.index || 0;
    var search = {};

Severity: Minor
Found in lib/classes/base/controller/RestEndpointController.js - About 1 hr to fix

Function domain_wrapper has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function domain_wrapper(server) {
  return function(req, res, next) {
    req.domain = domain.create();

    req.domain.on('error', function(er) {
Severity: Minor
Found in lib/server/middleware/domainWrapper.js - About 1 hr to fix

Function create_view has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

function create_view(options, skeletons) {
  var Model;
  var Controller;
  var current_dir = process.cwd();

Severity: Minor
Found in bin/support/create_view.js - About 1 hr to fix

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 create has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

RestEndpointController.prototype.create = function(params, readyCallback) {
  if (this.model) {
    async.waterfall([
      function(next) {
        this.model.create(next);
Severity: Minor
Found in lib/classes/base/controller/RestEndpointController.js - About 55 mins to fix

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 create has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

ResourceEndpointController.prototype.create = function(readyCallback) {
  if (this.model) {
    async.waterfall([
      function(next) {
        this.model.create(next);
Severity: Minor
Found in lib/classes/base/controller/ResourceEndpointController.js - About 55 mins to fix

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

Avoid deeply nested control flow statements.
Open

        for (verb in route) if (route.hasOwnProperty(verb)) {
          if (verb === 'DEL') expressVerb = 'delete';
          else expressVerb = verb.toLowerCase();

          path[expressVerb](action.accessChecked(route[verb]));
Severity: Major
Found in lib/router.js - About 45 mins to fix

Function index has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

ResourceEndpointController.prototype.index = function(readyCallback) {
  if (this.model){
    var skip = this.connection.req.query.index || 0;
    var params = {};

Severity: Minor
Found in lib/classes/base/controller/ResourceEndpointController.js - About 45 mins to fix

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 ViewBuilder has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

function ViewBuilder(files) {
  //list contents of path, and for each .jade file add an available mode.
  var modes = {};
  var i;

Severity: Minor
Found in lib/classes/base/view/ViewBuilder.js - About 45 mins to fix

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 index has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

RestEndpointController.prototype.index = function(params, readyCallback) {
  if (this.model){
    var skip = this.connection.req.query.index || 0;
    var search = {};

Severity: Minor
Found in lib/classes/base/controller/RestEndpointController.js - About 45 mins to fix

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 EndpointController has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function EndpointController(connection) {
  var application = require('./../../../index').application;

  this.connection = connection;
  this.view = this.name = this.constructor.name;
Severity: Minor
Found in lib/classes/base/controller/EndpointController.js - About 35 mins to fix

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 remove has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

ResourceEndpointController.prototype.remove = function(item, readyCallback) {
  if (this.model){
    this.model.remove(item, function(err, removed) {
      if (err) {
        this.connection.die(500);
Severity: Minor
Found in lib/classes/base/controller/ResourceEndpointController.js - About 35 mins to fix

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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

config.initialize = _.once(function() {
  var path        = require('path');
  var fs          = require('fs-extra');
  var moddir      = path.resolve(path.dirname(module.filename), '..');
  var cwd         = process.cwd();
Severity: Minor
Found in lib/config.js - About 25 mins to fix

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

Severity
Category
Status
Source
Language