pypen.settings.Settings.__init__()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 17
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 15
nop 13
dl 0
loc 17
rs 9.65
c 0
b 0
f 0

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
from copy import copy
2
3
class Settings:
4
    def __init__(self, fps, width, height, default_pypen_name, _is_executing_with_python,
5
                 _user_has_start, _user_has_update, fill_color, stroke_color, stroke_width,
6
                 _shape_begun, _starting_point):
7
        self.fps = fps
8
        self.width = width
9
        self.height = height
10
        self.default_pypen_name = default_pypen_name
11
        self.fill_color = fill_color
12
        self.stroke_color = stroke_color
13
        self.stroke_width = stroke_width
14
15
        self._is_executing_with_python = _is_executing_with_python
16
        self._user_has_start = _user_has_start
17
        self._user_has_update = _user_has_update
18
19
        self._shape_begun = False
20
        self._starting_point = None
21
22
23
settings = Settings(width=640,
24
                    height=480,
25
                    fps=60,
26
                    default_pypen_name="my_sketch.py",
27
                    fill_color="default_fill_color",
28
                    stroke_color="default_stroke_color",
29
                    stroke_width=0,
30
31
                    _is_executing_with_python=False,
32
                    _user_has_start=True,
33
                    _user_has_update=True,
34
35
                    _shape_begun=False,
36
                    _starting_point=None)
37
38
default_settings = copy(settings)
39