Showing 26 of 40 total issues
File typeahead.js
has 1130 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
/*!
* typeahead.js 0.9.3
* https://github.com/twitter/typeahead
* Copyright 2013 Twitter, Inc. and other contributors; Licensed MIT
*/
File bootstrap-datepicker.js
has 878 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
/* =========================================================
* bootstrap-datepicker.js
* http://www.eyecon.ro/bootstrap-datepicker
* =========================================================
* Copyright 2012 Stefan Petre
Function TypeaheadView
has 215 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
var TypeaheadView = function() {
var html = {
wrapper: '<span class="twitter-typeahead"></span>',
hint: '<input class="tt-hint" type="text" autocomplete="off" spellcheck="off" disabled>',
dropdown: '<span class="tt-dropdown-menu"></span>'
Function Dataset
has 192 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
var Dataset = function() {
var keys = {
thumbprint: "thumbprint",
protocol: "protocol",
itemHash: "itemHash",
Function DropdownView
has 167 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
var DropdownView = function() {
var html = {
suggestionsList: '<span class="tt-suggestions"></span>'
}, css = {
suggestionsList: {
Function InputView
has 121 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
var InputView = function() {
function InputView(o) {
var that = this;
utils.bindAll(this);
this.specialKeyCodeMap = {
Function fill
has 92 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
fill: function() {
var d = new Date(this.viewDate),
year = d.getUTCFullYear(),
month = d.getUTCMonth(),
startYear = this.startDate !== -Infinity ? this.startDate.getUTCFullYear() : -Infinity,
Function Datepicker
has 92 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
var Datepicker = function(element, options) {
var that = this;
this.element = $(element);
this.language = options.language||this.element.data('date-language')||"en";
Function keydown
has 89 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
keydown: function(e){
if (this.picker.is(':not(:visible)')){
if (e.keyCode == 27) // allow escape to hide and re-show picker
this.show();
return;
Function parseDate
has 87 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
parseDate: function(date, format, language) {
if (date instanceof Date) return date;
if (/^[\-+]\d+[dmwy]([\s,]+[\-+]\d+[dmwy])*$/.test(date)) {
var part_re = /([\-+]\d+)([dmwy])/,
parts = date.match(/([\-+]\d+)([dmwy])/g),
Function click
has 80 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
click: function(e) {
e.stopPropagation();
e.preventDefault();
var target = $(e.target).closest('span, td, th');
if (target.length == 1) {
Function PersistentStorage
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
var PersistentStorage = function() {
var ls, methods;
try {
ls = window.localStorage;
ls.setItem("~~~", "!");
Function Transport
has 75 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
var Transport = function() {
var pendingRequestsCount = 0, pendingRequests = {}, maxPendingRequests, requestCache;
function Transport(o) {
utils.bindAll(this);
o = utils.isString(o) ? {
Function _attachEvents
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
_attachEvents: function(){
this._detachEvents();
if (this.isInput) { // single input
this._events = [
[this.element, {
Method sort_field_helper
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Open
def sort_field_helper(order, sort_field, display_name)
sort_field_order = (order == sort_field) ? "#{sort_field} DESC" : sort_field
symbol = (order == sort_field) ? '»' : (order == sort_field + ' DESC' ? '«' : '«»')
selected_class = (order == sort_field) ? 'selected' : (order == sort_field + ' DESC' ? 'selected' : '')
content_tag(:span, class: selected_class) do
- 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 EventTarget
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
var EventTarget = function() {
var eventSplitter = /\s+/;
return {
on: function(events, callback) {
var event;
Function initialize
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
initialize: function(datasetDefs) {
var datasets;
datasetDefs = utils.isArray(datasetDefs) ? datasetDefs : [ datasetDefs ];
if (datasetDefs.length === 0) {
$.error("no datasets provided");
Function _loadPrefetchData
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
_loadPrefetchData: function(o) {
var that = this, thumbprint = VERSION + (o.thumbprint || ""), storedThumbprint, storedProtocol, storedItemHash, storedAdjacencyList, isExpired, deferred;
if (this.storage) {
storedThumbprint = this.storage.get(keys.thumbprint);
storedProtocol = this.storage.get(keys.protocol);
Function _getLocalSuggestions
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
_getLocalSuggestions: function(terms) {
var that = this, firstChars = [], lists = [], shortestList, suggestions = [];
utils.each(terms, function(i, term) {
var firstChar = term.charAt(0);
!~utils.indexOf(firstChars, firstChar) && firstChars.push(firstChar);
Function updateNavArrows
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
updateNavArrows: function() {
var d = new Date(this.viewDate),
year = d.getUTCFullYear(),
month = d.getUTCMonth();
switch (this.viewMode) {