Completed
Pull Request — develop (#249)
by Xaver
28s
created

service-worker.js   A

Complexity

Total Complexity 7
Complexity/F 1.17

Size

Lines of Code 24
Function Count 6

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
wmc 7
c 1
b 0
f 0
nc 1
mnd 1
bc 7
fnc 6
dl 0
loc 24
rs 10
bpm 1.1666
cpm 1.1666
noi 6

1 Function

Rating   Name   Duplication   Size   Complexity  
A self.addEventListener(ꞌfetchꞌ) 0 13 2
1
self.addEventListener('install', function (event) {
0 ignored issues
show
Bug introduced by
The variable self seems to be never declared. If this is a global, consider adding a /** global: self */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
2
  var offlineRequest = new Request('offline.html');
0 ignored issues
show
Bug introduced by
The variable Request seems to be never declared. If this is a global, consider adding a /** global: Request */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
3
  event.waitUntil(
4
    fetch(offlineRequest).then(function (response) {
5
      return caches.open('offline').then(function (cache) {
0 ignored issues
show
Bug introduced by
The variable caches seems to be never declared. If this is a global, consider adding a /** global: caches */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
6
        return cache.put(offlineRequest, response);
7
      });
8
    })
9
  );
10
});
11
12
self.addEventListener('fetch', function (event) {
0 ignored issues
show
Bug introduced by
The variable self seems to be never declared. If this is a global, consider adding a /** global: self */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
13
  var request = event.request;
14
  if (request.method === 'GET') {
15
    event.respondWith(
16
      fetch(request).catch(function () {
17
        console.log(request);
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
18
        return caches.open('offline').then(function (cache) {
0 ignored issues
show
Bug introduced by
The variable caches seems to be never declared. If this is a global, consider adding a /** global: caches */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
19
          return cache.match('offline.html');
20
        });
21
      })
22
    );
23
  }
24
});
25