Completed
Pull Request — develop (#230)
by
unknown
04:47 queued 02:38
created

Components/BlockCookieNotification/Partials/AcceptButton/script.js   A

Complexity

Total Complexity 6
Complexity/F 1.2

Size

Lines of Code 32
Function Count 5

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
nc 1
dl 0
loc 32
rs 10
c 1
b 0
f 0
wmc 6
mnd 1
bc 7
fnc 5
bpm 1.4
cpm 1.2
noi 2

4 Functions

Rating   Name   Duplication   Size   Complexity  
A script.js ➔ checkCookies 0 9 2
A script.js ➔ getOptions 0 6 1
A script.js ➔ acceptCookies 0 9 1
A script.js ➔ getCookieValue 0 3 1
1
/* globals Cookies */
2
3
import 'file-loader?name=vendor/js-cookie.js!js-cookie/src/js.cookie'
4
5
export function getOptions (optionContainer) {
0 ignored issues
show
Unused Code introduced by
The parameter optionContainer is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
6
  return {
7
    expireDays: 7,
8
    cookieName: 'cookies_accepted'
9
  }
10
}
11
12
export function acceptCookies ($container, cookieName, expireDays) {
13
  return function (e) {
0 ignored issues
show
Unused Code introduced by
The parameter e is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
14
    Cookies.set(cookieName, true, {
15
      expires: expireDays
16
    })
17
18
    $container.remove()
19
  }
20
}
21
22
export function checkCookies ($container, cookieName) {
23
  const cookiesAccepted = getCookieValue(cookieName)
24
25
  if (!cookiesAccepted) {
26
    $container.addClass('cookieNotification-isVisible')
27
  } else {
28
    $container.remove()
29
  }
30
}
31
32
function getCookieValue (cookieName) {
33
  return Cookies.get(cookieName)
34
}
35