nooline/nooline

View on GitHub

Showing 24 issues of 48 total

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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      this.$cancelVerifyButton = $(buttonTag)
      .appendTo(this.$verifyPanel)
      .attr({
        class: cancelVerifyClassNames,
        title: cancelVerifyButtonText
Severity: Minor
Found in common/js/nooline/views/content-snippet-view/enable-editing.js and 1 other location - About 55 mins to fix
common/js/nooline/views/content-snippet-view/enable-editing.js on lines 90..96

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 54.

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

Further Reading

Severity
Category
Status