Completed
Pull Request — master (#25)
by Alejandro
03:58
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 88.89%

Importance

Changes 0
Metric Value
cc 0
wmc 8
eloc 25
nc 1
mnd 1
bc 4
fnc 6
dl 0
loc 37
ccs 16
cts 18
cp 0.8889
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 3
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 3
export const _listServers = ServersService => ({
16
  type: FETCH_SERVERS,
17
  servers: ServersService.listServers(),
18
});
19 3
export const listServers = () => _listServers(ServersService);
20
21 3
export const _createServer = (ServersService, server) => {
22 1
  ServersService.createServer(server);
23 1
  return _listServers(ServersService);
24
};
25 3
export const createServer = curry(_createServer)(ServersService);
26
27 3
export const _deleteServer = (ServersService, server) => {
28 1
  ServersService.deleteServer(server);
29 1
  return _listServers(ServersService);
30
};
31 3
export const deleteServer = curry(_deleteServer)(ServersService);
32
33 3
export const _createServers = (ServersService, servers) => {
34
  ServersService.createServers(servers);
35
  return _listServers(ServersService);
36
};
37
export const createServers = curry(_createServers)(ServersService);
38