spicycms/spicy.core

View on GitHub

Showing 237 of 237 total issues

Function login has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

    def login(self, request):
        status = 'error'
        message = ''
        redirect = None

Severity: Minor
Found in src/spicy/core/profile/services.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 collect has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

    def collect(self):
        """
        Perform the bulk of the work of collectstatic.

        Split off from handle_noargs() to facilitate testing.
Severity: Minor
Found in src/spicy/core/siteskin/management/commands/collectstatic.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

File admin.py has 345 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from datetime import datetime, timedelta
from django.conf import settings
from django.contrib import admin
from django.contrib.auth.models import Group
from django.core.urlresolvers import reverse
Severity: Minor
Found in src/spicy/core/profile/admin.py - About 4 hrs to fix

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

        if path.rstrip('?') == url:
            li_style = li_style + ' ' + 'activated'
            content = '<a href="%s" class="ui-corner-left">%s</a>' % (
                url, unicode(title))
        else:
    Severity: Major
    Found in src/spicy/core/siteskin/templatetags/navigator.py and 1 other location - About 4 hrs to fix
    src/spicy/core/admin/templatetags/spicy_admin.py on lines 93..99

    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 77.

    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

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

        if path.rstrip('?') == url:
            li_style = li_style + ' ' + 'activated'
            content = '<a href="%s" class="ui-corner-left">%s</a>' % (
                url, unicode(title))
        else:
    Severity: Major
    Found in src/spicy/core/admin/templatetags/spicy_admin.py and 1 other location - About 4 hrs to fix
    src/spicy/core/siteskin/templatetags/navigator.py on lines 101..107

    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 77.

    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 3 locations. Consider refactoring.
    Open

        def addFailure(self, test, err):
            super(SpicyTextTestResult, self).addFailure(test, err)
            if self.showAll:
                self.stream.writeln(red("FAIL"))
            elif self.dots:
    Severity: Major
    Found in src/spicy/spicyunittest.py and 2 other locations - About 4 hrs to fix
    src/spicy/spicyunittest.py on lines 50..56
    src/spicy/spicyunittest.py on lines 74..80

    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 75.

    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 3 locations. Consider refactoring.
    Open

        def addExpectedFailure(self, test, err):
            super(SpicyTextTestResult, self).addExpectedFailure(test, err)
            if self.showAll:
                self.stream.writeln(red("expected failure"))
            elif self.dots:
    Severity: Major
    Found in src/spicy/spicyunittest.py and 2 other locations - About 4 hrs to fix
    src/spicy/spicyunittest.py on lines 50..56
    src/spicy/spicyunittest.py on lines 58..64

    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 75.

    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 3 locations. Consider refactoring.
    Open

        def addError(self, test, err):
            super(SpicyTextTestResult, self).addError(test, err)
            if self.showAll:
                self.stream.writeln(red("ERROR"))
            elif self.dots:
    Severity: Major
    Found in src/spicy/spicyunittest.py and 2 other locations - About 4 hrs to fix
    src/spicy/spicyunittest.py on lines 58..64
    src/spicy/spicyunittest.py on lines 74..80

    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 75.

    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 addSuccess(self, test):
            super(SpicyTextTestResult, self).addSuccess(test)
            if self.showAll:
                self.stream.writeln(green("ok"))
            elif self.dots:
    Severity: Major
    Found in src/spicy/spicyunittest.py and 1 other location - About 3 hrs to fix
    src/spicy/spicyunittest.py on lines 82..88

    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 73.

    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 addUnexpectedSuccess(self, test):
            super(SpicyTextTestResult, self).addUnexpectedSuccess(test)
            if self.showAll:
                self.stream.writeln(red("unexpected success"))
            elif self.dots:
    Severity: Major
    Found in src/spicy/spicyunittest.py and 1 other location - About 3 hrs to fix
    src/spicy/spicyunittest.py on lines 42..48

    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 73.

    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 tag has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

    def tag():
        version = _get_version_check_point()
        version.version.increase()
        
        date = datetime.now().isoformat().split('T')[0]
    Severity: Minor
    Found in src/spicy/core/rmanager/management/commands/release.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

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

        @ajax_request('/$', is_public=True, use_siteskin=True, use_cache=False)
        def login(self, request):
            result = self.service.login(request)
    
            status = result['status']
    Severity: Major
    Found in src/spicy/core/profile/services.py and 1 other location - About 3 hrs to fix
    src/spicy/core/profile/services.py on lines 39..46

    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 70.

    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

        @ajax_request('/$', is_public=True, use_siteskin=True, use_cache=False)
        def register(self, request):
            result = self.service.register(request)
    
            status = result['status']
    Severity: Major
    Found in src/spicy/core/profile/services.py and 1 other location - About 3 hrs to fix
    src/spicy/core/profile/services.py on lines 30..37

    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 70.

    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 handle has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        def handle(self, *args, **options):
            verbosity = int(options.get('verbosity', 1))
            self.nomedia = options['nomedia']
            self.prefix = options['prefix']
            self.main_sitemap_file_name = '%s%ssitemap.xml' % (
    Severity: Minor
    Found in src/spicy/core/siteskin/management/commands/create_sitemap.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

    File middleware.py has 309 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # profile_middleware - a middleware that profiles views
    #
    # Inspired by udfalkso's http://www.djangosnippets.org/snippets/186/
    # and the Shwagroo Team's http://www.djangosnippets.org/snippets/605/
    #
    Severity: Minor
    Found in src/spicy/core/rmanager/middleware.py - About 3 hrs to fix

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

      class TrashFiltersForm(forms.Form):
          # TODO group by ContentTypes or Apps
          consumer_type = forms.ModelChoiceField(
              label=_('ContentType'), queryset=ContentType.objects.all(), required=False)
          consumer_type.widget.attrs['class'] = 'uniform'
      Severity: Major
      Found in src/spicy/core/trash/forms.py and 1 other location - About 3 hrs to fix
      src/spicy/core/profile/forms.py on lines 605..609

      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 66.

      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

      class ProfileFiltersForm(forms.Form):
          group = forms.ModelChoiceField(
              label=_('Group'), queryset=Group.objects.all(), required=False)
          group.widget.attrs['class'] = 'uniform'
          search_text = forms.CharField(max_length=100, required=False)
      Severity: Major
      Found in src/spicy/core/profile/forms.py and 1 other location - About 3 hrs to fix
      src/spicy/core/trash/forms.py on lines 11..17

      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 66.

      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 import_data has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          def import_data(self, src, fields):
              fields.insert(0, 'id')
              workbook = xlrd.open_workbook(file_contents=src.read())
              sheet = workbook.sheet_by_index(0)
              import_fields = {}
      Severity: Minor
      Found in src/spicy/core/profile/models.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 handle_create_app has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

      def handle_create_app(ns):
          spicy_pkg_root_dir = os.path.dirname(__file__)
          #spicy_app_tpl_root = os.path.join(spicy_pkg_root_dir)
          source_app_dir = os.path.join(spicy_pkg_root_dir, 'app')
      
      
      Severity: Minor
      Found in src/spicy/script.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

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

          def clean_username(self):
              username = self.cleaned_data['username']
              if Profile.objects.filter(username=username).exclude(
                      pk=self.instance.pk).exists():
                  raise forms.ValidationError(_('Username must be unique'))
      Severity: Major
      Found in src/spicy/core/profile/forms.py and 1 other location - About 3 hrs to fix
      src/spicy/core/profile/forms.py on lines 478..484

      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 65.

      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

      Severity
      Category
      Status
      Source
      Language