wooyek/django-opt-out

View on GitHub

Showing 13 of 15 total issues

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

@task(check, sync, detox, bump)
def release(ctx):
    """Build new package version release and sync repo"""
    ctx.run("git checkout develop")
    ctx.run("git merge master --verbose")
Severity: Major
Found in tasks.py and 1 other location - About 1 hr to fix
tasks.py on lines 75..82

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

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

@task
def check(ctx):
    """Check project codebase cleanness"""
    ctx.run("flake8 src tests setup.py manage.py")
    ctx.run("isort --check-only --diff --recursive src tests setup.py")
Severity: Major
Found in tasks.py and 1 other location - About 1 hr to fix
tasks.py on lines 190..198

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

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 event_type == 'list_unsubscribe':
                email = event['raw_rcpt_to']
                send_signal(signals.list_unsubscribe, self.__class__, request=self.request, email=email, data=entry)
Severity: Minor
Found in src/django_opt_out/plugins/sparkpost/views.py and 1 other location - About 50 mins to fix
src/django_opt_out/plugins/sparkpost/views.py on lines 34..36

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

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

            elif event_type == 'link_unsubscribe':
                email = event['raw_rcpt_to']
                send_signal(signals.link_unsubscribe, self.__class__, request=self.request, email=email, data=entry)
Severity: Minor
Found in src/django_opt_out/plugins/sparkpost/views.py and 1 other location - About 50 mins to fix
src/django_opt_out/plugins/sparkpost/views.py on lines 31..33

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

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

def _send_robust(message):
    try:
        return message.send()
    except SparkPostAPIException as ex:  # pragma: no cover
        if ex.status == 1902 or not settings.FAIL_ON_EMAIL_SUPPRESSION:
Severity: Minor
Found in src/django_opt_out/plugins/sparkpost/__init__.py - About 45 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 send_email has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

def send_email(subject, to, ctx, template_html, template_txt=None, **kwargs):
Severity: Minor
Found in src/django_opt_out/plugins/sparkpost/__init__.py - About 45 mins to fix

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

    if __name__ == "__main__":
        os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tests.settings")
        from django.core.management import execute_from_command_line
    
        execute_from_command_line(sys.argv)
    Severity: Minor
    Found in manage.py and 1 other location - About 40 mins to fix
    example_project/manage.py on lines 12..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 34.

    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 __name__ == "__main__":
        os.environ.setdefault("DJANGO_SETTINGS_MODULE", "website.settings")
    
        from django.core.management import execute_from_command_line
    
    
    Severity: Minor
    Found in example_project/manage.py and 1 other location - About 40 mins to fix
    manage.py on lines 15..19

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

    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 save has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def save(self, force_insert=False, force_update=False, using=None, update_fields=None):
    Severity: Minor
    Found in src/django_opt_out/models.py - About 35 mins to fix

      Function suppress_email has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def suppress_email(sender, view, request, opt_out, **kwargs):
      Severity: Minor
      Found in src/django_opt_out/plugins/sparkpost/hooks.py - About 35 mins to fix

        Function create_opt_out has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def create_opt_out(sender, request, email, data, **kwargs):
        Severity: Minor
        Found in src/django_opt_out/plugins/sparkpost/hooks.py - About 35 mins to fix

          Function remove_suppression has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def remove_suppression(sender, view, request, opt_out, **kwargs):
          Severity: Minor
          Found in src/django_opt_out/plugins/sparkpost/hooks.py - About 35 mins to fix

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

                def handle(self, *args, **options):
                    if not options['force']:
                        try:
                            assert models.OptOutTag.objects.count() == 0
                            assert models.OptOutFeedback.objects.count() == 0
            Severity: Minor
            Found in src/django_opt_out/management/commands/opt_out_feedback_defaults.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