ulikoehler/UliEngineering

View on GitHub
UliEngineering/EngineerIO.py

Summary

Maintainability
C
1 day
Test Coverage

File EngineerIO.py has 422 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
A python script to normalize a wide variety of value notations
from electronics engineering.
Severity: Minor
Found in UliEngineering/EngineerIO.py - About 6 hrs to fix

    Function split_input has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        def split_input(self, s):
            """
            Separate a string into a number, suffix and unit plus prefixes.
            Does not try to parse the numbers.
            returns None if the string could not be parsed.
    Severity: Minor
    Found in UliEngineering/EngineerIO.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 split_unit has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def split_unit(self, s):
            """
            Split a string into (remainder, unit).
            Only units in the units set are recognized
            unit may be '' if no unit is recognized
    Severity: Minor
    Found in UliEngineering/EngineerIO.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 normalize_numeric_safe has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def normalize_numeric_safe(self, arg):
            """
            Normalize each element of an iterable and retrieve only the numeric value
            (the unit is ignored). Works on iterables and string-likes.
    
    
    Severity: Minor
    Found in UliEngineering/EngineerIO.py - About 55 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 __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(self, units=_default_units(),
    Severity: Minor
    Found in UliEngineering/EngineerIO.py - About 35 mins to fix

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

          def normalize_numeric_verify_unit(self, arg, reference: Unit):
              """
              Normalize a value. If it is a string
              verify if its unit matches the reference unit.
              """
      Severity: Minor
      Found in UliEngineering/EngineerIO.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 normalize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def normalize(self, s, encoding="utf8"):
              """
              Converts an engineer's input of a wide variety of formats to a numeric
              value.
      
      
      Severity: Minor
      Found in UliEngineering/EngineerIO.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 _format_with_suffix has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def _format_with_suffix(v, suffix="", significant_digits=3):
          """
          Format a given value with a given suffix.
          This helper function formats the value to 3 visible digits.
          v must be pre-multiplied by the factor implied by the suffix.
      Severity: Minor
      Found in UliEngineering/EngineerIO.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