Completed
Push — GildedRose/js ( a01e2a )
by
unknown
05:41 queued 03:38
created

src/GildedRose/gilded_rose.js   A

Complexity

Total Complexity 20
Complexity/F 10

Size

Lines of Code 55
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
c 1
b 0
f 0
nc 1
dl 0
loc 55
rs 10
wmc 20
mnd 6
bc 22
fnc 2
bpm 11
cpm 10
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
D gilded_rose.js ➔ update_quality 0 47 19
1
function Item(name, sell_in, quality) {
2
    this.name = name;
3
    this.sell_in = sell_in;
4
    this.quality = quality;
5
}
6
7
var items = [];
8
9
function update_quality() {
10
    for (var i = 0; i < items.length; i++) {
11
        if (items[i].name != 'Aged Brie' && items[i].name != 'Backstage passes to a TAFKAL80ETC concert') {
12
            if (items[i].quality > 0) {
13
                if (items[i].name != 'Sulfuras, Hand of Ragnaros') {
14
                    items[i].quality = items[i].quality - 1
15
                }
16
            }
17
        } else {
18
            if (items[i].quality < 50) {
19
                items[i].quality = items[i].quality + 1
20
                if (items[i].name == 'Backstage passes to a TAFKAL80ETC concert') {
21
                    if (items[i].sell_in < 11) {
22
                        if (items[i].quality < 50) {
23
                            items[i].quality = items[i].quality + 1
24
                        }
25
                    }
26
                    if (items[i].sell_in < 6) {
27
                        if (items[i].quality < 50) {
28
                            items[i].quality = items[i].quality + 1
29
                        }
30
                    }
31
                }
32
            }
33
        }
34
        if (items[i].name != 'Sulfuras, Hand of Ragnaros') {
35
            items[i].sell_in = items[i].sell_in - 1;
36
        }
37
        if (items[i].sell_in < 0) {
38
            if (items[i].name != 'Aged Brie') {
39
                if (items[i].name != 'Backstage passes to a TAFKAL80ETC concert') {
40
                    if (items[i].quality > 0) {
41
                        if (items[i].name != 'Sulfuras, Hand of Ragnaros') {
42
                            items[i].quality = items[i].quality - 1
43
                        }
44
                    }
45
                } else {
46
                    items[i].quality = items[i].quality - items[i].quality
47
                }
48
            } else {
49
                if (items[i].quality < 50) {
50
                    items[i].quality = items[i].quality + 1
51
                }
52
            }
53
        }
54
    }
55
}
56