wikimedia/wikimedia-fundraising-dash

View on GitHub

Showing 47 of 93 total issues

File persistence.js has 279 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var config = require( './config.js' ),
    promiseDbLib = require( 'mysql-promise' );

function getConnection() {
    var promiseDb = promiseDbLib();
Severity: Minor
Found in persistence.js - About 2 hrs to fix

    Function FiltersViewModel has 67 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function FiltersViewModel( params ) {
            var self = this;
    
            this.filters = ko.observableArray( [] );
            this.setChoices = function () {
    Severity: Major
    Found in src/components/filters/filters.js - About 2 hrs to fix

      Function makeDailyChart has 66 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              self.makeDailyChart = function ( /* d, i */ ) {
                  return {
                      size: {
                          height: 450,
                          width: window.width
      Severity: Major
      Found in src/components/widgets/totals-earned-chart/totals-earned-chart.js - About 2 hrs to fix

        Function loadData has 58 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                self.loadData = function ( data, timestamp ) {
                    var runningTotal = 0,
                        currentDate = new Date(),
                        lastData,
                        days = self.campaign().getLengthInDays(),
        Severity: Major
        Found in src/components/widgets/totals-earned-chart/totals-earned-chart.js - About 2 hrs to fix

          Function DistanceToGoalChartViewModel has 54 lines of code (exceeds 25 allowed). Consider refactoring.
          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

                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 ( ?, \'\', ? );' +
            Severity: Major
            Found in persistence.js - About 2 hrs to fix

              Function DatePickerViewModel has 47 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  function DatePickerViewModel( params ) {
                      var self = this;
              
                      self.setupTimepicker = function ( event ) {
                          $( '#' + event.target.id ).timepicker( {
              Severity: Minor
              Found in src/components/utils/date-pickers/date-pickers.js - About 1 hr to fix

                Function makeCharts has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                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

                          self.createQueryString = function () {
                              var qs = self.filterQueryString(),
                                  ds = '',
                                  timePresets = [
                                      'Last 15 Minutes',
                  Severity: Minor
                  Found in src/components/widgets/fraud-gauge/fraud-gauge.js - About 1 hr to fix

                    Function renderPercentRangeChart has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            self.renderPercentRangeChart = function () {
                    
                                var canvas = $( '#fraudPercentRanges' )[ 0 ],
                                    ctx = canvas.getContext( '2d' ),
                                    placeholder = document.createElement( 'canvas' ),
                    Severity: Minor
                    Found in src/components/widgets/fraud-gauge/fraud-gauge.js - About 1 hr to fix

                      Function Top10ViewModel has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          function Top10ViewModel( params ) {
                      
                              WidgetBase.call( this, params );
                      
                              var self = this;
                      Severity: Minor
                      Found in src/components/widgets/top10/top10.js - About 1 hr to fix

                        Function update has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                                update: function ( el, valueAccessor, allBindingsAccessor /* , viewModel */ ) {
                                    var allBindings = allBindingsAccessor(),
                                        converted,
                                        textAccessor;
                        
                        
                        Severity: Minor
                        Found in src/app/bindings.js - About 1 hr to fix

                          Function getBoard has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                          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 = ? )';
                          
                          
                          Severity: Minor
                          Found in persistence.js - About 1 hr to fix

                            Function GenericBoardViewModel has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                function GenericBoardViewModel( params ) {
                            
                                    var self = this,
                                        timeFormat = 'dddd, MMMM Do YYYY, h:mm:ss a';
                            
                            
                            Severity: Minor
                            Found in src/components/boards/generic-board/generic-board.js - About 1 hr to fix

                              Function saveBoard has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                              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 ],
                              Severity: Minor
                              Found in persistence.js - About 1 hr to fix

                                Function filterText has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                        self.filterText = ko.computed( function () {
                                            var filterName,
                                                text,
                                                parts = [],
                                                choices = self.userChoices(),
                                Severity: Minor
                                Found in src/app/widgetBase.js - About 1 hr to fix

                                  Function validateValue has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                  function validateValue( value, column ) {
                                      var valid = false,
                                          i;
                                      switch ( column.type ) {
                                          case 'dropdown':
                                  Severity: Minor
                                  Found in routes/data.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 validateValue has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  function validateValue( value, column ) {
                                      var valid = false,
                                          i;
                                      switch ( column.type ) {
                                          case 'dropdown':
                                  Severity: Minor
                                  Found in routes/data.js - About 1 hr to fix

                                    Function saveWidgetConfig has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                            self.saveWidgetConfig = function () {
                                                self.config.userChoices = self.userChoices();
                                                self.config.filterQueryString = self.filterQueryString();
                                    
                                                var data = JSON.stringify( {
                                    Severity: Minor
                                    Found in src/app/widgetBase.js - About 1 hr to fix

                                      Function TextFilterViewModel has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                          function TextFilterViewModel( params ) {
                                              var self = this;
                                      
                                              this.operators = [
                                                  ops.eq,
                                      Severity: Minor
                                      Found in src/components/filters/text-filter/text-filter.js - About 1 hr to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language