princesslana/smalld.py

View on GitHub

Showing 10 of 10 total issues

Function prepare_gateway_mock has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

def prepare_gateway_mock(
    gateway_mock, smalld, side_effects=[()], close_reason=None, auto_close=True
):
    """Configures __iter__ for gateway.

Severity: Minor
Found in test/test_smalld.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 run has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def run(self):
        logger.info("Running (SmallD v%s)...", __version__)

        self.closed_event.clear()

Severity: Minor
Found in smalld/smalld.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 __iter__ has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def __iter__(self):
        try:
            self.ws.connect(self.url)
        except WebSocketError as e:
            logger.debug("Exception connecting to gateway.", exc_info=True)
Severity: Minor
Found in smalld/gateway.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 send_request has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def send_request(self, method, path, payload="", attachments=None, params=None):
        if attachments:
            files = [(f"file{idx}", a) for idx, a in enumerate(attachments)]
            args = {"data": {"payload_json": json.dumps(payload)}, "files": files}
        elif payload:
Severity: Minor
Found in smalld/smalld.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 on_gateway_payload has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def on_gateway_payload(self, func=None, *, op=None, t=None):
        def decorator(f):
            def filtered_payload_listener(data):
                if op is not None and data.op != op:
                    return
Severity: Minor
Found in smalld/smalld.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 make_ratelimit_headers has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

def make_ratelimit_headers(
Severity: Minor
Found in test/test_ratelimit.py - About 35 mins to fix

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

    def test_ratelimit_raises_on_limit_exhausted_response(
    Severity: Minor
    Found in test/test_ratelimit.py - About 35 mins to fix

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

      def prepare_gateway_mock(
      Severity: Minor
      Found in test/test_smalld.py - About 35 mins to fix

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

            def send_request(self, method, path, payload="", attachments=None, params=None):
        Severity: Minor
        Found in smalld/smalld.py - About 35 mins to fix

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

              def run_heartbeat_loop(self):
                  time.sleep(self.heartbeat_interval)
                  while not self.smalld.closed:
                      try:
                          self.send_heartbeat()
          Severity: Minor
          Found in smalld/standard_listeners.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