dprog-philippe-docourt/django-qr-code

View on GitHub

Showing 14 of 14 total issues

File utils.py has 734 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""Utility classes and functions for configuring and setting up the content and the look of a QR code."""
import datetime
import decimal
from collections import namedtuple
from dataclasses import asdict
Severity: Major
Found in qr_code/qrcode/utils.py - About 1 day to fix

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

        def make_qr_code_data(self) -> str:
            """\
            Creates a string encoding the event information.
    
            Only a subset of https://icalendar.org/iCalendar-RFC-5545/3-6-1-event-component.html is supported.
    Severity: Minor
    Found in qr_code/qrcode/utils.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 make_embedded_qr_code has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    def make_embedded_qr_code(data: Any, qr_code_options: QRCodeOptions, force_text: bool = True, use_data_uri_for_svg: bool = False) -> str:
        """
        Generates a <svg> or <img> tag representing the QR code for the given `data`.
        This tag can be embedded into an HTML document.
    
    
    Severity: Minor
    Found in qr_code/qrcode/maker.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 __init__ has 26 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(
    Severity: Major
    Found in qr_code/qrcode/utils.py - About 3 hrs to fix

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

      def make_qr_code_url(
          data: Any,
          qr_code_options: Optional[QRCodeOptions] = None,
          force_text: bool = True,
          cache_enabled: Optional[bool] = None,
      Severity: Minor
      Found in qr_code/qrcode/serve.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 make_qr_code_data has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          def make_qr_code_data(self) -> str:
              """
              Make a text for configuring a contact in a phone book. The MeCARD format is used, with an optional, non-standard (but often recognized) ORG field.
      
              See this archive of the format specifications: https://web.archive.org/web/20160304025131/https://www.nttdocomo.co.jp/english/service/developer/make/content/barcode/function/application/addressbook/index.html
      Severity: Minor
      Found in qr_code/qrcode/utils.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 __init__ has 13 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(
      Severity: Major
      Found in qr_code/qrcode/utils.py - About 1 hr to fix

        Function serve_qr_code_image has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        def serve_qr_code_image(request) -> HttpResponse:
            """Serve an image that represents the requested QR code.
        
            IMPORTANT NOTE: Each boolean option mentioned below (value True/False) must be passed as `<option name>=1` for `True`, respectively `<option name>=0` for `False`.
        
        
        Severity: Minor
        Found in qr_code/views.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 __init__ has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def __init__(
                self,
                size: Union[int, float, str, Decimal, None] = DEFAULT_MODULE_SIZE,
                border: int = 4,
                version: Union[int, str, None] = None,
        Severity: Minor
        Found in qr_code/qrcode/utils.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 _make_app_qr_code_from_obj_or_kwargs has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def _make_app_qr_code_from_obj_or_kwargs(
        Severity: Major
        Found in qr_code/templatetags/qr_code.py - About 50 mins to fix

          Function _size_as_number has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def _size_as_number(self) -> Union[int, float, str, Decimal]:
                  """Returns the size as integer value.
          
                  :rtype: int or float
                  """
          Severity: Minor
          Found in qr_code/qrcode/utils.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_qr_code_url has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def make_qr_code_url(
          Severity: Minor
          Found in qr_code/qrcode/serve.py - About 35 mins to fix

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

            def cache_qr_code():
                """
                Decorator that caches the requested page if a settings named 'QR_CODE_CACHE_ALIAS' exists and is not empty or None.
                """
            
            
            Severity: Minor
            Found in qr_code/views.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

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

            def _options_from_args(args: Mapping) -> QRCodeOptions:
                """Returns a QRCodeOptions instance from the provided arguments."""
                options = args.get("options")
                if options:
                    if not isinstance(options, QRCodeOptions):
            Severity: Minor
            Found in qr_code/qrcode/maker.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