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
Push — master ( b76a04...86e5e1 )
by Zhmayev
01:15
created

$(document).ready   A

Complexity

Conditions 1
Paths 2

Size

Total Lines 54

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 54
rs 9.6716

5 Functions

Rating   Name   Duplication   Size   Complexity  
B 0 30 1
A 0 4 1
A 0 4 1
A 0 3 1
A 0 4 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
jQuery(document).ready(function ($) {
2
3
  $('#wp-admin-bar-pagespeed_purge')
4
    .click(function (event) {
5
      event.preventDefault();
6
7
      var spinner = $(this).find('a');
8
      pagespeed_purge_animate(spinner);
9
10
      // Purge cache for the entire website
11
      // More info: https://modpagespeed.com/doc/system#purge_cache
12
      $.ajax({
13
          method: "PURGE",
14
          url: document.location.origin + '/*'
15
        })
16
        .done(function (msg) {
17
          if (msg && msg.indexOf("successful") > -1) {
18
            pagespeed_purge_success(spinner);
19
          } else {
20
            pagespeed_purge_error(spinner);
21
          }
22
        })
23
        .fail(function () {
24
          pagespeed_purge_error(spinner);
25
        })
26
        .always(function () {
27
          setTimeout(function () {
28
            pagespeed_purge_reset(spinner);
29
          }, 750);
30
        });
31
32
      return false;
33
    });
34
35
  function pagespeed_purge_animate(spinner) {
36
    pagespeed_purge_reset(spinner);
37
    spinner.addClass('spin');
38
  }
39
40
  function pagespeed_purge_error(spinner) {
41
    pagespeed_purge_reset(spinner);
42
    spinner.addClass('error');
43
  }
44
45
  function pagespeed_purge_success(spinner) {
46
    pagespeed_purge_reset(spinner);
47
    spinner.addClass('success');
48
  }
49
50
  function pagespeed_purge_reset(spinner) {
51
    spinner.removeClass('spin').removeClass('success').removeClass('error');
52
  }
53
54
});