nooline/nooline

View on GitHub

Showing 22 of 48 total issues

Function start has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

;(function start() {

  /**
   * @constructor Nooline
   * The base constructor which we decorate with various modules, governing
Severity: Minor
Found in common/js/nooline/start.js - About 1 hr to fix

Function loadSnippets has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  N.Models.Category.prototype.loadSnippets = function (error, data, index) {
    var error404;
    var ContentSnippet;
    var snippet;

Severity: Minor
Found in common/js/nooline/models/category/load-snippets.js - About 1 hr to fix

Function bindEvents has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  N.Views.ContentSnippetView.prototype.bindEvents = function (element) {

    var _this = this;

    _this.setElement(element);
Severity: Minor
Found in common/js/nooline/views/content-snippet-view/bind-events.js - About 1 hr to fix

Function Nooline has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function Nooline () {
    requirejs.config({
      baseUrl: '/',
      shim: {
        'node_modules/backbone/backbone': {
Severity: Minor
Found in common/js/nooline/start.js - About 1 hr to fix

Function buildControls has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  N.buildControls = function buildControls (data) {

    var allSnippets = N.contentCategories.findAllContent();
    var permissions = {};

Severity: Minor
Found in common/js/nooline/build-controls.js - About 1 hr to fix

Function loadIndex has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  N.Models.Category.prototype.loadIndex = function (error, data) {
    var fs;
    var info;
    var error404;
    var snippetList;
Severity: Minor
Found in common/js/nooline/models/category/load-index.js - About 1 hr to fix

Function render has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  N.Views.CategoryView.prototype.render = function () {
    var error404;
    var config;
    var content;
    var info;
Severity: Minor
Found in common/js/nooline/views/category-view/render.js - About 1 hr to fix

Function putSnippet has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function putSnippet (req, res) {

  var ContentSnippet = require(__root
    + '/common/js/nooline/models/content-snippet'
  );
Severity: Minor
Found in routes/put-snippet.js - About 1 hr to fix

Function bootstrap has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function bootstrap (req, res) {

  /**
   * Check to see if both settings files have finished loading.  If so, send
   * the settings back to the client.
Severity: Minor
Found in routes/bootstrap.js - About 1 hr to fix

Function bootstrap has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = function bootstrap (req, res) {

  /**
   * Check to see if both settings files have finished loading.  If so, send
   * the settings back to the client.
Severity: Minor
Found in routes/bootstrap.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 addPermission has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    _.each(data.permissions, function addPermission (permission) {

      permissions[permission] = true;

      _.each(N.controls['control-locations'],
Severity: Minor
Found in common/js/nooline/build-controls.js - About 1 hr to fix

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

Nooline.commitChanges = function (files, repo) {

  var process;
  var exec = require('child_process').exec;
  var config = require(__root + '/sites/' + repo + '/config/site.json');
Severity: Minor
Found in controllers/commit-changes.js - About 1 hr to fix

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

  N.Models.Category.prototype.createSnippet = function () {

    var snippets = this.get('snippets');
    var index = 1 + N.contentCategories.reduce(function (memo, category) {
      return memo + category.get('snippets').length;
Severity: Minor
Found in common/js/nooline/models/category/create-snippet.js - About 1 hr to fix

Function globalEvents has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function globalEvents () {

  var N = this.Nooline;

  // TODO: Refactor this.
Severity: Minor
Found in common/js/nooline/assign-listeners.js - About 1 hr to fix

Function error404 has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function error404 (error, info) {

  console.error(error);

  // TODO: These options, particularly the partials and startPath,
Severity: Minor
Found in routes/error-404.js - About 1 hr to fix

Function create has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  N.Views.ContentSnippetView.prototype.create = function () {

    var category = this.model.get('type');
    var $el;
    var $article;
Severity: Minor
Found in common/js/nooline/views/content-snippet-view/create.js - About 1 hr to fix

Function addControl has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        function addControl (types, spot) {

        var $button;
        var $container;

Severity: Minor
Found in common/js/nooline/build-controls.js - About 1 hr to fix

Function loadMeta has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  N.Models.Category.prototype.loadMeta = function (error, data) {
    var fs;
    var errorMessage;
    var error404;
      
Severity: Minor
Found in common/js/nooline/models/category/load-meta.js - About 1 hr to fix

Function saveContent has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function saveContent (category, info) {
  var snippets = category.get('snippets');
  var fs = require('fs');
  var path;

Severity: Minor
Found in controllers/save-content.js - About 1 hr to fix

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

module.exports = function matchLogin (data, info) {
  
  var errorLogin = require('./error-login');
  var crypto = require('crypto-js/core');
  var startSession = require('./start-session');
Severity: Minor
Found in controllers/match-login.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

Severity
Category
Status
Source