SkierPGP/Skier

View on GitHub
skier/keyinfo.py

Summary

Maintainability
D
3 days
Test Coverage

Function pgp_dump has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring.
Open

    def pgp_dump(cls, armored: str, packets: list = None):
        """
        Generates a key using pgpdump.
        :param armored: The armored data to output.
        :param packets: Optional: A packets list to use instead of the armored data.
Severity: Minor
Found in skier/keyinfo.py - About 1 day 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

File keyinfo.py has 342 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import time
import binascii
import base64
from enum import Enum
import pgpdump.packet
Severity: Minor
Found in skier/keyinfo.py - About 4 hrs to fix

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

        def from_database_object(cls, keyob: db.Key):
            k = KeyInfo()
            k.uid = keyob.uid
            for uid in keyob.uid:
                if cfg.cfg.config.features.keybase:
    Severity: Minor
    Found in skier/keyinfo.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 __init__ has 13 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(self, uid: list = None, keyid: str = None, fingerprint: str = None,
    Severity: Major
    Found in skier/keyinfo.py - About 1 hr to fix

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

      def jsondes(obj):
          """Default JSON serializer."""
          import calendar, datetime
      
          if isinstance(obj, datetime.datetime):
      Severity: Minor
      Found in skier/keyinfo.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 translate has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def translate(self, sig):
              if sig[2] == 32:
                  return wrap("revoke")
              elif sig[2] == 24:
                  return wrap("subsig")
      Severity: Minor
      Found in skier/keyinfo.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 _setup_keybase has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def _setup_keybase(self, username):
              if cache.exists("keybase_" + username):
                  miss = False
                  # Load it without autofetching.
                  k = keybaseapi.User(username, autofetch=False)
      Severity: Minor
      Found in skier/keyinfo.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

      Avoid too many return statements within this function.
      Open

                  return wrap("sig")
      Severity: Major
      Found in skier/keyinfo.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return KeyInfo(uid=uid, keyid=keyid, fingerprint=fingerprint, length=length, algo=algo,
        Severity: Major
        Found in skier/keyinfo.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return wrap("sig-2")
          Severity: Major
          Found in skier/keyinfo.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                        return wrap("sig-1")
            Severity: Major
            Found in skier/keyinfo.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                          return wrap("sig??")
              Severity: Major
              Found in skier/keyinfo.py - About 30 mins to fix

                There are no issues that match your filters.

                Category
                Status