jacquev6/LowVoltage

View on GitHub
LowVoltage/actions/conversion.py

Summary

Maintainability
D
1 day
Test Coverage

ConversionUnitTests has 32 functions (exceeds 20 allowed). Consider refactoring.
Open

class ConversionUnitTests(_tst.UnitTests):
    def test_convert_unicode_value_to_db(self):
        self.assertEqual(_convert_value_to_db(u"éoà"), {"S": u"éoà"})

    def test_convert_bytes_value_to_db(self):
Severity: Minor
Found in LowVoltage/actions/conversion.py - About 4 hrs to fix

    Function _convert_value_to_db has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def _convert_value_to_db(value):
        if isinstance(value, unicode):
            return {"S": value}
        elif isinstance(value, bytes):
            return {"B": base64.b64encode(value).decode("utf8")}
    Severity: Minor
    Found in LowVoltage/actions/conversion.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 _convert_db_to_value has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def _convert_db_to_value(value):
        if "S" in value:
            return value["S"]
        elif "B" in value:
            return bytes(base64.b64decode(value["B"].encode("utf8")))
    Severity: Minor
    Found in LowVoltage/actions/conversion.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

    Avoid too many return statements within this function.
    Open

            return {"M": {n: _convert_value_to_db(v) for n, v in value.iteritems()}}
    Severity: Major
    Found in LowVoltage/actions/conversion.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return set(bytes(base64.b64decode(v.encode("utf8"))) for v in value["BS"])
      Severity: Major
      Found in LowVoltage/actions/conversion.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return {"NULL": True}
        Severity: Major
        Found in LowVoltage/actions/conversion.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return {"L": [_convert_value_to_db(v) for v in value]}
          Severity: Major
          Found in LowVoltage/actions/conversion.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                        return {"SS": [s for s in value]}
            Severity: Major
            Found in LowVoltage/actions/conversion.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return set(int(v) for v in value["NS"])
              Severity: Major
              Found in LowVoltage/actions/conversion.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return {n: _convert_db_to_value(v) for n, v in value["M"].iteritems()}
                Severity: Major
                Found in LowVoltage/actions/conversion.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                              return {"BS": [base64.b64encode(b).decode("utf8") for b in value]}
                  Severity: Major
                  Found in LowVoltage/actions/conversion.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                return {"NS": [str(n) for n in value]}
                    Severity: Major
                    Found in LowVoltage/actions/conversion.py - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                              return set(value["SS"])
                      Severity: Major
                      Found in LowVoltage/actions/conversion.py - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                return None
                        Severity: Major
                        Found in LowVoltage/actions/conversion.py - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                  return [_convert_db_to_value(v) for v in value["L"]]
                          Severity: Major
                          Found in LowVoltage/actions/conversion.py - About 30 mins to fix

                            There are no issues that match your filters.

                            Category
                            Status