jakubroztocil/httpie

View on GitHub

Showing 73 of 73 total issues

File definition.py has 770 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from __future__ import annotations

import os
import textwrap
from argparse import FileType
Severity: Major
Found in httpie/cli/definition.py - About 1 day to fix

    File argparser.py has 471 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import argparse
    import errno
    import os
    import re
    import sys
    Severity: Minor
    Found in httpie/cli/argparser.py - About 7 hrs to fix

      Function _process_auth has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
      Open

          def _process_auth(self):
              # TODO: refactor & simplify this method.
              self.args.auth_plugin = None
              default_auth_plugin = plugin_manager.get_auth_plugins()[0]
              auth_type_set = self.args.auth_type is not None
      Severity: Minor
      Found in httpie/cli/argparser.py - About 5 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 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

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

      def interpret(context: Any, key: str, value: Any) -> Any:
          cursor = context
          paths = list(parse(key))
          paths.append(Path(PathAction.SET, value))
      
      
      Severity: Minor
      Found in httpie/cli/nested_json/interpret.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

      Function parse has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

      def parse(source: str) -> Iterator[Path]:
          """
          start: root_path path*
          root_path: (literal | index_path | append_path)
          literal: TEXT | NUMBER
      Severity: Minor
      Found in httpie/cli/nested_json/parse.py - About 3 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 colors.py has 320 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import json
      from typing import Optional, Type, Tuple
      
      import pygments.formatters
      import pygments.lexer
      Severity: Minor
      Found in httpie/output/formatters/colors.py - About 3 hrs to fix

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

              def _compute_new_headers(self, request_headers: HTTPHeadersDict) -> HTTPHeadersDict:
                  new_headers = HTTPHeadersDict()
                  for name, value in request_headers.copy().items():
                      if value is None:
                          continue  # Ignore explicitly unset headers
          Severity: Minor
          Found in httpie/sessions.py - About 3 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 tokenize has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
          Open

          def tokenize(source: str) -> Iterator[Token]:
              cursor = 0
              backslashes = 0
              buffer = []
          
          
          Severity: Minor
          Found in httpie/cli/nested_json/parse.py - About 3 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 to_help_message has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

          def to_help_message(
              spec: ParserSpec,
          ) -> Iterable[RenderableType]:
              yield Padding(
                  options_highlighter(spec.description),
          Severity: Minor
          Found in httpie/output/ui/rich_help.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

          File downloads.py has 284 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          """
          Download mode implementation.
          
          """
          import mimetypes
          Severity: Minor
          Found in httpie/downloads.py - About 2 hrs to fix

            Function parse_format_options has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
            Open

            def parse_format_options(s: str, defaults: Optional[dict]) -> dict:
                """
                Parse `s` and update `defaults` with the parsed values.
            
                >>> parse_format_options(
            Severity: Minor
            Found in httpie/cli/argtypes.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 get_lexer has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
            Open

            def get_lexer(
                mime: str,
                explicit_json=False,
                body=''
            ) -> Optional[Type[Lexer]]:
            Severity: Minor
            Found in httpie/output/formatters/colors.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 _parse_items has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                def _parse_items(self):
                    """
                    Parse `args.request_items` into `args.headers`, `args.data`,
                    `args.params`, and `args.files`.
            
            
            Severity: Minor
            Found in httpie/cli/argparser.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 merge_all_the_people has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

            def merge_all_the_people(release: str, contributors: People, committers: FullNames, reporters: GitHubLogins) -> None:
                """
                >>> contributors = {'Alice': new_person(github='alice', twitter='alice')}
                >>> merge_all_the_people('2.6.0', contributors, {}, {})
                >>> contributors
            Severity: Minor
            Found in docs/contributors/fetch.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

            File core.py has 252 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import argparse
            import os
            import platform
            import sys
            import socket
            Severity: Minor
            Found in httpie/core.py - About 2 hrs to fix

              Function __iter__ has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                  def __iter__(self) -> Iterable[bytes]:
                      """Return an iterator over `self.msg`."""
                      if self.output_options.headers:
                          yield self.get_headers()
                          yield b'\r\n\r\n'
              Severity: Minor
              Found in httpie/output/streams.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_stream_type_and_kwargs has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

              def get_stream_type_and_kwargs(
                  env: Environment,
                  processing_options: ProcessingOptions,
                  message_type: Type[HTTPMessage],
                  headers: HTTPHeadersDict,
              Severity: Minor
              Found in httpie/output/writer.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 _setup_standard_streams has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                  def _setup_standard_streams(self):
                      """
                      Modify `env.stdout` and `env.stdout_isatty` based on args, if needed.
              
                      """
              Severity: Minor
              Found in httpie/cli/argparser.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

              Severity
              Category
              Status
              Source
              Language