nephila/django-meta

View on GitHub
meta/views.py

Summary

Maintainability
D
2 days
Test Coverage

File views.py has 380 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import json
import warnings
from datetime import date

from django.apps import apps
Severity: Minor
Found in meta/views.py - About 5 hrs to fix

    MetadataMixin has 32 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class MetadataMixin(FullUrlMixin):
        """
        Django CBV mixin to prepare metadata for the view context
        """
    
    
    Severity: Minor
    Found in meta/views.py - About 4 hrs to fix

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

          def schema(self):
              """
              Schema.org object description.
      
              Items in the schema are converted in a format suitable of json encoding at this stage:
      Severity: Minor
      Found in meta/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 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def __init__(self, **kwargs):
              self.request = kwargs.get("request", None)
              self.use_sites = kwargs.get("use_sites", get_setting("USE_SITES"))
              self.title = kwargs.get("title")
              self.og_title = kwargs.get("og_title")
      Severity: Minor
      Found in meta/views.py - About 1 hr to fix

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

            def keywords(self, keywords):
                if keywords is None:
                    kws = get_setting("DEFAULT_KEYWORDS")
                else:
                    if not hasattr(keywords, "__iter__"):
        Severity: Minor
        Found in meta/views.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 image_object has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def image_object(self, image):
                try:
                    if image:
                        image["url"] = self._normalize_media_url(image.get("url", None))
                        if self.get_protocol() == "https":
        Severity: Minor
        Found in meta/views.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 get_domain has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_domain(self):
                """
                Discover the current website domain
        
                :py:class:`django.contrib.sites.models.Site`
        Severity: Minor
        Found in meta/views.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

        Avoid too many return statements within this function.
        Open

                        return {itemkey: process_item(itemvalue) for itemkey, itemvalue in item.items()}
        Severity: Major
        Found in meta/views.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return item
          Severity: Major
          Found in meta/views.py - About 30 mins to fix

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

                def _get_full_url(self, url):
                    """
                    Build the full URL (protocol and domain included) for the URL given as argument
            
                    :param url: absolute (domain-less) URL
            Severity: Minor
            Found in meta/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

            There are no issues that match your filters.

            Category
            Status