Passed
Push — develop ( 28324e...c851a6 )
by Plexxi
05:20 queued 02:38
created

PascalRowAction   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 27
rs 10
wmc 11

2 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 0 2 1
D _compute_pascal_row() 0 23 10
1
import math
2
3
4
from st2common.runners.base_action import Action
5
6
7
class PascalRowAction(Action):
8
    def run(self, **kwargs):
9
        return PascalRowAction._compute_pascal_row(**kwargs)
10
11
    @staticmethod
12
    def _compute_pascal_row(row_index=0):
13
        if row_index == 'a':
14
            return False, 'This is suppose to fail don\'t worry!!'
15
        elif row_index == 'b':
16
            return None
17
        elif row_index == 'complex_type':
18
            result = PascalRowAction()
19
            return (False, result)
20
        elif row_index == 'c':
21
            return False, None
22
        elif row_index == 'd':
23
            return 'succeeded', [1, 2, 3, 4]
24
        elif row_index == 'e':
25
            return [1, 2]
26
        elif row_index == 5:
27
            return [math.factorial(row_index) /
28
                    (math.factorial(i) * math.factorial(row_index - i))
29
                    for i in range(row_index + 1)]
30
        else:
31
            return True, [math.factorial(row_index) /
32
                          (math.factorial(i) * math.factorial(row_index - i))
33
                          for i in range(row_index + 1)]
34