timofurrer/w1thermsensor

View on GitHub

Showing 12 of 22 total issues

File core.py has 396 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
w1thermsensor
~~~~~~~~~~~~~

A Python package and CLI tool to work with w1 temperature sensors.
Severity: Minor
Found in src/w1thermsensor/core.py - About 5 hrs to fix

    File cli.py has 259 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    """
    w1thermsensor
    ~~~~~~~~~~~~~
    
    A Python package and CLI tool to work with w1 temperature sensors.
    Severity: Minor
    Found in src/w1thermsensor/cli.py - About 2 hrs to fix

      Function get has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

      def get(id_, hwid, type_, unit, resolution, as_json, offset):
          """Get temperature of a specific sensor"""
          if id_ and (hwid or type_):
              raise click.BadArgumentUsage(
                  "If --id is given --hwid and --type are not allowed."
      Severity: Minor
      Found in src/w1thermsensor/cli.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 ls has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      def ls(types, as_json, resolution):  # pylint: disable=invalid-name
          """List all available sensors"""
          sensors = W1ThermSensor.get_available_sensors(types)
      
          if as_json:
      Severity: Minor
      Found in src/w1thermsensor/cli.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 resolution has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      def resolution(resolution, id_, hwid, type_):
          """Change the resolution for the sensor and persist it in the sensor's EEPROM"""
          if id_ and (hwid or type_):
              raise click.BadArgumentUsage(
                  "If --id is given --hwid and --type are not allowed."
      Severity: Minor
      Found in src/w1thermsensor/cli.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 evaluate_temperature has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def evaluate_temperature(
      Severity: Major
      Found in src/w1thermsensor/core.py - About 50 mins to fix

        Function get has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def get(id_, hwid, type_, unit, resolution, as_json, offset):
        Severity: Major
        Found in src/w1thermsensor/cli.py - About 50 mins to fix

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

              def __init__(
          Severity: Minor
          Found in src/w1thermsensor/core.py - About 35 mins to fix

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

            def all(types, unit, resolution, as_json):  # pylint: disable=redefined-builtin
                """Get temperatures of all available sensors"""
                sensors = W1ThermSensor.get_available_sensors(types)
                temperatures = []
                for sensor in sensors:
            Severity: Minor
            Found in src/w1thermsensor/cli.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_available_sensors has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def get_available_sensors(
                    cls, types: Optional[Iterable[Union[Sensor, str]]] = None
                ) -> List["W1ThermSensor"]:
                    """Return all available sensors.
            
            
            Severity: Minor
            Found in src/w1thermsensor/core.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

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

                def __init__(
                    self,
                    sensor_type: Optional[Sensor] = None,
                    sensor_id: Optional[str] = None,
                    offset: float = 0.0,
            Severity: Minor
            Found in src/w1thermsensor/core.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

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

                def __post_init__(self):
                    """
                    Validates that the required arguments are set and sanity check that the high points are
                    higher than the associated low points.  This method does not sanity check that values make
                    sense for high/low point outside of high_point > low_point.
            Severity: Minor
            Found in src/w1thermsensor/calibration_data.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

            Severity
            Category
            Status
            Source
            Language