SkierPGP/Skier

View on GitHub

Showing 37 of 42 total issues

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

Function import_key has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

def import_key(keyserver: str, keyid: str):
    """
    Attempts to import a key from the keyserver.
    :param keyserver: The keyserver to import from.
    :param keyid: The Key ID to import.
Severity: Minor
Found in skier/pgpactions.py - About 4 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

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 synch_keys has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

    def synch_keys():
        print("Synching keys...")
        # We only synch once per bootup, because when a new key is added to any server, it's automatically distributed.
        # This ensures servers don't lag behind the rest of the pool.
        # Get the latest sync time.
    Severity: Minor
    Found in skier/pgpactions.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 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 search_through_keys_old has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def search_through_keys_old(search_str: str) -> list:
        """
        Searches through the keys via ID or UID name.
        :param search_str: The string to search for.
        Examples: '0xBF864998CDEEC2D390162087EB4084E3BF0192D9' for a fingerprint search
    Severity: Minor
    Found in skier/old/pgp.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 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 pksgetkey has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      def pksgetkey():
          if 'op' in request.args and request.args.get("op") == "get":
              # Lookup the key
              keyid = request.args.get("search")
              if keyid is None or not keyid.startswith("0x"):
      Severity: Minor
      Found in skier/pks.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(app):
          from skier import frontend
          from skier import pgpapi
          from skier import pks
          from cfg import API_VERSION
      Severity: Minor
      Found in init.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 add has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      def add():
          # Get the key from the form
          key = request.form.get("enterkey")
          if not key:
              return render_template("submit.html")
      Severity: Minor
      Found in skier/frontend.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 add_pgp_key has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      def add_pgp_key(armored: str) -> tuple:
          """
          Adds a key to the database.
          :param armored: The armored key data to add to the keyring.
          :return: True and the keyid if the import succeeded, or:
      Severity: Minor
      Found in skier/pgp.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 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 get_pgp_armor_key has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      def get_pgp_armor_key(keyid: str) -> str:
          """
          Lookup a PGP key.
          :param keyid: The key ID to lookup.
          :return: The armored version of the PGP key, or None if the key does not exist in the DB.
      Severity: Minor
      Found in skier/pgp.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 importkey has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      def importkey(keyserver, keyid):
          if not keyserver in cfg.config.sks_imports:
              if not keyserver in cfg.config.skier_imports:
                  return json.dumps({"code": 2, "err": "Invalid keyserver"}), 400, {"Content-Type": "application/json"}
          key = pgpactions.import_key(keyserver=keyserver, keyid=keyid)
      Severity: Minor
      Found in skier/pgpapi.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

      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 _broadcast_add has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      def _broadcast_add(key: db.Key):
          # Load the keyservers from the config file.
          keyservers = cfg.cfg.config.keyservers_synch
          for server in keyservers:
              assert isinstance(server, str)
      Severity: Minor
      Found in skier/pgpactions.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 import_from_dump has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def import_from_dump(file):
          """Import from an SKS dump."""
          # First, load a new GPG instance.
          gpg = GPG(gnupghome="/tmp/skier-import")
      
      
      Severity: Minor
      Found in manager.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 from_keyinfo has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def from_keyinfo(cls, obj):
              k = Key()
              for uid in obj.uid:
                  k.uid.append(uid)
      
      
      Severity: Minor
      Found in db.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 search has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def search():
          if 'keyid' in request.args:
              page = request.args.get("page", 1)
              try:
                  page = int(page)
      Severity: Minor
      Found in skier/frontend.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

      Severity
      Category
      Status
      Source
      Language