spicycms/spicy.core

View on GitHub

Showing 237 of 237 total issues

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

Function profiles_list has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

def profiles_list(request):
    nav = utils.NavigationFilter(request, accepting_filters=[
        ('group', None), ('search_text', ''), ('is_staff', None),
        ('last_login', None)])
    search_args, search_kwargs = [], {}
Severity: Minor
Found in src/spicy/core/profile/admin.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 restore has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    def restore(self, request):
        message = ''
        RestorePasswordForm = load_module(defaults.RESTORE_PASSWORD_FORM)
        if request.method == 'POST':
            form = RestorePasswordForm(request.POST)
Severity: Minor
Found in src/spicy/core/profile/services.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

@is_staff(required_perms=delete_perm(defaults.SIMPLE_PAGE_MODEL))
@render_to('delete.html', use_admin=True)
def delete(request, simplepage_id):
    page = get_object_or_404(SimplePage, pk=simplepage_id)
    if request.method == 'POST':
Severity: Major
Found in src/spicy/core/simplepages/admin.py and 1 other location - About 3 hrs to fix
src/spicy/core/profile/admin.py on lines 141..149

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

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

@render_to('spicy.core.profile/widgets/signin_form.html')
def login_widget(request):
    result = api.register['profile'].login(request)
    if result['status'] == 'ok':
        result['redirect_now'] = True
Severity: Major
Found in src/spicy/core/profile/views.py and 1 other location - About 2 hrs to fix
src/spicy/core/profile/views.py on lines 214..219

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

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

@render_to('spicy.core.profile/widgets/signup_form.html')
def registration_widget(request):
    result = api.register['profile'].register(request)
    if result['status'] == 'ok':
        result['redirect_now'] = True
Severity: Major
Found in src/spicy/core/profile/views.py and 1 other location - About 2 hrs to fix
src/spicy/core/profile/views.py on lines 206..211

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

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

File decorators.py has 286 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
import inspect
from django.conf import settings
from django.core.serializers.json import DjangoJSONEncoder
from django.http import HttpResponse
Severity: Minor
Found in src/spicy/core/siteskin/decorators.py - About 2 hrs to fix

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

    # -*- coding: utf-8 -*-
    import random
    import string
    import logging
    from uuid import uuid4
    Severity: Minor
    Found in src/spicy/core/profile/views.py - About 2 hrs to fix

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

          def handle(self, app='', *args, **options):
              self.app = app
              self.verbosity = int(options['verbosity'])
      
              if len(args) > 0:
      Severity: Minor
      Found in src/spicy/core/rmanager/management/commands/release.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 dashboard has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

      def dashboard(request):
          sites = Site.objects.all()
          dashboard_links = []
          dashboard_lists = []
          for admin_app in conf.admin_apps_register.values():
      Severity: Minor
      Found in src/spicy/core/admin/admin.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 memcache has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

      def memcache(request):
          class Stats:
              pass
          
          message = ''
      Severity: Minor
      Found in src/spicy/core/rmanager/admin.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

      File widgets.py has 267 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      from django.conf import settings
      
      from django.db.models import ObjectDoesNotExist
      
      from django import forms
      Severity: Minor
      Found in src/spicy/core/siteskin/widgets.py - About 2 hrs to fix

        Function get_template_sources has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_template_sources(self, template_name, template_dirs=None):
                if not template_dirs:
                    template_dirs = app_directories.app_template_dirs
                for template_dir in template_dirs:
                    app_dir = os.path.dirname(template_dir)
        Severity: Minor
        Found in src/spicy/core/siteskin/loaders.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 get_render_from_response has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

        def get_render_from_response(request, url, get_forwarding=False):
            path, query = url, ''
        
            if '?' in url:
                path, query = url.split('?', 1)
        Severity: Minor
        Found in src/spicy/core/siteskin/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

        AbstractProfile has 21 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class AbstractProfile(User, MediaConsumerAbstractModel):
            IS_ACTIVATED = 'Already activated'
            user_ptr = models.OneToOneField(User, parent_link=True)
            activation_key = models.CharField(_('activation key'), max_length=40)
            is_banned = models.BooleanField(
        Severity: Minor
        Found in src/spicy/core/profile/models.py - About 2 hrs to fix

          Function __new__ has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              def __new__(mcs, name, bases, attrs):
                  attrs['_meta_urls'] = urls = []
                  for attr, inst in attrs.iteritems():
                      render_interface = inst
                      if isinstance(inst, MethodDecoratorAdaptor):
          Severity: Minor
          Found in src/spicy/core/service/api.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 build_remote_env has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              def build_remote_env(self):
                  """
                  Build remote enviroment using common for all applications requirements.
          
                  Builder use native `virtualenv` utility.
          Severity: Minor
          Found in src/spicy/script.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

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

                  if not isinstance(output, dict):
                      if self.use_cache and isinstance(output, HttpResponse):
                          cache.set(
                              make_cache_key(request), output.content,
                              self.cache_timeout)
          Severity: Major
          Found in src/spicy/core/siteskin/decorators.py and 1 other location - About 2 hrs to fix
          src/spicy/core/siteskin/decorators.py on lines 254..259

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

          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 not isinstance(output, dict):
                      if self.use_cache and isinstance(output, HttpResponse):
                          cache.set(
                              make_cache_key(request), output.content,
                              self.cache_timeout)
          Severity: Major
          Found in src/spicy/core/siteskin/decorators.py and 1 other location - About 2 hrs to fix
          src/spicy/core/siteskin/decorators.py on lines 223..229

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

          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 sync_database(self):
                  with prefix('source {0}/bin/activate'.format(self.remote_env_path)):
                      for app in self.apps:
                          app.sync_database()
                          print_info('Sync database app: {0}'.format(app))
          Severity: Major
          Found in src/spicy/script.py and 1 other location - About 2 hrs to fix
          src/spicy/script.py on lines 1076..1080

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

          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