spicycms/spicy.core

View on GitHub

Showing 237 of 237 total issues

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

def print_success(message):
    sys.stdout.write(paint_text(prefix_message(message), 'green') + '\n')
Severity: Major
Found in src/spicy/utils/printing.py and 3 other locations - About 30 mins to fix
src/spicy/utils/printing.py on lines 54..55
src/spicy/utils/printing.py on lines 58..59
src/spicy/utils/printing.py on lines 65..66

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

def print_warning(message):
    sys.stdout.write(paint_text(prefix_message(message), 'yellow') + '\n')
Severity: Major
Found in src/spicy/utils/printing.py and 3 other locations - About 30 mins to fix
src/spicy/utils/printing.py on lines 58..59
src/spicy/utils/printing.py on lines 62..63
src/spicy/utils/printing.py on lines 65..66

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

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

        if self.use_cache:
            # TODO: test. Return APIResponse?
            cached_data = cache.get(make_cache_key(request))
            if cached_data:
                return HttpResponse(cached_data)
Severity: Minor
Found in src/spicy/core/siteskin/decorators.py and 2 other locations - About 30 mins to fix
src/spicy/core/siteskin/decorators.py on lines 215..218
src/spicy/core/siteskin/decorators.py on lines 246..249

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

def print_todo(message):
    sys.stdout.write(paint_text(prefix_message(message), 'magenta') + '\n')
Severity: Major
Found in src/spicy/utils/printing.py and 3 other locations - About 30 mins to fix
src/spicy/utils/printing.py on lines 54..55
src/spicy/utils/printing.py on lines 58..59
src/spicy/utils/printing.py on lines 62..63

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

def print_info(message):
    sys.stdout.write(paint_text(prefix_message(message), 'green') + '\n')
Severity: Major
Found in src/spicy/utils/printing.py and 3 other locations - About 30 mins to fix
src/spicy/utils/printing.py on lines 54..55
src/spicy/utils/printing.py on lines 62..63
src/spicy/utils/printing.py on lines 65..66

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

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

        if self.use_cache:
            cached_data = cache.get(make_cache_key(request))
            if cached_data:
                return HttpResponse(cached_data)
Severity: Minor
Found in src/spicy/core/siteskin/decorators.py and 2 other locations - About 30 mins to fix
src/spicy/core/siteskin/decorators.py on lines 215..218
src/spicy/core/siteskin/decorators.py on lines 290..294

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

    def get_template_sources(self, template_name, template_dirs=None):
        try:  # that is for easier debugging when db is down
            theme = utils.get_siteskin_settings().theme
        except Exception, e:
            print e
Severity: Minor
Found in src/spicy/core/siteskin/loaders.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 colorize_diff has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def colorize_diff(value):
    """
    Colorize diff like hgweb does ;-)
    """
    return mark_safe(
Severity: Minor
Found in src/spicy/core/siteskin/templatetags/sk.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 delete_expired_users has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def delete_expired_users(self):
        raise NotImplementedError
        # # XXX: antisvin 2011-02-24: This would delete shop orders from
        # express registration. Fix foreign keys to Profile or use trash app
        # before deleting expirted users.
Severity: Minor
Found in src/spicy/core/profile/models.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_password2 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def clean_password2(self):
        if self.cleaned_data['is_registration']:
            password1 = self.cleaned_data.get('password1', '').strip()
            password2 = self.cleaned_data.get('password2', '').strip()
            if password1 and password2:
Severity: Minor
Found in src/spicy/core/profile/forms.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 clear_permission_cache has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def clear_permission_cache(salt, keys=None, superuser=False, user_obj=None):
    """
    Clear permissions cache. Either keys, superuser or user_obj should be
    passed.

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

    def __init__(self, name, checked, values):
        self.result = []
        for v in values:
            description = None
            if isinstance(v, (list, tuple)):
Severity: Minor
Found in src/spicy/core/rmanager/middleware.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 signin has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def signin(request):
    result = api.register['profile'].login(request)
    if result['status'] == 'ok':
        return HttpResponseRedirect(
            result.get('redirect') or user_redirect_uri)
Severity: Minor
Found in src/spicy/core/profile/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

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

    def clean_email(self):
        email = self.cleaned_data['email']
        if email:
            try:
                Profile.objects.get(email__iexact=email)
Severity: Minor
Found in src/spicy/core/profile/forms.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 __init__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def __init__(self, *args, **kwargs):
        # Path request=None to auth form or it eats our data!
        super(SigninForm, self).__init__(None, *args, **kwargs)

        # We inherit username and password from AuthenticationForm,
Severity: Minor
Found in src/spicy/core/profile/forms.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 save has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def save(self, *args, **kwargs):
        is_old = bool(self.id or False)
        if is_old:
            old = self.__class__.objects.get(pk=self.pk)

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

    def clean_email(self):
        email = self.cleaned_data['email']
        if email:
            try:
                if Profile.objects.filter(email__iexact=email).count():
Severity: Minor
Found in src/spicy/core/profile/forms.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