spaceone/httoop

View on GitHub

Showing 52 of 52 total issues

Function _rfc2231_and_continuation_params has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

    def _rfc2231_and_continuation_params(cls, params: Iterator[Any]) -> Iterator[Tuple[bytes, str]]:  # TODO: complexity
        count = set()
        continuations = dict()
        for key, value, quoted in params:
            if key in count:
Severity: Minor
Found in httoop/header/element.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

Body has 33 functions (exceeds 20 allowed). Consider refactoring.
Open

class Body(with_metaclass(HTTPSemantic, IFile)):
    u"""A HTTP message body.

    This class is capable of handling HTTP Transfer-Encoding
    and Content-Encoding as defined in RFC 2616.
Severity: Minor
Found in httoop/messages/body.py - About 4 hrs to fix

    File messaging.py has 326 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # -*- coding: utf-8 -*-
    # TODO: Via, Server, User-Agent can contain comments → parse them
    import re
    from typing import Any, List, Optional
    
    
    Severity: Minor
    Found in httoop/header/messaging.py - About 3 hrs to fix

      File element.py has 317 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      # -*- coding: utf-8 -*-
      """HTTP header elements.
      
      .. seealso:: :rfc:`2616#section-2.2`
      
      
      Severity: Minor
      Found in httoop/header/element.py - About 3 hrs to fix

        File uri.py has 312 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        # -*- coding: utf-8 -*-
        """Uniform Resource Identifier.
        
        .. seealso:: :rfc:`3986`
        """
        Severity: Minor
        Found in httoop/uri/uri.py - About 3 hrs to fix

          Function __call__ has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
          Open

              def __call__(self, application: Callable) -> Iterator[Any]:
                  def write(data):
                      if not self.headers_set:
                          raise RuntimeError("write() before start_response()")
                      elif not self.headers_sent:
          Severity: Minor
          Found in httoop/gateway/wsgi.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

          URI has 27 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class URI(with_metaclass(URIType)):
              u"""Uniform Resource Identifier."""
          
              __slots__ = ('scheme', 'username', 'password', 'host', '_port', 'path', 'query_string', 'fragment')
              slots = __slots__
          Severity: Minor
          Found in httoop/uri/uri.py - About 3 hrs to fix

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

                def parse(cls, elementstr: bytes) -> "Range":
                    bytesunit, __, byteranges = elementstr.partition(b'=')
                    byteranges = super(Range, cls).split(byteranges)
                    ranges = set()
                    for brange in byteranges:
            Severity: Minor
            Found in httoop/header/range.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

            StateMachine has 26 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class StateMachine(object):
                u"""A protocol state machine which supports pipelining and
                parses HTTP messages by turning them into appropriate objects.
                """
            
            
            Severity: Minor
            Found in httoop/parser.py - About 3 hrs to fix

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

              class HeaderElement(with_metaclass(HeaderType)):
                  u"""An element (with parameters) from an HTTP header's element list."""
              
                  priority = None
                  is_request_header = False
              Severity: Minor
              Found in httoop/header/element.py - About 2 hrs to fix

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

                    def get_links(self, relation: str, name: None=None) -> Iterator[Dict[str, Union[None, bool, str]]]:
                        links = self['_links'].get(relation)
                        if links is None:
                            return
                        if isinstance(links, dict):
                Severity: Minor
                Found in httoop/codecs/application/hal_json.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 _unquote_host has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                Open

                    def _unquote_host(self, host: bytes) -> str:
                        # IPv6 / IPvFuture
                        if host.startswith(b'[') and host.endswith(b']'):
                            host = host[1:-1]
                            try:
                Severity: Minor
                Found in httoop/uri/uri.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 has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                Open

                    def _parse(self) -> Iterator[Union[None, Response, Tuple[Request, Response]]]:
                        while self.buffer:
                            if self.message is None:
                                yield self.on_message_started()
                            state = self.state
                Severity: Minor
                Found in httoop/parser.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

                Status has 21 functions (exceeds 20 allowed). Consider refactoring.
                Open

                class Status(with_metaclass(HTTPSemantic)):
                    u"""A HTTP Status.
                
                    :rfc:`2616#section-6.2`
                    """
                Severity: Minor
                Found in httoop/status/status.py - About 2 hrs to fix

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

                      def prepare(self) -> None:
                          u"""prepares the response for being ready for transmitting."""
                          response = self.response
                  
                          status = int(response.status)
                  Severity: Minor
                  Found in httoop/semantic/response.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 __setattr__ has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def __setattr__(self, name: str, value: Any) -> None:
                          if name.startswith('_'):
                              return super(URI, self).__setattr__(name, value)
                  
                          if name == 'scheme' and value:
                  Severity: Minor
                  Found in httoop/uri/uri.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 parse has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def parse(self, uri: bytes) -> None:
                          r"""Parses a well formed absolute or relative URI.
                  
                          foo://example.com:8042/over/there?name=ferret#nose
                          \_/   \______________/\_________/ \_________/ \__/
                  Severity: Minor
                  Found in httoop/uri/uri.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 prepare has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def prepare(self) -> None:
                          if self.message.method.safe:
                              self.message.body = None
                              self.chunked = False
                  
                  
                  Severity: Minor
                  Found in httoop/semantic/request.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 parse has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def parse(cls, elementstr: bytes) -> "ContentRange":
                          value, start, end, complete_length = None, None, None, None
                          try:
                              value, content_range = elementstr.split(None, 1)
                              if value != b'bytes':
                  Severity: Minor
                  Found in httoop/header/range.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 set has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def set(self, content: Any) -> None:
                          if isinstance(content, Body):
                              self.mimetype = content.mimetype
                              self.data = content.data
                              self.chunked = content.chunked
                  Severity: Minor
                  Found in httoop/messages/body.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