Narzędzie |
Opis |
looks for programming errors, helps enforcing a coding standard and sniffs for some code smells. It additionally includes pyreverse (an UML diagram generator) and symilar (a similarities checker). |
|
tool that computes various metrics from the source code like McCabe’s complexity, raw metrics (SLOC, blank lines etc.), halstead metrics, maintainability index |
|
finds unused code in Python programs. This is useful for cleaning up and finding errors in large code bases. |
def compareTimMin(time, timeList, distance): 31 = test = len(time.split(':')) flattened = [ n for row in matrix for n in row ] # 2 + doubled = [ n * 2 for n in numbers if n % 2 == 1 ] # 2 + time_in_sec_from_min = [ x*60 for x in time ] # 1 + fahrenheit = [ ((float(9)/5)* x + 32) for x in Celsius if x > 0 ] # + 1 + 1 + coloured_things = [ (x,y) for x in colours for y in things ] # 2 + if (test == 2 or test == 6) and (distance <= 7 and distance > 1): # 1 + 3 + list2 = [ float('.'.join(i.split(':'))) for i in timeList ] # 1 + out = ':'.join(list2.split('.')) if (len(out) > 0 and len(out) <= 4) or len == -2: # 1 + 2 + out += '0' ind = vdot.iloc[:, distance - 1][vdot.iloc[:,distance - 1] == out].index.tolist()[0] return out, ind elif (test == 2 or test == 4) and (distance > 7 and distance <= 42) : # 1 + 3 + print("Error: time must be in format(hh:mm:ss)") return "", "" elif (test == 3 or test == 1) and (distance > 7 and distance <= 42): # 1 + 3 + list2 = [ int(''.join(i.split(':'))) for i in timeList ] # 1 + out = out[:1] + ':' + out[1:3] + ':' + out[3:] ind = vdot.iloc[:, distance - 1][vdot.iloc[:,distance - 1] == out].index.tolist()[0] return out, ind elif (test == 3 or test == 4) and (distance <= 7 and distance > 1): # 1 + 3 + print("Error: time must be in format(mm:ss)") return "", ""
radon cc time.py -s
time.py
F 1:0 compareTimMin - E (31)
Wynik liczony jest od 1, dlatego uzyskaliśmy 12 punktów mimo, że suma daje 11
Construct |
Effect on CC |
Reasoning |
|
+ 1 |
An |
|
+ 1 |
The |
|
+ 0 |
The |
|
+ 1 |
There is a decision at the start of the loop. |
|
+ 1 |
There is a decision at the |
|
+ 1 |
Each except branch adds a new conditional path of execution. |
|
+ 0 |
The finally block is unconditionally executed. |
|
+ 1 |
The |
|
+ 1 |
The |
|
+ 1 |
A list/set/dict comprehension of generator expression is equivalent to a for loop. |
|
+ 1 |
Every boolean operator (and, or) adds a decision point. |
CC score |
Rank |
Risk |
1 - 5 |
A |
low - simple block |
6 - 10 |
B |
low - well structured and stable block |
11 - 20 |
C |
moderate - slighltly complex block |
21 - 30 |
D |
more than moderate - more complex block |
31 - 40 |
E |
high - complex block, alarming |
41+ |
F |
very high - error-prone, unstable block |
Metrics | Before refactorization | After refactorization |
---|---|---|
Cyclomatic Complexity [lower is better] |
calc.py
F 40:0 menu - B (9)
vdot.py
F 7:0 compareTimMin - C (12)
9 blocks (classes, functions, methods) analyzed. Average complexity: A (3.33) |
24 blocks (classes, functions, methods) analyzed. Average complexity: A (1.25) |
Maintainability Index [higher is better] |
calc.py - A (47.36)
vdot.py - A (51.01) Average maintainability: 49.19 |
runningCalculator.py - A (84.58)
calculator.py - A (57.13)
constants.py - A (79.88)
control.py - A (64.79)
runningIndex.py - A (78.45)
utils.py - A (51.99) Average maintainability: 69.47 |
Unused, dead code by Vulture |
vdot.py:65: unused variable 'timeTab' (60% confidence) |
No errors |
Pylint [higher is better, can be negative] |
Your code has been rated at -1.58/10 |
Your code has been rated at 9.17/10 |