KarrLab/obj_tables

View on GitHub
obj_tables/sci/units.py

Summary

Maintainability
D
2 days
Test Coverage
A
99%

File units.py has 452 lines of code (exceeds 250 allowed). Consider refactoring.
Open

""" Unit attribute

:Author: Jonathan Karr <karr@mssm.edu>
:Date: 2019-01-20
:Copyright: 2019, Karr Lab
Severity: Minor
Found in obj_tables/sci/units.py - About 6 hrs to fix

    Function validate has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        def validate(self, obj, value):
            """ Determine if :obj:`value` is a valid value for this UnitAttribute
    
            Args:
                obj (:obj:`Model`): class being validated
    Severity: Minor
    Found in obj_tables/sci/units.py - About 2 hrs 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 validate has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        def validate(self, obj, value):
            """ Determine if :obj:`value` is a valid value for this QuantityAttribute
    
            Args:
                obj (:obj:`Model`): class being validated
    Severity: Minor
    Found in obj_tables/sci/units.py - About 2 hrs 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 get_xlsx_validation has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_xlsx_validation(self, sheet_models=None, doc_metadata_model=None):
            """ Get XLSX validation
    
            Args:
                sheet_models (:obj:`list` of :obj:`Model`, optional): models encoded as separate sheets
    Severity: Minor
    Found in obj_tables/sci/units.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 __init__ has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def __init__(self, registry, choices=None, none=True, default=None, default_cleaned_value=None,
                     none_value=None, verbose_name='', description="Units (e.g. 'second', 'meter', or 'gram')",
                     primary=False, unique=False, unique_case_insensitive=False):
            """
            Args:
    Severity: Minor
    Found in obj_tables/sci/units.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 __init__ has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def __init__(self, registry, choices=None, none=True, default=None, default_cleaned_value=None,
                     none_value=None, verbose_name='', description="Units (e.g. 'second', 'meter', or 'gram')",
                     primary=False, unique=False, unique_case_insensitive=False):
            """
            Args:
    Severity: Minor
    Found in obj_tables/sci/units.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 __init__ has 11 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(self, registry, choices=None, none=True, default=None, default_cleaned_value=None,
    Severity: Major
    Found in obj_tables/sci/units.py - About 1 hr to fix

      Function __init__ has 11 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(self, registry, choices=None, none=True, default=None, default_cleaned_value=None,
      Severity: Major
      Found in obj_tables/sci/units.py - About 1 hr to fix

        Function get_obj_units has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        def get_obj_units(obj):
            """ Get units used in a model object and related objects
        
            Args:
                obj (:obj:`core.Model`): model object
        Severity: Minor
        Found in obj_tables/sci/units.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 value_equal has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def value_equal(self, val1, val2, tol=1e-12):
                """ Determine if attribute values are equal
        
                Args:
                    val1 (:obj:`pint.quantity._Quantity`): first value
        Severity: Minor
        Found in obj_tables/sci/units.py - About 45 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

        Function clean has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def clean(self, value):
                """ Convert attribute value into the appropriate type
        
                Args:
                    value (:obj:`object`): value of attribute to clean
        Severity: Minor
        Found in obj_tables/sci/units.py - About 35 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

        Function clean has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def clean(self, value):
                """ Convert attribute value into the appropriate type
        
                Args:
                    value (:obj:`object`): value of attribute to clean
        Severity: Minor
        Found in obj_tables/sci/units.py - About 35 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

        Function get_xlsx_validation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_xlsx_validation(self, sheet_models=None, doc_metadata_model=None):
                """ Get XLSX validation
        
                Args:
                    sheet_models (:obj:`list` of :obj:`Model`, optional): models encoded as separate sheets
        Severity: Minor
        Found in obj_tables/sci/units.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