Showing 248 of 248 total issues

File ssm2.py has 477 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
Copyright (C) 2012 STFC
 
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Severity: Minor
Found in ssm/ssm2.py - About 7 hrs to fix

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

    def __init__(self, hosts_and_ports, qpath, cert, key, dest=None, listen=None,
    capath=None, check_crls=False, use_ssl=True, enc_cert=None,
    verify_enc_cert=True, pidfile=None, path_type='dirq',
    protocol=STOMP_MESSAGING, project=None, token=''):
    """Create an SSM2 object.
    Severity: Minor
    Found in ssm/ssm2.py - About 4 hrs to fix

    Cyclomatic complexity is too high in method __init__. (17)
    Open

    def __init__(self, hosts_and_ports, qpath, cert, key, dest=None, listen=None,
    capath=None, check_crls=False, use_ssl=True, enc_cert=None,
    verify_enc_cert=True, pidfile=None, path_type='dirq',
    protocol=STOMP_MESSAGING, project=None, token=''):
    """Create an SSM2 object.
    Severity: Minor
    Found in ssm/ssm2.py by radon

    Cyclomatic complexity is too high in function run_sender. (13)
    Open

    def run_sender(protocol, brokers, project, token, cp, log):
    """Run Ssm2 as a sender."""
    try:
    server_cert = None
    verify_server_cert = True
    Severity: Minor
    Found in ssm/agents.py by radon

    Ssm2 has 25 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Ssm2(stomp.ConnectionListener):
    """Minimal SSM implementation."""
     
    # Schema for the dirq message queue.
    QSCHEMA = {'body': 'string', 'signer': 'string', 'empaid': 'string?'}
    Severity: Minor
    Found in ssm/ssm2.py - About 2 hrs to fix

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

      if os.path.isfile(options.config):
      cp = configparser.ConfigParser({'use_ssl': 'true'})
      cp.read(options.config)
      else:
      print("Config file not found at", options.config)
      Severity: Major
      Found in bin/sender.py and 1 other location - About 2 hrs to fix
      bin/receiver.py on lines 66..71

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

      if os.path.isfile(options.config):
      cp = configparser.ConfigParser({'use_ssl': 'true'})
      cp.read(options.config)
      else:
      print("Config file not found at", options.config)
      Severity: Major
      Found in bin/receiver.py and 1 other location - About 2 hrs to fix
      bin/sender.py on lines 58..63

      Cyclomatic complexity is too high in function run_receiver. (12)
      Open

      def run_receiver(protocol, brokers, project, token, cp, log, dn_file):
      """Run Ssm2 as a receiver daemon."""
      if DaemonContext is None:
      log.error("Receiving SSMs must use python-daemon, but the "
      "python-daemon module wasn't found.")
      Severity: Minor
      Found in ssm/agents.py by radon

      File agents.py has 266 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      #!/usr/bin/env python
       
      # Copyright 2021 UK Research and Innovation
      #
      # Licensed under the Apache License, Version 2.0 (the "License");
      Severity: Minor
      Found in ssm/agents.py - About 2 hrs to fix

        Cyclomatic complexity is too high in method send_all. (9)
        Open

        def send_all(self):
        """
        Send all the messages in the outgoing queue.
         
        Either via STOMP or HTTPS (to an Argo Message Broker).
        Severity: Minor
        Found in ssm/ssm2.py by radon

        Cyclomatic complexity is too high in function verify. (9)
        Open

        def verify(signed_text, capath, check_crl):
        """Verify the signed message has been signed by the certificate.
         
        Verify the signed message has been signed by the certificate (attached to
        the supplied SMIME message) it claims to have, by one of the accepted CAs
        Severity: Minor
        Found in ssm/crypto.py by radon

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

        def send_all(self):
        """
        Send all the messages in the outgoing queue.
         
        Either via STOMP or HTTPS (to an Argo Message Broker).
        Severity: Minor
        Found in ssm/ssm2.py - About 2 hrs to fix

        Cyclomatic complexity is too high in method handle_connect. (8)
        Open

        def handle_connect(self):
        """Connect to broker.
         
        Assuming that the SSM has retrieved the details of the broker or
        brokers it wants to connect to, connect to one.
        Severity: Minor
        Found in ssm/ssm2.py by radon

        Cyclomatic complexity is too high in function get_ssm_args. (8)
        Open

        def get_ssm_args(protocol, cp, log):
        """Return brokers, project, and token from config based on protocol."""
        if protocol == Ssm2.STOMP_MESSAGING:
        # Set defaults for AMS variables that Ssm2 constructor requires below.
        project = None
        Severity: Minor
        Found in ssm/agents.py by radon

        Cyclomatic complexity is too high in method _handle_msg. (8)
        Open

        def _handle_msg(self, text):
        """Deal with the raw message contents appropriately.
         
        Namely:
        - decrypt if necessary
        Severity: Minor
        Found in ssm/ssm2.py by radon

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

        def __init__(self, hosts_and_ports, qpath, cert, key, dest=None, listen=None,
        Severity: Major
        Found in ssm/ssm2.py - About 2 hrs to fix

          Cyclomatic complexity is too high in method _get_messages. (7)
          Open

          def _get_messages(self, sort_by_mtime=False):
          """
          Get the messages stored in this MessageDirectory.
           
          if sort_by_mtime is set to True, the returned list is guaranteed to be
          Severity: Minor
          Found in ssm/message_directory.py by radon

          Cyclomatic complexity is too high in function verify_cert. (7)
          Open

          def verify_cert(certstring, capath, check_crls=True):
          """Verify that the certificate is signed by a CA with a cert in capath.
           
          Note that I've had to compare strings in the output of openssl to check
          for verification, which may make this brittle.
          Severity: Minor
          Found in ssm/crypto.py by radon

          Cyclomatic complexity is too high in method start_connection. (7)
          Open

          def start_connection(self):
          """Start existing connection and subscribe to the relevant topics.
           
          If the timeout is reached without receiving confirmation of
          connection, raise an exception.
          Severity: Minor
          Found in ssm/ssm2.py by radon

          Cyclomatic complexity is too high in function get_dns. (7)
          Open

          def get_dns(dn_file, log):
          """Retrieve a list of DNs from a file."""
          dns = []
          f = None
          try:
          Severity: Minor
          Found in ssm/agents.py by radon
          Severity
          Category
          Status
          Source
          Language