Passed
Push — master ( 7d6f78...eb825e )
by Konstantin
11:20
created

exportChildren.exportChildren()   C

Complexity

Conditions 9

Size

Total Lines 23
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 23
rs 6.6666
c 0
b 0
f 0
cc 9
nop 8

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
# pylint: disable=line-too-long,invalid-name,missing-module-docstring,missing-function-docstring
2
def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='OrderedGroupType', fromsubclass_=False, pretty_print=True): # pylint: disable=unused-argument,too-many-arguments
3
    namespaceprefix_ = 'pc:'
4
    if self.UserDefined is not None:
5
        self.UserDefined.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UserDefined', pretty_print=pretty_print)
6
    for Labels_ in self.Labels:
7
        Labels_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Labels', pretty_print=pretty_print)
8
    cleaned = []
9
    def replaceWithRRI(group):
10
        rri = RegionRefIndexedType.factory(parent_object_=self) # pylint: disable=undefined-variable
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable RegionRefIndexedType does not seem to be defined.
Loading history...
11
        rri.index = group.index
12
        rri.regionRef = group.regionRef
13
        cleaned.append(rri)
14
    # remove emtpy groups and replace with RegionRefIndexedType
15
    for entry in self.get_AllIndexed():
16
        # pylint: disable=undefined-variable
17
        if isinstance(entry, (OrderedGroupIndexedType)) and not entry.get_AllIndexed():
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable OrderedGroupIndexedType does not seem to be defined.
Loading history...
18
            replaceWithRRI(entry)
19
        elif isinstance(entry, UnorderedGroupIndexedType) and not entry.get_UnorderedGroupChildren():
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable UnorderedGroupIndexedType does not seem to be defined.
Loading history...
20
            replaceWithRRI(entry)
21
        else:
22
            cleaned.append(entry)
23
    for entry in cleaned:
24
        entry.export(outfile, level, namespaceprefix_, namespacedef_='', name_=entry.__class__.__name__[:-4], pretty_print=pretty_print)
25