wikimedia/wikimedia-fundraising-dash

View on GitHub

Showing 93 of 93 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

            return connection.query( update, updateParams )
                .then( function ( dbResults ) {
                    if ( dbResults[ 0 ].affectedRows !== 1 ) {
                        // Either the instance doesn't exist or it's not ours
                        throw new Error( 'Instance ' + instance.id + ' with owner ' + instance.ownerId + ' not found' );
Severity: Major
Found in persistence.js and 1 other location - About 2 hrs to fix
persistence.js on lines 231..237

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 76.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

            return connection.query( update, updateParams )
                .then( function ( dbResults ) {
                    if ( dbResults[ 0 ].affectedRows !== 1 ) {
                        // Either the board doesn't exist or it's not ours
                        throw new Error( 'Board ' + board.id + ' with owner ' + board.ownerId + ' not found' );
Severity: Major
Found in persistence.js and 1 other location - About 2 hrs to fix
persistence.js on lines 128..134

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 76.

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

Further Reading

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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

            persistence.saveBoard( board ).then( function () {
                res.json( { success: true, id: board.id } );
            }, function ( error ) {
                res.json( { error: error } );
            } );
    Severity: Major
    Found in routes/board.js and 1 other location - About 1 hr to fix
    routes/widget.js on lines 21..25

    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 74.

    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

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

            self.disposables.push( self.includeEndowment.subscribe( function () {
                self.config.includeEndowment = self.includeEndowment();
                self.logStateChange();
                self.reloadData();
            } ) );
    src/components/widgets/totals-earned-chart/totals-earned-chart.js on lines 116..120

    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 74.

    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

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

            persistence.saveWidgetInstance( instance ).then( function () {
                res.json( { success: true, id: instance.id } );
            }, function ( error ) {
                res.json( { error: error } );
            } );
    Severity: Major
    Found in routes/widget.js and 1 other location - About 1 hr to fix
    routes/board.js on lines 15..19

    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 74.

    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

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

            self.disposables.push( self.majorDonationCutoff.subscribe( function () {
                self.config.majorDonationCutoff = self.majorDonationCutoff();
                self.logStateChange();
                self.reloadData();
            } ) );
    src/components/widgets/totals-earned-chart/totals-earned-chart.js on lines 110..114

    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 74.

    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

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

                            value: function ( value, ratio, id ) {
                                var display;
                                if ( id === 'Hourly Total' ) {
                                    display = numeral( value ).format( '$0,0' );
                                } else {
    src/components/widgets/totals-earned-chart/totals-earned-chart.js on lines 403..411

    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 74.

    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

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

                            value: function ( value, ratio, id ) {
                                var display;
                                if ( id === 'Daily Total' ) {
                                    display = numeral( value ).format( '$0,0' );
                                } else {
    src/components/widgets/totals-earned-chart/totals-earned-chart.js on lines 334..342

    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 74.

    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

    Further Reading

    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 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 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

                    Identical blocks of code found in 2 locations. Consider refactoring.
                    Open

                            persistence.loginUser( req.session.passport.user ).then( function () {
                                res.redirect( '/' );
                            }, function ( error ) {
                                res.json( error );
                            } );
                    Severity: Major
                    Found in server.js and 1 other location - About 1 hr to fix
                    server.js on lines 136..140

                    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 65.

                    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

                    Further Reading

                    Identical blocks of code found in 2 locations. Consider refactoring.
                    Open

                                persistence.loginUser( req.session.passport.user ).then( function () {
                                    res.redirect( '/' );
                                }, function ( error ) {
                                    res.json( error );
                                } );
                    Severity: Major
                    Found in server.js and 1 other location - About 1 hr to fix
                    server.js on lines 125..129

                    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 65.

                    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

                    Further Reading

                    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
                      Severity
                      Category
                      Status
                      Source
                      Language