Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Push — master ( d3ad00...acd091 )
by Pierre
04:27
created

action.js ➔ ... ➔ ItemView.extend._executeAction   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 25
rs 8.8571
c 0
b 0
f 0
1
/*
2
 * This file is part of CSBill project.
3
 *
4
 * (c) 2013-2017 Pierre du Plessis <[email protected]>
5
 *
6
 * This source file is subject to the MIT license that is bundled
7
 * with this source code in the file LICENSE.
8
 */
9
10
define(
11
    ['core/view', 'jquery', 'template', 'lodash', 'routing', 'core/alert'],
12
    function(ItemView, $, Template, _, Routing, Alert) {
13
        return ItemView.extend({
14
            tagName: 'span',
15
            template: Template.datagrid.action,
16
            ui: {
17
                button: ".btn"
18
            },
19
            events: {
20
                'click @ui.button': 'confirm'
21
            },
22
            confirm: function() {
23
                if (_.isEmpty(this.getOption('grid').getSelectedModels())) {
24
                    return Alert.alert('You need to select at least one row');
25
                }
26
27
                if (!_.isEmpty(this.model.get('confirm'))) {
28
                    var view = this;
29
                    Alert.confirm(this.model.get('confirm'), function(response) {
30
                        if (true === response) {
0 ignored issues
show
Complexity Best Practice introduced by
There is no return statement if true === response is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
31
                            return view._executeAction();
32
                        }
33
                    });
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
34
                } else {
35
                    this._executeAction();
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
36
                }
37
            },
38
            _executeAction: function() {
39
                var grid = this.getOption('grid');
40
41
                var models = _.map(
42
                    grid.getSelectedModels(),
43
                    function(model) {
44
                        return model.id;
45
                    }),
46
47
                    promise = $.ajax({
48
                        url: Routing.generate(this.model.get('action')),
49
                        data: {'data': models},
50
                        method: 'POST'
51
                    });
52
53
                promise.done(_.bind(function() {
54
                    grid.collection.fetch({
55
                        success: function() {
56
                            grid.clearSelectedModels();
57
                        }
58
                    });
59
                }, this));
60
61
                return promise;
62
            }
63
        })
0 ignored issues
show
Coding Style introduced by
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
64
    }
65
);