pwabuilder-sw-register.js   A
last analyzed

Complexity

Total Complexity 2
Complexity/F 2

Size

Lines of Code 11
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 11
rs 10
c 0
b 0
f 0
wmc 2
mnd 1
bc 1
fnc 1
bpm 1
cpm 2
noi 3
1
//This is the service worker with the Cache-first network
2
3
//Add this below content to your HTML page, or add the js file to your page at the very top to register service worker
4
if (navigator.serviceWorker.controller) {
0 ignored issues
show
Bug introduced by
The variable navigator seems to be never declared. If this is a global, consider adding a /** global: navigator */ 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...
5
  console.log('[PWA Builder] active service worker found, no need to register')
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...
6
} else {
7
8
//Register the ServiceWorker
9
  navigator.serviceWorker.register('pwabuilder-sw.js', {
10
    scope: './'
11
  }).then(function(reg) {
12
    console.log('Service worker has been registered for scope:'+ reg.scope);
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...
13
  });
14
}