Function Fossil
has a Cognitive Complexity of 305 (exceeds 5 allowed). Consider refactoring. Open
var Fossil = (function () {
var deferred = function ($) {
return $.Deferred;
}(jquery);
var utils = function (_) {
- 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 Fossil
has 1140 lines of code (exceeds 25 allowed). Consider refactoring. Open
var Fossil = (function () {
var deferred = function ($) {
return $.Deferred;
}(jquery);
var utils = function (_) {
File fossil-core.js
has 1141 lines of code (exceeds 250 allowed). Consider refactoring. Open
var Fossil = (function () {
var deferred = function ($) {
return $.Deferred;
}(jquery);
var utils = function (_) {
Function mixins_deferrable
has 195 lines of code (exceeds 25 allowed). Consider refactoring. Open
var mixins_deferrable = function (_, Deferred) {
var messages = {
timeout: 'async process timed out',
rejected: 'some asynchronous process failed',
Function mixins_observable
has 128 lines of code (exceeds 25 allowed). Consider refactoring. Open
var mixins_observable = function (_, Backbone) {
var exposedPubsubProperties = [
'_listenerId',
'createPubSub'
Function services_routing
has 127 lines of code (exceeds 25 allowed). Consider refactoring. Open
var services_routing = function (_, Backbone, utils, Service) {
var Routing = Service.extend({
prefix: '',
router: null,
Function service
has 85 lines of code (exceeds 25 allowed). Consider refactoring. Open
var service = function (_, utils, Mixin, Observable) {
var Service = Mixin.extend({
expose: null,
link: null,
Function services_canvas
has 76 lines of code (exceeds 25 allowed). Consider refactoring. Open
var services_canvas = function ($, Service, utils, Region) {
var Canvas = Service.extend({
selector: 'body',
canvas: null,
useDeep: true,
Function mixin
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
var mixin = function (_, utils) {
var specials = ['initialize'];
function isSpecialFunction(name) {
return -1 !== specials.indexOf(name);
Function utils
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
var utils = function (_) {
var messages = { invalid_src: 'Invalid source object.' };
function scalarOrArray(method) {
return function () {
Function fossil
has 17 arguments (exceeds 4 allowed). Consider refactoring. Open
var fossil = function (deferred, utils, Mixin, Module, Service, ObservableBuffer, ViewStore, Observable, Startable, Deferrable, Session, Canvas, Routing, Events, Template, Underscore, Handlebars) {
Function viewStore
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
var viewStore = function (_, utils, Mixin) {
var ViewStore = Mixin.extend({
factories: null,
views: null,
constructor: function () {
Function observableBuffer
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
var observableBuffer = function (Mixin) {
var ObservableBuffer = Mixin.extend({
constructor: function () {
this.store = [];
Mixin.apply(this, arguments);
Function mixins_startable
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
var mixins_startable = function () {
var Startable = {
run: false,
start: function () {
Function services_template
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
var services_template = function (_, utils, Service) {
var Template = Service.extend({
engine: null,
useDeep: true,
constructor: function (options) {
Function engines_underscore
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
var engines_underscore = function (_, Backbone, Mixin, Observable, Deferrable, Startable) {
var ViewExtension = {
precompile: function (template) {
if (typeof template === 'string') {
return _.template(template);
Function engines_handlebars
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
var engines_handlebars = function (_, Backbone, Handlebars, Mixin, Observable, Deferrable, Startable) {
var ViewExtension = {
precompile: function (template) {
if (typeof template === 'string') {
return Handlebars.compile(template);
Function services_session
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
var services_session = function (_, Backbone, utils, Service) {
var expose = [
'get',
'set',
Function route
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
route: function (module, path, name, callback) {
var original;
path = url(module.url, path);
if (typeof name === 'function' || !callback) {
callback = name;
Function engines_handlebars
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
var engines_handlebars = function (_, Backbone, Handlebars, Mixin, Observable, Deferrable, Startable) {
Function engines_underscore
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
var engines_underscore = function (_, Backbone, Mixin, Observable, Deferrable, Startable) {
Identical blocks of code found in 2 locations. Consider refactoring. Open
var Fossil = (function () {
var deferred = function ($) {
return $.Deferred;
}(jquery);
var utils = function (_) {
- 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 10205.
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