Total Complexity | 8 |
Complexity/F | 1 |
Lines of Code | 43 |
Function Count | 8 |
Duplicated Lines | 43 |
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 | import Cookies from 'js-cookie' |
||
3 | import * as types from '../mutation-types' |
||
4 | |||
5 | // state |
||
6 | export const state = { |
||
7 | code: null, |
||
8 | uploader: null |
||
9 | } |
||
10 | |||
11 | // getters |
||
12 | export const getters = { |
||
13 | code: state => state.code, |
||
14 | uploader: state => state.uploader, |
||
15 | } |
||
16 | |||
17 | // mutations |
||
18 | export const mutations = { |
||
19 | |||
20 | [types.CODE_SAVE] (state, { code }) { |
||
21 | state.code = code |
||
22 | }, |
||
23 | [types.CODE_UPDATE] (state, { code }) { |
||
24 | state.code = code |
||
25 | }, |
||
26 | [types.Uploader] (state, { uploader }) { |
||
27 | state.uploader = uploader |
||
28 | } |
||
29 | } |
||
30 | |||
31 | // actions |
||
32 | export const actions = { |
||
33 | saveCode ({ commit, dispatch }, payload) { |
||
34 | commit(types.CODE_SAVE, payload) |
||
35 | }, |
||
36 | |||
37 | updateCode ({ commit }, payload) { |
||
38 | commit(types.CODE_UPDATE, payload) |
||
39 | }, |
||
40 | setUploader: function({commit, dispatch}, payload) { |
||
41 | commit(types.Uploader, payload) |
||
42 | }, |
||
43 | } |
||
44 |