lib/cache.js   A
last analyzed

Complexity

Total Complexity 5
Complexity/F 1.25

Size

Lines of Code 25
Function Count 4

Duplication

Duplicated Lines 25
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
c 1
b 0
f 0
nc 1
dl 25
loc 25
rs 10
wmc 5
mnd 1
bc 6
fnc 4
bpm 1.5
cpm 1.25
noi 0

4 Functions

Rating   Name   Duplication   Size   Complexity  
A Cache.get 10 10 2
A cache.js ➔ Cache 5 5 1
A Cache.refresh 4 4 1
A Cache.constructor 22 22 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
"use strict";
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
2
Object.defineProperty(exports, "__esModule", { value: true });
3
var Cache = /** @class */ (function () {
4
    function Cache(cacheItem, timer) {
5
        this.cacheItem = cacheItem;
6
        this.timer = (timer * 1000);
7
        this.timeCached = (new Date()).getTime();
8
    }
9
    Cache.prototype.get = function () {
10
        if ((this.timeCached + this.timer) < (new Date()).getTime()) {
11
            this.cacheItem = null;
12
            this.timeCached = null;
13
            return null;
14
        }
15
        else {
16
            return this.cacheItem;
17
        }
18
    };
19
    Cache.prototype.refresh = function (cacheItem) {
20
        this.timeCached = (new Date()).getTime();
21
        this.cacheItem = cacheItem;
22
    };
23
    return Cache;
24
}());
25
exports.Cache = Cache;
26
//# sourceMappingURL=cache.js.map