nephila/djangocms-blog

View on GitHub

Showing 73 of 73 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        if self.categories.exists():
            posts = posts.filter(categories__in=list(self.categories.all()))
Severity: Minor
Found in djangocms_blog/models.py and 1 other location - About 35 mins to fix
djangocms_blog/models.py on lines 564..565

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 33.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    main_image_thumbnail = models.ForeignKey(
        thumbnail_model,
        verbose_name=_("main image thumbnail"),
        related_name="djangocms_blog_post_thumbnail",
        on_delete=models.SET_NULL,
Severity: Minor
Found in djangocms_blog/models.py and 1 other location - About 35 mins to fix
djangocms_blog/models.py on lines 228..232

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 33.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        if self.tags.exists():
            posts = posts.filter(tags__in=list(self.tags.all()))
Severity: Minor
Found in djangocms_blog/models.py and 1 other location - About 35 mins to fix
djangocms_blog/models.py on lines 566..567

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 33.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Avoid too many return statements within this function.
Open

        return nodes
Severity: Major
Found in djangocms_blog/cms_menus.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

                return nodes
    Severity: Major
    Found in djangocms_blog/cms_menus.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return nodes
      Severity: Major
      Found in djangocms_blog/cms_menus.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

            return language
        Severity: Major
        Found in djangocms_blog/models.py - About 30 mins to fix

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              def priority(self, obj):
                  if obj and obj.app_config:
                      return obj.app_config.sitemap_priority
                  return get_setting("SITEMAP_PRIORITY_DEFAULT")
          Severity: Minor
          Found in djangocms_blog/sitemaps/__init__.py and 1 other location - About 30 mins to fix
          djangocms_blog/sitemaps/__init__.py on lines 20..23

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 32.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              def changefreq(self, obj):
                  if obj and obj.app_config:
                      return obj.app_config.sitemap_changefreq
                  return get_setting("SITEMAP_CHANGEFREQ_DEFAULT")
          Severity: Minor
          Found in djangocms_blog/sitemaps/__init__.py and 1 other location - About 30 mins to fix
          djangocms_blog/sitemaps/__init__.py on lines 15..18

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 32.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

              def get_months(self, queryset=None, current_site=True):
                  """
                  Get months with aggregate count (how much posts is in the month).
                  Results are ordered by date.
                  """
          Severity: Minor
          Found in djangocms_blog/managers.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 items has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def items(self):
                  items = []
                  self.url_cache.clear()
                  for lang in get_language_list():
                      self.url_cache[lang] = {}
          Severity: Minor
          Found in djangocms_blog/sitemaps/__init__.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 populate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def populate(self):
                  if (
                      not self.is_current_app and not get_setting("ENABLE_THROUGH_TOOLBAR_MENU")
                  ) or not self.request.user.has_perm("djangocms_blog.add_post"):
                      return  # pragma: no cover
          Severity: Minor
          Found in djangocms_blog/cms_toolbars.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 _clean_html has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def _clean_html(self, content):
                  body = BytesIO(content)
                  document = etree.iterparse(body, html=True)
                  for _a, element in document:
                      if not (element.text and element.text.strip()) and len(element) == 0 and element.tag == "p":
          Severity: Minor
          Found in djangocms_blog/feeds.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