spicycms/spicy.core

View on GitHub

Showing 237 of 237 total issues

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

            if can_login and not is_blacklisted and form.is_valid():

                if not redirect or ' ' in redirect or (
                        '//' in redirect and re.match(r'[^\?]*//', redirect)):
                    redirect = settings.LOGIN_REDIRECT_URL
Severity: Major
Found in src/spicy/core/profile/services.py and 1 other location - About 2 days to fix
src/spicy/core/profile/services.py on lines 336..364

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

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 can_login and not is_blacklisted and login_form.is_valid():

                if not redirect or ' ' in redirect or (
                        '//' in redirect and re.match(r'[^\?]*//', redirect)):
                    redirect = settings.LOGIN_REDIRECT_URL
Severity: Major
Found in src/spicy/core/profile/services.py and 1 other location - About 2 days to fix
src/spicy/core/profile/services.py on lines 199..227

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

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 script.py has 980 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# coding: utf-8
"""SpicyTools command handler implementation

SPICY_BUILD_DIR = '.spicy-build'
SPICY_REQ_FILE = 'requirements.txt'
Severity: Major
Found in src/spicy/script.py - About 2 days to fix

    File forms.py has 514 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # -*- coding: utf-8 -*-
    import re
    import datetime as dt
    from copy import copy
    from captcha.conf.settings import get_challenge, CAPTCHA_FLITE_PATH
    Severity: Major
    Found in src/spicy/core/profile/forms.py - About 1 day to fix

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

      class DateTimePicker(forms.TextInput):
          def __init__(self, options={}, attrs={}):
              self.options = JSONEncoder().encode(options)
              self.attrs = attrs
      
      
      Severity: Major
      Found in src/spicy/core/siteskin/widgets.py and 1 other location - About 1 day to fix
      src/spicy/core/siteskin/widgets.py on lines 292..304

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

      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 DatePicker(forms.TextInput):
          def __init__(self, options={}, attrs={}):
              self.options = JSONEncoder().encode(options)
              self.attrs = attrs
      
      
      Severity: Major
      Found in src/spicy/core/siteskin/widgets.py and 1 other location - About 1 day to fix
      src/spicy/core/siteskin/widgets.py on lines 306..318

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

      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 models.py has 472 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import xlrd
      import xlwt
      import errno
      import random
      import smtplib
      Severity: Minor
      Found in src/spicy/core/profile/models.py - About 7 hrs to fix

        File services.py has 429 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        # -*- coding: utf-8 -*-
        import datetime
        import re
        from django.conf import settings
        from django.core.cache import cache
        Severity: Minor
        Found in src/spicy/core/profile/services.py - About 6 hrs to fix

          Function handle_normal has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
          Open

              def handle_normal(self, query, gen, content_type, object_model, verbosity):
                  thumb_width, thumb_height = DOC_THUMB_SIZE
                  for i, data in enumerate(query):
                      if verbosity > 1 and i % 1000 == 0:
                          print i, '...'
          Severity: Minor
          Found in src/spicy/core/siteskin/management/commands/create_sitemap.py - About 6 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 new_social_user has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
          Open

          def new_social_user(request):
              new_user = request.session.get('NEW_USER')
              if not new_user:
                  return HttpResponseRedirect(reverse('profile:public:signin'))
              elif not (new_user.is_active and new_user.is_authenticated()):
          Severity: Minor
          Found in src/spicy/core/profile/views.py - About 6 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 sanitize_token has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
          Open

              def sanitize_token(self, token):
                  if token["type"] in (
                          tokenTypes["StartTag"], tokenTypes["EndTag"],
                          tokenTypes["EmptyTag"]):
                      if token["name"] in self.allowed_elements:
          Severity: Minor
          Found in src/spicy/core/siteskin/html.py - About 5 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 find_templates has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
          Open

          def find_templates(
                  base_dir, name_tuples=True, abs_path=None, rel_path=False,
                  from_dict=None):
              if abs_path is None:
                  abs_path = not name_tuples
          Severity: Minor
          Found in src/spicy/utils/templates.py - About 5 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 has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
          Open

              def handle(self, *args, **options):
                  email = options.get('email', None)
                  interactive = options.get('interactive')
                  
                  if not interactive:
          Severity: Minor
          Found in src/spicy/core/profile/management/commands/createsuperuser.py - About 5 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 get_branch_by_revision_id(self, app_name, revision_id, app_path):
                  with lcd(os.path.join(os.path.abspath('.'), app_name)):
                      branch_name = local(
                          self.cmd_branch_by_revision % dict(revision_id=revision_id),
                          capture=True)
          Severity: Major
          Found in src/spicy/script.py and 1 other location - About 5 hrs to fix
          src/spicy/script.py on lines 475..485

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

          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 get_revision_by_branch(self, app_name, branch_name, app_path):
                  with lcd(os.path.join(os.path.abspath('.'), app_name)):
                      revision_id = local(self.cmd_revision_by_branch % dict(
                          branch_name=branch_name), capture=True)
                      if not revision_id:
          Severity: Major
          Found in src/spicy/script.py and 1 other location - About 5 hrs to fix
          src/spicy/script.py on lines 462..473

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

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

              def login_or_register(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

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

                      if not is_blacklisted and register_form.is_valid():
                          status = 'ok'
                          new_profile = register_form.save(
                              request=request, realhost=request.get_host(),
                              next_url=request.session.get(REDIRECT_FIELD_NAME, '/'))
          Severity: Major
          Found in src/spicy/core/profile/services.py and 1 other location - About 4 hrs to fix
          src/spicy/core/profile/services.py on lines 268..274

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

          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 not is_blacklisted and form.is_valid():
                          status = 'ok'
                          new_profile = form.save(
                              request=request, realhost=request.get_host(),
                              next_url=request.session.get(REDIRECT_FIELD_NAME, '/'))
          Severity: Major
          Found in src/spicy/core/profile/services.py and 1 other location - About 4 hrs to fix
          src/spicy/core/profile/services.py on lines 312..318

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

          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 api.py has 358 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import traceback
          from django.conf import settings
          from django.conf.urls.defaults import patterns, url
          from django.contrib.contenttypes.models import ContentType
          from django.utils.translation import ugettext_lazy as _
          Severity: Minor
          Found in src/spicy/core/service/api.py - About 4 hrs to fix

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

                def _generate_common_reqfile(self):
                    """Project requirements file generator using all applications
            
                    return: local agregated requirements.txt file from all applications.
                    """
            Severity: Minor
            Found in src/spicy/script.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

            Severity
            Category
            Status
            Source
            Language