CIMAC-CIDC/cidc-schemas

View on GitHub
cidc_schemas/template_writer.py

Summary

Maintainability
C
7 hrs
Test Coverage
A
98%

File template_writer.py has 383 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-

"""Defines the `XlTemplateWriter` class for writing `Template`s to Excel templates."""

import logging
Severity: Minor
Found in cidc_schemas/template_writer.py - About 5 hrs to fix

    Function _write_data_dict has a Cognitive Complexity of 15 (exceeds 10 allowed). Consider refactoring.
    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
    Severity: Minor
    Found in cidc_schemas/template_writer.py - About 1 hr to fix

    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

        def _write_legend_item(cls, ws, row_n, name, theme, prop_schema):
    Severity: Minor
    Found in cidc_schemas/template_writer.py - About 35 mins to fix

      Avoid too many return statements within this function.
      Open

              return None
      Severity: Major
      Found in cidc_schemas/template_writer.py - About 30 mins to fix

        Function _write_worksheet has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
        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"
        
        Severity: Minor
        Found in cidc_schemas/template_writer.py - About 25 mins to fix

        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

        There are no issues that match your filters.

        Category
        Status