Function init_schema
has a Cognitive Complexity of 154 (exceeds 5 allowed). Consider refactoring. Open
def init_schema(filename, out_filename=None):
""" Initialize an `ObjTables` schema from a tabular declarative specification in
:obj:`filename`. :obj:`filename` can be a XLSX, CSV, or TSV file.
Schemas (classes and attributes) should be defined using the following tabular format.
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
File utils.py
has 881 lines of code (exceeds 250 allowed). Consider refactoring. Open
""" Utilities
:Author: Jonathan Karr <karr@mssm.edu>
:Author: Arthur Goldberg <Arthur.Goldberg@mssm.edu>
:Date: 2016-11-23
Function viz_schema
has a Cognitive Complexity of 79 (exceeds 5 allowed). Consider refactoring. Open
def viz_schema(module, filename, attributes=True, tail_labels=True, hidden_classes=None, extra_edges=None,
model_names=None,
rank_sep=None,
node_sep=None,
node_width=None,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function get_attribute_by_name
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
def get_attribute_by_name(cls, group_name, attr_name, verbose_name=False, case_insensitive=False):
""" Return the attribute of :obj:`Model` class :obj:`cls` with name :obj:`name`
Args:
cls (:obj:`class`): Model class
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function viz_schema
has 21 arguments (exceeds 4 allowed). Consider refactoring. Open
def viz_schema(module, filename, attributes=True, tail_labels=True, hidden_classes=None, extra_edges=None,
Function diff_workbooks
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def diff_workbooks(filename_1, filename_2, models, model_name, schema_name=None, **kwargs):
""" Get difference of models in two workbooks
Args:
filename_1 (:obj:`str`): path to first workbook
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function randomize_object_graph
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def randomize_object_graph(obj):
""" Randomize the order of the edges (RelatedManagers) in the object's object graph.
Args:
obj (:obj:`Model`): instance of :obj:`Model`
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Consider simplifying this complex logical expression. Open
if (not case_insensitive and ((not verbose_name and attr.name == attr_name) or
(verbose_name and attr.verbose_name == attr_name))) or \
(case_insensitive and ((not verbose_name and attr.name.lower() == attr_name.lower()) or
(verbose_name and attr.verbose_name.lower() == attr_name.lower()))):
return (None, attr)
Function init_schema
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
def init_schema(filename, out_filename=None):
""" Initialize an `ObjTables` schema from a tabular declarative specification in
:obj:`filename`. :obj:`filename` can be a XLSX, CSV, or TSV file.
Schemas (classes and attributes) should be defined using the following tabular format.
Function get_related_models
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def get_related_models(root_model, include_root_model=False):
""" Get the models that have relationships to a model
Args:
root_model (:obj:`type`): subclass of :obj:`Model`
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function set_git_repo_metadata_from_path
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def set_git_repo_metadata_from_path(model, repo_type, path='.', url_attr='url', branch_attr='branch',
Avoid deeply nested control flow statements. Open
if isinstance(val, list) and len(val) > 1:
# randomize children
objs_to_randomize.extend(val)
# shuffle related manager
Function diff_workbooks
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def diff_workbooks(filename_1, filename_2, models, model_name, schema_name=None, **kwargs):
Function get_attrs
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def get_attrs():
""" Get a dictionary of the defined types of attributes for use with :obj:`init_schema`.
Returns:
:obj:`dict`: dictionary which maps the name of each attribute to its instance
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function get_attribute_by_name
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_attribute_by_name(cls, group_name, attr_name, verbose_name=False, case_insensitive=False):
Function to_pandas
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def to_pandas(objs, models=None, get_related=True,