Passed
Pull Request — master (#161)
by Jan
04:20
created

data_cleaner   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 30
dl 0
loc 49
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A tests.data_cleaner.cleandir() 0 8 3
A tests.data_cleaner.replace_hash() 0 5 1
1
import fileinput
0 ignored issues
show
introduced by
Missing module docstring
Loading history...
introduced by
import missing from __future__ import absolute_import
Loading history...
2
import re
3
import os
4
from glob import glob
5
from shutil import rmtree
6
7
"""
8
cleandir is function which removes generated reports.
9
"""
0 ignored issues
show
Unused Code introduced by
This string statement has no effect and could be removed.
Loading history...
10
11
12
def cleandir():
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
13
    path = os.getcwd()
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
Comprehensibility Bug introduced by
path is re-defining a name which is already available in the outer-scope (previously defined on line 34).

It is generally a bad practice to shadow variables from the outer-scope. In most cases, this is done unintentionally and might lead to unexpected behavior:

param = 5

class Foo:
    def __init__(self, param):   # "param" would be flagged here
        self.param = param
Loading history...
14
    pattern = os.path.join(path, "graph-of-*")
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
15
16
    for item in glob(pattern):
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
17
        if not os.path.isdir(item):
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
18
            continue
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 12 tabs, expected 3
Loading history...
19
        rmtree(item)
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
20
21
22
"""
23
Data_cleaner is script which removes randomly generated items from test files.
24
"""
0 ignored issues
show
Unused Code introduced by
This string statement has no effect and could be removed.
Loading history...
25
26
27
def replace_hash(line):
0 ignored issues
show
Comprehensibility Bug introduced by
line is re-defining a name which is already available in the outer-scope (previously defined on line 47).

It is generally a bad practice to shadow variables from the outer-scope. In most cases, this is done unintentionally and might lead to unexpected behavior:

param = 5

class Foo:
    def __init__(self, param):   # "param" would be flagged here
        self.param = param
Loading history...
introduced by
Missing function or method docstring
Loading history...
28
    return re.sub(
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
29
        r'([a-zA-Z]|\d){8}-([a-zA-Z]|\d){4}-([a-zA-Z]|\d){4}-([a-zA-Z]|\d){4}-([a-zA-Z]|\d){12}',
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (97/80).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
30
        'UUID-HASH',
31
        str(line))
32
33
34
path = './'
0 ignored issues
show
Coding Style Naming introduced by
Constant name "path" doesn't conform to '(([A-Z_][A-Z0-9_]*)|(__.*__))$' pattern ('(([A-Z_][A-Z0-9_]*)|(__.*__))$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
35
36
files = []
37
38
# r=root, d=directories, f = files
39
for r, d, f in os.walk(path):
40
    for file_ in f:
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
41
        if '.json' in file_ or '.js' in file_:
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
42
            files.append(os.path.join(r, file_))
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 12 tabs, expected 3
Loading history...
43
44
for file_src in files:
45
    print(file_src)
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
46
    with fileinput.FileInput(file_src, inplace=True) as f:
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 4 tabs, expected 1
Loading history...
47
        for line in f:
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 8 tabs, expected 2
Loading history...
48
            print(replace_hash(line), end="")
0 ignored issues
show
Coding Style introduced by
Bad indentation. Found 12 tabs, expected 3
Loading history...
49