Showing 24 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
- Create a ticketCreate a ticket
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;
- Create a ticketCreate a ticket
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);
- Create a ticketCreate a ticket
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 = {};
- Create a ticketCreate a ticket
Function Nooline
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
function Nooline () {
requirejs.config({
baseUrl: '/',
shim: {
'node_modules/backbone/backbone': {
- Create a ticketCreate a ticket
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;
- Create a ticketCreate a ticket
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;
- Create a ticketCreate a ticket
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'
);
- Create a ticketCreate a ticket
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.
- Create a ticketCreate a ticket
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.
- Read upRead up
- Create a ticketCreate a ticket
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'],
- Create a ticketCreate a ticket
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');
- Create a ticketCreate a ticket
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;
- Create a ticketCreate a ticket
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,
- Create a ticketCreate a ticket
Function addControl
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function addControl (types, spot) {
var $button;
var $container;
- Create a ticketCreate a ticket
Function globalEvents
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function globalEvents () {
var N = this.Nooline;
// TODO: Refactor this.
- Create a ticketCreate a ticket
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;
- Create a ticketCreate a ticket
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;
- Create a ticketCreate a ticket
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;
- Create a ticketCreate a ticket
Similar blocks of code found in 2 locations. Consider refactoring. Open
this.$cancelVerifyButton = $(buttonTag)
.appendTo(this.$verifyPanel)
.attr({
class: cancelVerifyClassNames,
title: cancelVerifyButtonText
- Read upRead up
- Create a ticketCreate a ticket
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
- 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