Fixed code smell 'Functions, methods, and lambdas should not have too many parameters' reported by SonarQube.

This commit is contained in:
Khushboo Vashi 2020-07-14 19:23:50 +05:30 committed by Akshay Joshi
parent d6893f9d8a
commit bd9dc97b4f
3 changed files with 52 additions and 41 deletions

View File

@ -670,12 +670,12 @@ register_dialect("unix", UnixDialect)
class DictReader(object):
def __init__(self, f, fieldnames=None, restkey=None, restval=None,
dialect="excel", *args, **kwds):
*args, **kwds):
self._fieldnames = fieldnames # list of keys for the dict
self.restkey = restkey # key to catch long rows
self.restval = restval # default value for short rows
self.reader = Reader(f, dialect, *args, **kwds)
self.dialect = dialect
self.dialect = kwds.get('dialect', "excel")
self.reader = Reader(f, self.dialect, *args, **kwds)
self.line_num = 0
def __iter__(self):
@ -721,14 +721,14 @@ class DictReader(object):
class DictWriter(object):
def __init__(self, f, fieldnames, restval="", extrasaction="raise",
dialect="excel", *args, **kwds):
def __init__(self, f, fieldnames, *args, **kwds):
self.fieldnames = fieldnames # list of keys for the dict
self.restval = restval # for writing short dicts
if extrasaction.lower() not in ("raise", "ignore"):
self.extrasaction = kwds.get('extrasaction', "raise")
self.restval = kwds.get('restval', "") # for writing short dicts
if self.extrasaction.lower() not in ("raise", "ignore"):
raise ValueError("extrasaction (%s) must be 'raise' or 'ignore'"
% extrasaction)
self.extrasaction = extrasaction
% self.extrasaction)
dialect = kwds.get('dialect', "excel")
self.Writer = Writer(f, dialect, *args, **kwds)
def writeheader(self):

View File

@ -17,24 +17,23 @@ class MenuItem(object):
class Panel(object):
def __init__(
self, name, title, content='', width=500, height=600, is_iframe=True,
show_title=True, is_closeable=True, is_private=False, priority=None,
icon=None, data=None, events=None, limit=None, can_hide=False
self, name, title, content='', width=500, height=600, **kwargs
):
self.name = name
self.title = title
self.content = content
self.width = width
self.height = height
self.isIframe = is_iframe
self.showTitle = show_title
self.isCloseable = is_closeable
self.isPrivate = is_private
self.icon = icon
self.data = data
self.events = events
self.limit = limit
self.canHide = can_hide
self.isIframe = kwargs.get('is_iframe', True)
self.showTitle = kwargs.get('show_title', True)
self.isCloseable = kwargs.get('is_closeable', True)
self.isPrivate = kwargs.get('is_private', None)
self.icon = kwargs.get('icon', None)
self.data = kwargs.get('data', None)
self.events = kwargs.get('events', None)
self.limit = kwargs.get('limit', False)
self.canHide = kwargs.get('can_hide', False)
priority = kwargs.get('priority', None)
if priority is None:
global PRIORITY
PRIORITY += 100

View File

@ -31,9 +31,7 @@ class _Preference(object):
"""
def __init__(
self, cid, name, label, _type, default, help_str=None,
min_val=None, max_val=None, options=None, select2=None, fields=None,
allow_blanks=None
self, cid, name, label, _type, default, **kwargs
):
"""
__init__
@ -67,13 +65,13 @@ class _Preference(object):
self.default = default
self.label = label
self._type = _type
self.help_str = help_str
self.min_val = min_val
self.max_val = max_val
self.options = options
self.select2 = select2
self.fields = fields
self.allow_blanks = allow_blanks
self.help_str = kwargs.get('help_str', None)
self.min_val = kwargs.get('min_val', None)
self.max_val = kwargs.get('max_val', None)
self.options = kwargs.get('options', None)
self.select2 = kwargs.get('select2', None)
self.fields = kwargs.get('fields', None)
self.allow_blanks = kwargs.get('allow_blanks', None)
# Look into the configuration table to find out the id of the specific
# preference.
@ -391,9 +389,7 @@ class Preferences(object):
return res
def register(
self, category, name, label, _type, default, min_val=None,
max_val=None, options=None, help_str=None, category_label=None,
select2=None, fields=None, allow_blanks=None
self, category, name, label, _type, default, **kwargs
):
"""
register
@ -419,6 +415,15 @@ class Preferences(object):
take input from user e.g. keyboardshortcut preference)
:param allow_blanks: Flag specify whether to allow blank value.
"""
min_val = kwargs.get('min_val', None)
max_val = kwargs.get('max_val', None)
options = kwargs.get('options', None)
help_str = kwargs.get('help_str', None)
category_label = kwargs.get('category_label', None)
select2 = kwargs.get('select2', None)
fields = kwargs.get('fields', None)
allow_blanks = kwargs.get('allow_blanks', None)
cat = self.__category(category, category_label)
if name in cat['preferences']:
return (cat['preferences'])[name]
@ -432,8 +437,9 @@ class Preferences(object):
), "Type cannot be found in the defined list!"
(cat['preferences'])[name] = res = _Preference(
cat['id'], name, label, _type, default, help_str, min_val,
max_val, options, select2, fields, allow_blanks
cat['id'], name, label, _type, default, help_str=help_str,
min_val=min_val, max_val=max_val, options=options,
select2=select2, fields=fields, allow_blanks=allow_blanks
)
return res
@ -469,9 +475,7 @@ class Preferences(object):
@classmethod
def register_preference(
cls, module, category, name, label, _type, default, min_val=None,
max_val=None, options=None, help_str=None, module_label=None,
category_label=None
cls, module, category, name, label, _type, default, **kwargs
):
"""
register
@ -493,6 +497,13 @@ class Preferences(object):
:param module_label: Label for the module
:param category_label: Label for the category
"""
min_val = kwargs.get('min_val', None)
max_val = kwargs.get('max_val', None)
options = kwargs.get('options', None)
help_str = kwargs.get('help_str', None)
module_label = kwargs.get('module_label', None)
category_label = kwargs.get('category_label', None)
m = None
if module in Preferences.modules:
m = Preferences.modules[module]
@ -502,8 +513,9 @@ class Preferences(object):
m = Preferences(module, module_label)
return m.register(
category, name, label, _type, default, min_val, max_val,
options, help_str, category_label
category, name, label, _type, default, min_val=min_val,
max_val=max_val, options=options, help_str=help_str,
category_label=category_label
)
@staticmethod