Total Complexity | 4 |
Complexity/F | 1 |
Lines of Code | 52 |
Function Count | 4 |
Duplicated Lines | 52 |
Ratio | 100 % |
Changes | 0 |
Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | View Code Duplication | import axios from 'axios' |
|
|
|||
2 | |||
3 | export function createActions(route) { |
||
4 | return { |
||
5 | LOAD_COUNTERS: ({ commit }) => { |
||
6 | return new Promise(resolve => { |
||
7 | axios |
||
8 | .all([ |
||
9 | axios.get(route('admin.posts.draft.counter')), |
||
10 | axios.get(route('admin.posts.pending.counter')), |
||
11 | axios.get(route('admin.posts.published.counter')), |
||
12 | axios.get(route('admin.users.active.counter')), |
||
13 | axios.get(route('admin.form_submissions.counter')) |
||
14 | ]) |
||
15 | .then( |
||
16 | axios.spread( |
||
17 | ( |
||
18 | newPostsCount, |
||
19 | pendingPostsCount, |
||
20 | publishedPostsCount, |
||
21 | activeUsersCount, |
||
22 | formSubmissionsCount |
||
23 | ) => { |
||
24 | commit('SET_COUNTER', { |
||
25 | type: 'newPostsCount', |
||
26 | counter: newPostsCount.data |
||
27 | }) |
||
28 | commit('SET_COUNTER', { |
||
29 | type: 'pendingPostsCount', |
||
30 | counter: pendingPostsCount.data |
||
31 | }) |
||
32 | commit('SET_COUNTER', { |
||
33 | type: 'publishedPostsCount', |
||
34 | counter: publishedPostsCount.data |
||
35 | }) |
||
36 | commit('SET_COUNTER', { |
||
37 | type: 'activeUsersCount', |
||
38 | counter: activeUsersCount.data |
||
39 | }) |
||
40 | commit('SET_COUNTER', { |
||
41 | type: 'formSubmissionsCount', |
||
42 | counter: formSubmissionsCount.data |
||
43 | }) |
||
44 | |||
45 | resolve() |
||
46 | } |
||
47 | ) |
||
48 | ) |
||
49 | }) |
||
50 | } |
||
51 | } |
||
52 | } |
||
53 |