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

view.js ➔ ... ➔ $.done   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
/*
2
 * This file is part of CSBill package.
3
 *
4
 * (c) 2013-2015 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
    ['jquery', 'core/module', 'backbone', 'core/alert', 'routing', 'translator', 'client/view/info', './credit', './contacts', 'client/view/address_collection', 'client/model/address_collection'],
12
    function($, Module, Backbone, Alert, Routing, __, InfoView, ClientCredit, ClientContact, AddressView, AddressCollection) {
13
        'use strict';
14
15
        return Module.extend({
16
            regions: {
17
                'clientCredit': '#client-credit',
18
                'clientInfo': '#client-info'
19
            },
20
            _renderCredit: function(options) {
21
                this.app.showChildView('clientCredit', ClientCredit.getView(options));
22
            },
23
            _renderContactCollection: function(layoutView, options) {
24
                layoutView.renderContactsRegion(ClientContact.getView(options));
25
            },
26
            _renderClientAddresses: function(layoutView, options) {
27
                var addressCollection = new AddressCollection(options.addresses, {'id': options.id});
28
29
                var that = this;
30
31
                addressCollection.on('remove', function() {
32
                    addressCollection
33
                        .fetch({reset: true, url: Routing.generate('_xhr_clients_address_list', {'id': options.id})})
34
                        .done(function() {
35
                            layoutView.model.set('addresses', addressCollection.toArray());
36
                            options.addresses = layoutView.model.get('addresses');
37
38
                            layoutView.render();
39
                            that._renderContactCollection(layoutView, options);
40
                            if (addressCollection.length > 0) {
41
                                layoutView.getRegion('clientAddress').show(new AddressView({collection: addressCollection}));
42
                            }
43
                        }
44
                    );
45
                });
46
47
                if (addressCollection.length > 0) {
48
                    layoutView.getRegion('clientAddress').show(new AddressView({collection: addressCollection}));
49
                }
50
            },
51
            _renderClientInfo: function(options) {
52
                var infoView = new InfoView({
53
                    model: new Backbone.Model(options)
54
                });
55
56
                this.app.showChildView('clientInfo', infoView);
57
58
                return infoView;
59
            },
60
            initialize: function(options) {
61
                this._renderCredit(options);
62
63
                var infoView = this._renderClientInfo(options);
64
                this.render(infoView, options);
65
66
                $('#delete-client').on('click', this.deleteClient);
67
            },
68
            render: function(infoView, options) {
69
                this._renderContactCollection(infoView, options);
70
                this._renderClientAddresses(infoView, options);
71
            },
72
            deleteClient: function(event) {
73
                event.preventDefault();
74
75
                var link = $(this);
76
77
                Alert.confirm(__('client.confirm_delete'), function(confirm) {
78
                    if (true === confirm) {
0 ignored issues
show
Complexity Best Practice introduced by
There is no return statement if true === confirm 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...
79
                        $('body').modalmanager('loading');
80
81
                        return $.ajax({
82
                            "url": link.attr("href"),
83
                            "dataType": "json",
84
                            "method": "delete"
85
                        }).done(function() {
86
                            window.document.location = Routing.generate("_clients_index");
87
                        });
88
                    }
89
                });
90
            }
91
        });
92
    }
93
);