Test Failed
Pull Request — master (#156)
by Jan
04:14 queued 01:43
created

oval_graph.command_line_client.client_json_input   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 22
dl 0
loc 28
ccs 18
cts 18
cp 1
rs 10
c 0
b 0
f 0
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A ClientJsonInput.load_rule_names() 0 2 1
A ClientJsonInput.__init__() 0 3 1
A ClientJsonInput.search_rules_id() 0 5 1
A ClientJsonInput.get_json_data_file() 0 8 3
1 1
import json
2
3 1
from .client import Client
4
5
6 1
class ClientJsonInput(Client):
7 1
    def __init__(self, args):
8 1
        super().__init__(args)
9 1
        self.json_data_file = self.get_json_data_file()
10
11 1
    def get_json_data_file(self):
12 1
        with open(self.source_filename, 'r') as f:
13 1
            try:
14 1
                return json.load(f)
15 1
            except Exception as error:
16 1
                raise ValueError(
17
                    'Used file "{}" is not valid json.'.format(
18
                        self.source_filename))
19
20 1
    def load_rule_names(self):
21 1
        return self.json_data_file.keys()
22
23 1
    def search_rules_id(self):
24 1
        rules = self._get_wanted_rules_from_array_of_IDs(
25
            self.load_rule_names())
26 1
        notselected_rules = []
27
        return self._check_rules_id(rules, notselected_rules)
28