Completed
Pull Request — master (#25)
by Alejandro
03:20
created

src/servers/reducers/server.js   A

Complexity

Total Complexity 8
Complexity/F 1.33

Size

Lines of Code 44
Function Count 6

Duplication

Duplicated Lines 0
Ratio 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
cc 0
wmc 8
eloc 25
c 0
b 0
f 0
nc 1
mnd 1
bc 4
fnc 6
dl 0
loc 44
rs 10
bpm 0.6666
cpm 1.3333
noi 0
ccs 18
cts 18
cp 1
crap 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
A server.js ➔ reducer 0 8 3
A server.js ➔ ??? 0 4 1
1
import { curry } from 'ramda';
2
import serversService from '../services/ServersService';
3
4 8
export const FETCH_SERVERS = 'shlink/servers/FETCH_SERVERS';
5
6
export default function reducer(state = {}, action) {
7 2
  switch (action.type) {
8
    case FETCH_SERVERS:
9 1
      return action.servers;
10
    default:
11 1
      return state;
12
  }
13
}
14
15 8
export const _listServers = (serversService) => ({
16
  type: FETCH_SERVERS,
17
  servers: serversService.listServers(),
18
});
19
20 8
export const listServers = () => _listServers(serversService);
21
22 8
export const _createServer = (serversService, server) => {
23 1
  serversService.createServer(server);
24
25 1
  return _listServers(serversService);
26
};
27
28 8
export const createServer = curry(_createServer)(serversService);
29
30 8
export const _deleteServer = (serversService, server) => {
31 1
  serversService.deleteServer(server);
32
33 1
  return _listServers(serversService);
34
};
35
36 8
export const deleteServer = curry(_deleteServer)(serversService);
37
38 8
export const _createServers = (serversService, servers) => {
39 1
  serversService.createServers(servers);
40
41 1
  return _listServers(serversService);
42
};
43
44
export const createServers = curry(_createServers)(serversService);
45