Passed
Push — master ( 5c289d...24a8ee )
by Ramon
01:12 queued 11s
created

SConstruct   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 45
dl 0
loc 70
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A _exec() 0 6 3
1
import subprocess
2
3
_CHECK_ONLY = 'check' in COMMAND_LINE_TARGETS
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable COMMAND_LINE_TARGETS does not seem to be defined.
Loading history...
4
_CONTINUE = 'continue' in COMMAND_LINE_TARGETS
5
_SUBJECT = 'barentsz'
6
7
8
def _exec(cmd: str) -> None:
9
    print(f'>>> {cmd}')
10
    exit_code = subprocess.call(cmd, shell=True)
11
    if exit_code != 0 and not _CONTINUE:
12
        print(f'Exiting with {exit_code}')
13
        Exit(exit_code)
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable Exit does not seem to be defined.
Loading history...
14
15
16
# COMBINATIONS:
17
18
if 'all' in COMMAND_LINE_TARGETS:
19
    COMMAND_LINE_TARGETS += ['format', 'quality']
20
21
if 'quality' in COMMAND_LINE_TARGETS:
22
    COMMAND_LINE_TARGETS += ['test', 'doctest', 'coverage', 'pycodestyle', 'pylint', 'mypy', 'complexity']
23
24
if 'format' in COMMAND_LINE_TARGETS:
25
    COMMAND_LINE_TARGETS += ['autoflake', 'isort']
26
27
28
# QUALITY:
29
30
if 'test' in COMMAND_LINE_TARGETS:
31
    _exec('python -m unittest discover tests')
32
33
if 'doctest' in COMMAND_LINE_TARGETS:
34
    _exec('python -m doctest README.md')
35
36
if 'coverage' in COMMAND_LINE_TARGETS:
37
    _exec('coverage run -m unittest discover tests')
38
    _exec('coverage report -m --fail-under=100')
39
40
if 'pycodestyle' in COMMAND_LINE_TARGETS:
41
    _exec(f'pycodestyle {_SUBJECT} -v --config=setup.cfg')
42
43
if 'pylint' in COMMAND_LINE_TARGETS:
44
    _exec(f'pylint --rcfile=setup.cfg {_SUBJECT}')
45
46
if 'mypy' in COMMAND_LINE_TARGETS:
47
    _exec(f'mypy {_SUBJECT} --show-error-codes --disallow-untyped-defs')
48
49
if 'complexity' in COMMAND_LINE_TARGETS:
50
    _exec(f'radon cc {_SUBJECT}')
51
    _exec(f'radon cc {_SUBJECT} -nc --total-average')
52
    _exec(f'xenon {_SUBJECT} --max-absolute B --max-modules A --max-average A')
53
54
55
# FORMAT:
56
57
if 'autoflake' in COMMAND_LINE_TARGETS:
58
    cmd = f'autoflake {_SUBJECT}/_here.py --recursive --in-place --remove-unused-variables --expand-star-imports'
59
    if _CHECK_ONLY:
60
        cmd += ' --check'
61
    _exec(cmd)
62
63
if 'isort' in COMMAND_LINE_TARGETS:
64
    cmd = f'isort {_SUBJECT} --recursive --quiet'
65
    if _CHECK_ONLY:
66
        cmd += ' --check'
67
    _exec(cmd)
68
69
Exit(0)
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable Exit does not seem to be defined.
Loading history...
70