Passed
Push — master ( 361725...fcee18 )
by Daniel
02:49
created

tableau_hyper_management.BasicNeeds   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 56.67 %

Importance

Changes 0
Metric Value
eloc 18
dl 17
loc 30
rs 10
c 0
b 0
f 0
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A BasicNeeds.fn_timestamped_print() 4 4 1
A BasicNeeds.fn_load_configuration() 5 5 2
A BasicNeeds.fn_optional_print() 3 3 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
"""
2
BasicNeeds - useful functions library
3
4
This library has functions useful to keep main logic short and simple
5
"""
6
7
# standard Python packages
8
from datetime import datetime, timezone
9
import json
10
import os.path
11
12
13 View Code Duplication
class BasicNeeds:
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
14
    cfg_dtls = {}
15
16
    def fn_load_configuration(self):
17
        with open(os.path.dirname(__file__) + "/config.json", 'r') as json_file:
18
            self.cfg_dtls = json.load(json_file)
19
            self.cfg_dtls['data_types']['empty'] = ''
20
            self.cfg_dtls['data_types']['str'] = '.'
21
22
    def fn_optional_print(self, boolean_variable, string_to_print):
23
        if boolean_variable:
24
            self.fn_timestamped_print(self, string_to_print)
25
26
    @staticmethod
27
    def fn_timestamped_print(self, string_to_print):
28
        print(datetime.now(timezone.utc).strftime("%Y-%b-%d %H:%M:%S.%f %Z")
29
              + ' - ' + string_to_print)
30