SRJ9/django-driver27

View on GitHub

Showing 31 of 100 total issues

File models.py has 887 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from collections import namedtuple

Severity: Major
Found in driver27/models.py - About 2 days to fix

    Function edit_positions has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

        def edit_positions(self, request, pk, *args, **kwargs):
            race = Race.objects.get(pk=pk)
            if request.method == 'POST':
    
                to_delete = request.POST.get('to_delete', [])
    Severity: Minor
    Found in driver27/admin/admin.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

    File admin.py has 331 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    from django.conf.urls import url
    from django.shortcuts import render
    from django.utils.translation import ugettext as _
    from .common import CommonTabbedModelAdmin
    from django.shortcuts import redirect
    Severity: Minor
    Found in driver27/admin/admin.py - About 3 hrs to fix

      Season has 31 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Season(AbstractRankModel):
          """ Season model. The main model to restrict races, results and punctuation """
          year = models.IntegerField(verbose_name=_('year'))
          competition = models.ForeignKey(Competition, related_name='seasons', verbose_name=_('competition'))
          rounds = models.IntegerField(blank=True, null=True, default=None, verbose_name=_('rounds'))
      Severity: Minor
      Found in driver27/models.py - About 3 hrs to fix

        AbstractRankModel has 26 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class AbstractRankModel(models.Model):
            def get_stats_cls(self, contender):
                raise NotImplementedError('Not implemented method')
        
            def get_team_stats_cls(self, team):
        Severity: Minor
        Found in driver27/rank.py - About 3 hrs to fix

          File rank.py has 277 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          # encoding: utf-8
          from .punctuation import get_punctuation_config
          from django.db import models
          from django.core.cache import cache
          from six import text_type
          Severity: Minor
          Found in driver27/rank.py - About 2 hrs to fix

            Function wizard has 11 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def wizard(cls, seat=None, driver=None, team=None,
            Severity: Major
            Found in driver27/models.py - About 1 hr to fix

              Function run has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  def run(self, filters):
                      if self.unique_by_race:
                          return self.run_unique_by_race(filters)
                      count = 0
                      max_count = 0
              Severity: Minor
              Found in driver27/streak.py - About 1 hr 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 run_unique_by_race has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  def run_unique_by_race(self, filters):
                      results_by_race = self.get_results_by_race()
                      count = 0
                      max_count = 0
                      for race_results in results_by_race:
              Severity: Minor
              Found in driver27/streak.py - About 1 hr 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 _create_result has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  def _create_result(row):
                      invalid_keywords = []
                      result_fields = [f.column for f in Result._meta.get_fields() if hasattr(f, 'column')]
                      for x in row:
                          if x in ['qualifying', 'finish', 'points', 'race_id', 'seat_id']:
              Severity: Minor
              Found in driver27/management/commands/update_results.py - About 1 hr 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_points_list has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  def get_points_list(self, limit_races=None, punctuation_config=None, **kwargs):
                      points_to_rank = kwargs.pop('points_to_rank', None)
                      if punctuation_config is None:
                          points_list = self.get_saved_points(limit_races=limit_races, **kwargs)
                      else:
              Severity: Minor
              Found in driver27/models.py - About 1 hr 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 competition_request has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

              def competition_request(f):
                  def wrap(request, *args, **kwargs):
                      if request.is_ajax():
                          slug = request.GET.get('competition_slug', None)
                          year = request.GET.get('year', None)
              Severity: Minor
              Found in driver27/decorators.py - About 1 hr 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_points_list has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  def get_points_list(self, limit_races=None, punctuation_config=None, **kwargs):
                      points_to_rank = kwargs.pop('points_to_rank', None)
                      if punctuation_config is None:
                          points_list = self.get_saved_points(limit_races=limit_races)
                      else:
              Severity: Minor
              Found in driver27/models.py - About 1 hr 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 stats_view has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              def stats_view(request, context):
                  season_or_competition = context.get('season_or_competition')
              
                  record = request.GET.get('record', None)
                  record_config = get_safe_record_config(record)
              Severity: Minor
              Found in driver27/views_ajax.py - About 55 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 formfield_for_foreignkey has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def formfield_for_foreignkey(self, db_field, request=None, **kwargs):
                      if getattr(request, '_obj_', None):
                          obj = request._obj_
                          if hasattr(obj, 'competition'):
                              if db_field.name == 'team' and not isinstance(obj, Team):
              Severity: Minor
              Found in driver27/admin/filters.py - About 55 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 create_option has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def create_option(self, name, value, label, selected, index, subindex=None, attrs=None):
              Severity: Major
              Found in driver27/admin/common.py - About 50 mins to fix

                Function get_copy_item has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def get_copy_item(self, request, pk, item_cls, items_plural, *args, **kwargs):
                Severity: Minor
                Found in driver27/admin/admin.py - About 45 mins to fix

                  Function streak_rank has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def streak_rank(self, only_actives=False, max_streak=False, **filters):
                          """ Get driver rank based on record filter """
                          cache_str = self.get_name_cache_rank('streak', locals())
                          cache_rank = cache.get(cache_str)
                  
                  
                  Severity: Minor
                  Found in driver27/rank.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

                  Avoid deeply nested control flow statements.
                  Open

                                          for attr in ['qualifying', 'finish', 'retired', 'wildcard']:
                                              if getattr(result, attr) != position[attr]:
                                                  has_changed = True
                  
                  
                  Severity: Major
                  Found in driver27/admin/admin.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if not has_changed:
                                                continue
                    
                    
                    Severity: Major
                    Found in driver27/admin/admin.py - About 45 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language