Passed
Pull Request — master (#44)
by Ramon
01:13
created

SConstruct   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 42
dl 0
loc 66
rs 10
c 0
b 0
f 0
wmc 3

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 = 'nptyping'
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', '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 .')
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 'complexity' in COMMAND_LINE_TARGETS:
47
    _exec(f'radon cc {_SUBJECT} -nc --total-average')
48
    _exec(f'xenon {_SUBJECT} --max-absolute B --max-modules A --max-average A --exclude nptyping/config.py')
49
50
51
# FORMAT:
52
53
if 'autoflake' in COMMAND_LINE_TARGETS:
54
    cmd = f'autoflake {_SUBJECT} --recursive --in-place --remove-unused-variables'
55
    if _CHECK_ONLY:
56
        cmd += ' --check'
57
    _exec(cmd)
58
59
if 'isort' in COMMAND_LINE_TARGETS:
60
    cmd = f'isort {_SUBJECT} --recursive --quiet'
61
    if _CHECK_ONLY:
62
        cmd += ' --check'
63
    _exec(cmd)
64
65
Exit(0)
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable Exit does not seem to be defined.
Loading history...
66