cidc_schemas/template_writer.py
File template_writer.py
has 383 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
# -*- coding: utf-8 -*-
"""Defines the `XlTemplateWriter` class for writing `Template`s to Excel templates."""
import logging
Function _write_data_dict
has a Cognitive Complexity of 15 (exceeds 10 allowed). Consider refactoring. Open
Open
def _write_data_dict(self, schemas):
"""
Adds a "Data Dictionary" tab that lists all used enums with allowed values.
Returns: a dict mapping field names to data dictionary sheet ranges of enum
- 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 _write_legend_item
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def _write_legend_item(cls, ws, row_n, name, theme, prop_schema):
Avoid too many return
statements within this function. Open
Open
return None
Function _write_worksheet
has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring. Open
Open
def _write_worksheet(self, name, schema, workbook, write_title=False):
"""Write content to the given worksheet"""
assert self.workbook, "_write_worksheet called without an initialized workbook"
assert self.template, "_write_worksheet called without an initialized template"
- 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"