nephila/django-meta

View on GitHub

Showing 11 of 13 total issues

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

class MetadataMixin:
    """
    Django CBV mixin to prepare metadata for the view context
    """

Severity: Minor
Found in meta/views.py - About 3 hrs to fix

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

    def towncrier_check(c):  # NOQA
        """ Check towncrier files. """
        output = io.StringIO()
        c.run("git branch --contains HEAD", out_stream=output)
        skipped_branch_prefix = ["pull/", "develop", "master", "HEAD"]
    Severity: Minor
    Found in tasks.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 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

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

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

          def _get_meta_value(self, field, value):
              """
              Build the data according to a
      
              :param field: metadata field name
      Severity: Minor
      Found in meta/models.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 keywords has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def keywords(self, keywords):
              if keywords is None:
                  kws = settings.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 build_absolute_uri has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def build_absolute_uri(self, url):
              """
              Return the full url for the provided url argument
              """
              request = get_request()
      Severity: Minor
      Found in meta/models.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 as_meta has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def as_meta(self, request=None):
              """
              Method that generates the Meta object (from django-meta)
              """
              from meta.views import Meta
      Severity: Minor
      Found in meta/models.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 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 meta_namespaces has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def meta_namespaces(context):
          """
          Include OG namespaces. To be used in the <head> tag.
          """
          # do nothing if meta is not in context
      Severity: Minor
      Found in meta/templatetags/meta.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 "{}://{}/{}".format(self.get_protocol(), self.get_domain(), url)
      Severity: Major
      Found in meta/views.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                        return "{}://{}/{}".format(meta_protocol, s.domain, url)
        Severity: Major
        Found in meta/models.py - About 30 mins to fix
          Severity
          Category
          Status
          Source
          Language