Passed
Push — master ( 1adf40...f067da )
by lv
01:05
created

app/model/catering/desk.js   A

Complexity

Total Complexity 4
Complexity/F 1

Size

Lines of Code 43
Function Count 4

Duplication

Duplicated Lines 43
Ratio 100 %

Importance

Changes 0
Metric Value
cc 0
wmc 4
eloc 23
c 0
b 0
f 0
nc 1
mnd 0
bc 4
fnc 4
dl 43
loc 43
rs 10
bpm 1
cpm 1
noi 0

4 Functions

Rating   Name   Duplication   Size   Complexity  
A module.exports.list 12 12 1
A module.exports.edit 5 5 1
A module.exports.first 11 11 1
A module.exports.add 4 4 1

How to fix   Duplicated Code   

Duplicated Code

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
const DB = require('../../libraries/db')
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
2
const ModelBase = require('../../model/base')
3
4
const table = 'mist_desk'
5
6
module.exports = {
7
    add: async function (data) {
8
        let res = await ModelBase.execInsert(table, data)
9
        return res;
10
    },
11
12
	list: async function (storeId) {
13
14
		let result = await DB.readMysql.select(
15
			'*'
16
		)
17
			.from(table)
18
			.where('store_id', storeId)
19
			.where('status', '!=', -1)
20
21
		return result
22
23
	},
24
25
	first: async function (id) {
26
27
		let result = await DB.readMysql.first(
28
			'*'
29
		)
30
			.from(table)
31
			.where('id', id)
32
33
		return result
34
35
	},
36
37
	edit: async function (data, where, notWhere = {}) {
38
		let result = await ModelBase.execUpdate(table, data, where, notWhere)
39
40
		return result
41
	}
42
43
}
44