Showing 47 of 93 total issues
File persistence.js
has 279 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
var config = require( './config.js' ),
promiseDbLib = require( 'mysql-promise' );
function getConnection() {
var promiseDb = promiseDbLib();
Function FiltersViewModel
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function FiltersViewModel( params ) {
var self = this;
this.filters = ko.observableArray( [] );
this.setChoices = function () {
Function makeDailyChart
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
self.makeDailyChart = function ( /* d, i */ ) {
return {
size: {
height: 450,
width: window.width
Function loadData
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
self.loadData = function ( data, timestamp ) {
var runningTotal = 0,
currentDate = new Date(),
lastData,
days = self.campaign().getLengthInDays(),
Function DistanceToGoalChartViewModel
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function DistanceToGoalChartViewModel( params ) {
var self = this;
WidgetBase.call( this, params );
self.hasData = ko.observable( false );
Function loginUser
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
loginUser: function ( user ) {
var params = [ user.id, user.provider, user.displayName ],
insertUser = 'INSERT IGNORE INTO dash_user ( oauth_id, oauth_provider, display_name ) VALUES ( ?, ?, ? )',
getInfo = 'SELECT id, default_board, avatar, title, email from dash_user where oauth_id = ? and oauth_provider = ?',
insertBoard = 'INSERT INTO dash_board ( display_name, description, owner_id ) VALUES ( ?, \'\', ? );' +
Function DatePickerViewModel
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function DatePickerViewModel( params ) {
var self = this;
self.setupTimepicker = function ( event ) {
$( '#' + event.target.id ).timepicker( {
Function makeCharts
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
self.makeCharts = function () {
if ( params.sharedContext.dailyDataArray.length < 2 ) {
return;
}
self.hasData( true );
Function createQueryString
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
self.createQueryString = function () {
var qs = self.filterQueryString(),
ds = '',
timePresets = [
'Last 15 Minutes',
Function renderPercentRangeChart
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
self.renderPercentRangeChart = function () {
var canvas = $( '#fraudPercentRanges' )[ 0 ],
ctx = canvas.getContext( '2d' ),
placeholder = document.createElement( 'canvas' ),
Function Top10ViewModel
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function Top10ViewModel( params ) {
WidgetBase.call( this, params );
var self = this;
Function update
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
update: function ( el, valueAccessor, allBindingsAccessor /* , viewModel */ ) {
var allBindings = allBindingsAccessor(),
converted,
textAccessor;
Function getBoard
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
getBoard: function ( boardId, userId ) {
var board,
connection = getConnection(),
select = 'SELECT owner_id, display_name, description, is_shared FROM dash_board WHERE id = ? AND ( is_shared OR owner_id = ? )';
Function GenericBoardViewModel
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function GenericBoardViewModel( params ) {
var self = this,
timeFormat = 'dddd, MMMM Do YYYY, h:mm:ss a';
Function saveBoard
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
saveBoard: function ( board ) {
var connection = getConnection(),
insert = 'INSERT INTO dash_board ( owner_id, display_name, description, is_shared ) VALUES ( ?, ?, ?, ? )',
addWidget = 'INSERT INTO dash_widget_instance_board ( instance_id, board_id, widget_position ) SELECT ?, b.id, COALESCE( MAX( widget_position ), 0 ) + 1 FROM dash_board b LEFT JOIN dash_widget_instance_board i ON b.id = i.board_id WHERE b.id = ? AND b.owner_id = ?',
addWidgetParams = [ board.addWidget, board.id, board.ownerId ],
Function filterText
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
self.filterText = ko.computed( function () {
var filterName,
text,
parts = [],
choices = self.userChoices(),
Function validateValue
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Open
function validateValue( value, column ) {
var valid = false,
i;
switch ( column.type ) {
case 'dropdown':
- 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 validateValue
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function validateValue( value, column ) {
var valid = false,
i;
switch ( column.type ) {
case 'dropdown':
Function saveWidgetConfig
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
self.saveWidgetConfig = function () {
self.config.userChoices = self.userChoices();
self.config.filterQueryString = self.filterQueryString();
var data = JSON.stringify( {
Function TextFilterViewModel
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function TextFilterViewModel( params ) {
var self = this;
this.operators = [
ops.eq,