jakubroztocil/httpie

View on GitHub
httpie/client.py

Summary

Maintainability
C
1 day
Test Coverage

Function collect_messages has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

def collect_messages(
    env: Environment,
    args: argparse.Namespace,
    request_body_read_callback: Callable[[bytes], None] = None,
) -> Iterable[RequestsMessage]:
Severity: Minor
Found in httpie/client.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 client.py has 305 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import argparse
import http.client
import json
import sys
from contextlib import contextmanager
Severity: Minor
Found in httpie/client.py - About 3 hrs to fix

    Function make_request_kwargs has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def make_request_kwargs(
        env: Environment,
        args: argparse.Namespace,
        base_headers: HTTPHeadersDict = None,
        request_body_read_callback=lambda chunk: chunk
    Severity: Minor
    Found in httpie/client.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 deeply nested control flow statements.
    Open

                        if args.all:
                            yield response
                        continue
    Severity: Major
    Found in httpie/client.py - About 45 mins to fix

      Function finalize_headers has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def finalize_headers(headers: HTTPHeadersDict) -> HTTPHeadersDict:
          final_headers = HTTPHeadersDict()
          for name, value in headers.items():
              if value is not None:
                  # “leading or trailing LWS MAY be removed without
      Severity: Minor
      Found in httpie/client.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 make_default_headers has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def make_default_headers(args: argparse.Namespace) -> HTTPHeadersDict:
          default_headers = HTTPHeadersDict({
              'User-Agent': DEFAULT_UA
          })
      
      
      Severity: Minor
      Found in httpie/client.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

      There are no issues that match your filters.

      Category
      Status