Total Complexity | 5 |
Complexity/F | 1.25 |
Lines of Code | 23 |
Function Count | 4 |
Duplicated Lines | 23 |
Ratio | 100 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 | var Cache = /** @class */ (function () { |
|
|
|||
2 | function Cache(cacheItem, timer) { |
||
3 | this.cacheItem = cacheItem; |
||
4 | this.timer = (timer * 1000); |
||
5 | this.timeCached = (new Date()).getTime(); |
||
6 | } |
||
7 | Cache.prototype.get = function () { |
||
8 | if ((this.timeCached + this.timer) < (new Date()).getTime()) { |
||
9 | this.cacheItem = null; |
||
10 | this.timeCached = null; |
||
11 | return null; |
||
12 | } |
||
13 | else { |
||
14 | return this.cacheItem; |
||
15 | } |
||
16 | }; |
||
17 | Cache.prototype.refresh = function (cacheItem) { |
||
18 | this.timeCached = (new Date()).getTime(); |
||
19 | this.cacheItem = cacheItem; |
||
20 | }; |
||
21 | return Cache; |
||
22 | }()); |
||
23 | export { Cache }; |
||
24 | //# sourceMappingURL=cache.js.map |