juntagrico/juntagrico-custom-sub

View on GitHub

Showing 14 of 14 total issues

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

juntagrico_custom_sub/entity/subscription_content_item.py on lines 0..24

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

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

Severity: Major
Found in juntagrico_custom_sub/entity/subscription_content_item.py and 1 other location - About 6 hrs to fix
juntagrico_custom_sub/entity/subscription_content_future_item.py on lines 0..25

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

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

    @property
    def display_future_content(self):
        result = []
        for prod in self.future_products.all().order_by('product__code'):
            try:
Severity: Major
Found in juntagrico_custom_sub/entity/subscription_content.py and 1 other location - About 5 hrs to fix
juntagrico_custom_sub/entity/subscription_content.py on lines 33..45

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

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

    @property
    def display_content(self):
        result = []
        for prod in self.products.all().order_by('product__code'):
            try:
Severity: Major
Found in juntagrico_custom_sub/entity/subscription_content.py and 1 other location - About 5 hrs to fix
juntagrico_custom_sub/entity/subscription_content.py on lines 47..59

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

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 58 lines of code (exceeds 30 allowed). Consider refactoring.
Open

    def handle(self, *args, **options):
        subproduct, _ = SubscriptionProduct.objects.get_or_create(name="Milch")
        subsize1_fields = {
            "name": "4 Liter",
            "long_name": "4 Liter Abo",
Severity: Major
Found in juntagrico_custom_sub/management/commands/cs_generate_testdata.py - About 2 hrs to fix

    Function handle has 32 lines of code (exceeds 30 allowed). Consider refactoring.
    Open

        def handle(self, *args, **options):
            subprod_fields = {"name": "Milch"}
            subproduct = jm.subtypes.SubscriptionProduct.objects.create(**subprod_fields)
            subsize1_fields = {
                "name": "4 Liter",
    Severity: Minor
    Found in juntagrico_custom_sub/management/commands/cs_generate_basic_data.py - About 1 hr to fix

      Avoid too many return statements within this function.
      Open

          return ""
      Severity: Major
      Found in juntagrico_custom_sub/util/sub_content.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return "cs-co-members"
        Severity: Major
        Found in juntagrico_custom_sub/views.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return "cs-shares"
          Severity: Major
          Found in juntagrico_custom_sub/views.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                return "cs-summary"
            Severity: Major
            Found in juntagrico_custom_sub/views.py - About 30 mins to fix

              Function handle has a Cognitive Complexity of 16 (exceeds 15 allowed). Consider refactoring.
              Open

                  def handle(self, *args, **options):
                      if not options['force'] and timezone.now().weekday() not in Config.depot_list_generation_days():
                          print(
                              'not the specified day for depot list generation, use --force to override')
                          return
              Severity: Minor
              Found in juntagrico_custom_sub/management/commands/cs_generate_depot_list.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

              Invalid escape sequence '\s'
              Open

                      WHITELIST_EMAILS.append(email.replace("@gmail.com", "(\+\S+)?@gmail.com"))
              Severity: Minor
              Found in testsettings.py by pep8

              Invalid escape sequences are deprecated in Python 3.6.

              Okay: regex = r'\.png$'
              W605: regex = '\.png$'

              Invalid escape sequence '+'
              Open

                      WHITELIST_EMAILS.append(email.replace("@gmail.com", "(\+\S+)?@gmail.com"))
              Severity: Minor
              Found in testsettings.py by pep8

              Invalid escape sequences are deprecated in Python 3.6.

              Okay: regex = r'\.png$'
              W605: regex = '\.png$'

              Refactor this function to reduce its Cognitive Complexity from 16 to the 15 allowed.
              Open

                  def handle(self, *args, **options):

              Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

              See

              Severity
              Category
              Status
              Source
              Language