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

src/servers/reducers/server.js   A

Complexity

Total Complexity 8
Complexity/F 1.33

Size

Lines of Code 37
Function Count 6

Duplication

Duplicated Lines 0
Ratio 0 %

Test Coverage

Coverage 100%

Importance

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

2 Functions

Rating   Name   Duplication   Size   Complexity  
A server.js ➔ reducer 0 8 3
A server.js ➔ ??? 0 4 1
1
import serversService from '../services/ServersService';
2
import { curry } from 'ramda';
3
4 7
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 7
export const _listServers = serversService => ({
16
  type: FETCH_SERVERS,
17
  servers: serversService.listServers(),
18
});
19 7
export const listServers = () => _listServers(serversService);
20
21 7
export const _createServer = (serversService, server) => {
22 1
  serversService.createServer(server);
23 1
  return _listServers(serversService);
24
};
25 7
export const createServer = curry(_createServer)(serversService);
26
27 7
export const _deleteServer = (serversService, server) => {
28 1
  serversService.deleteServer(server);
29 1
  return _listServers(serversService);
30
};
31 7
export const deleteServer = curry(_deleteServer)(serversService);
32
33 7
export const _createServers = (serversService, servers) => {
34 1
  serversService.createServers(servers);
35 1
  return _listServers(serversService);
36
};
37
export const createServers = curry(_createServers)(serversService);
38