src/ReTweetable.ts   A
last analyzed

Complexity

Total Complexity 4
Complexity/F 2

Size

Lines of Code 31
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 24
dl 0
loc 31
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0
wmc 4
mnd 2
bc 2
fnc 2
bpm 1
cpm 2
noi 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
A ReTweetableAbstract.isReTweetable 0 12 3
A ReTweetableAbstract.getRetweetValidations 0 2 1
1
export interface ReTweetableInterface {
2
    retweetError: string;
3
4
    isReTweetable(): boolean;
5
    getRetweetValidations(): Validation[];
6
}
7
8
export type Validation = {
9
    validate: () => boolean,
10
    message: () => string
11
};
12
13 5
export abstract class ReTweetableAbstract implements ReTweetableInterface {
14 100
    retweetError = '';
15
16
    abstract getRetweetValidations(): Validation[];
17
18
    isReTweetable(): boolean {
19 26
        const validations = this.getRetweetValidations();
20
21 26
        for (const validation of validations) {
22 127
            if (validation.validate()) {
23 17
                this.retweetError = validation.message();
24 17
                return false;
25
            }
26
        }
27
28 9
        return true;
29
    }
30
}
31