GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#709)
by
unknown
06:22 queued 36s
created

app/assets/javascripts/user_edit.js   A

Complexity

Total Complexity 8
Complexity/F 2

Size

Lines of Code 58
Function Count 4

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 58
rs 10
wmc 8
eloc 37
mnd 4
bc 4
fnc 4
bpm 1
cpm 2
noi 10

1 Function

Rating   Name   Duplication   Size   Complexity  
B user_edit.js ➔ clearRole 0 19 8
1
$(document).on('turbolinks:load', function(){
2
    var controller = $("body").data('controller');
3
    var action = $("body").data('action');
4
    if ((controller == "admins" && action == "edit_user") || (controller == "users" && action == "edit")) {
5
        $(".setting-btn").click(function(data){
6
            var url = $("body").data("relative-root")
7
            if (!url.endsWith("/")) {
8
                url += "/"
9
            }
10
            url += "admins?setting=" + data.target.id
11
12
            window.location.href = url
13
        })
14
15
        $(".clear-role").click(clearRole)
16
17
        $("#role-select-dropdown").change(function(data){
18
            dropdown = $("#role-select-dropdown");
0 ignored issues
show
Bug introduced by
The variable dropdown seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.dropdown.
Loading history...
19
            select_role_id = dropdown.val();
0 ignored issues
show
Bug introduced by
The variable select_role_id seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.select_role_id.
Loading history...
20
21
            if(select_role_id){
22
                selected_role = dropdown.find('[value=\"' + select_role_id + '\"]');
0 ignored issues
show
Bug introduced by
The variable selected_role seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.selected_role.
Loading history...
23
                selected_role.prop("disabled", true)
24
25
                tag_container = $("#role-tag-container");
0 ignored issues
show
Bug introduced by
The variable tag_container seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.tag_container.
Loading history...
26
                tag_container.append("<span id=\"user-role-tag_" + select_role_id + "\" style=\"background-color:" + selected_role.data("colour") + ";\" class=\"tag\">" + 
27
                    selected_role.text() + "<a data-role-id=\"" + select_role_id + "\" class=\"tag-addon clear-role\"><i data-role-id=\"" + select_role_id + "\" class=\"fas fa-times\"></i></a></span>");
28
29
                role_ids = $("#user_role_ids").val()
0 ignored issues
show
Bug introduced by
The variable role_ids seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.role_ids.
Loading history...
30
                role_ids += " " + select_role_id
31
                $("#user_role_ids").val(role_ids)
32
                
33
                $("#user-role-tag_" + select_role_id).click(clearRole);
34
                dropdown.val(null)
35
            }
36
        })
37
    }
38
})
39
40
function clearRole(data){
41
    role_id = $(data.target).data("role-id");
0 ignored issues
show
Bug introduced by
The variable role_id seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.role_id.
Loading history...
42
    role_tag = $("#user-role-tag_" + role_id);
0 ignored issues
show
Bug introduced by
The variable role_tag seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.role_tag.
Loading history...
43
    $(role_tag).remove()
44
  
45
    role_ids = $("#user_role_ids").val()
0 ignored issues
show
Bug introduced by
The variable role_ids seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.role_ids.
Loading history...
46
    parsed_ids = role_ids.split(' ')
0 ignored issues
show
Bug introduced by
The variable parsed_ids seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.parsed_ids.
Loading history...
47
  
48
    var index = parsed_ids.indexOf(role_id.toString());
49
  
50
    if (index > -1) {
51
        parsed_ids.splice(index, 1);
52
    }
53
  
54
    $("#user_role_ids").val(parsed_ids.join(' '))
55
  
56
    selected_role = $("#role-select-dropdown").find('[value=\"' + role_id + '\"]');
0 ignored issues
show
Bug introduced by
The variable selected_role seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.selected_role.
Loading history...
57
    selected_role.prop("disabled", false)
58
}