TabbycatDebate/tabbycat

View on GitHub

Showing 211 of 428 total issues

Avoid deeply nested control flow statements.
Open

                        for ballot in side.findall('ballot'):
                            for adj in [self.adjudicators.get(a) for a in ballot.get('adjudicators', "").split(" ")]:
                                if int(ballot.get('rank')) == 1:
                                    dr.add_winner(adj, side_code)
                dr.save()
Severity: Major
Found in tabbycat/importer/archive.py - About 45 mins to fix

    Function save_ballot has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring.
    Open

        def save_ballot(self):
            # 4. Save the sides
            if self.choosing_sides:
                self.result.set_sides(*self.cleaned_data['choose_sides'])
    
    
    Severity: Minor
    Found in tabbycat/results/forms.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

                            if i == 0:
                                cell['class'] = 'highlight-col'
                            row.append(cell)
    Severity: Major
    Found in tabbycat/draw/tables.py - About 45 mins to fix

      Function process_view has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring.
      Open

          def process_view(self, request, view_func, view_args, view_kwargs):
              if 'tournament_slug' in view_kwargs and request.path.split('/')[1] != 'api':
                  cached_key = "%s_%s" % (view_kwargs['tournament_slug'], 'object')
                  cached_tournament_object = cache.get(cached_key)
      
      
      Severity: Minor
      Found in tabbycat/utils/middleware.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 handle_tournament has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring.
      Open

          def handle_tournament(self, tournament, **options):
      
              writer = csv.writer(self.stdout)
      
              headings = [
      Severity: Minor
      Found in tabbycat/actionlog/management/commands/keytimes.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 post has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring.
      Open

          def post(self, request, *args, **kwargs):
              t = self.tournament
      
              try:
                  person = Person.objects.get(url_key=kwargs['url_key'])
      Severity: Minor
      Found in tabbycat/checkins/views.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

                              if cat.public:
                                  category_strs.append(escape(cat.name))
                              elif self.admin:
                                  category_strs.append("<em>" + escape(cat.name) + "</em>")
                          categories_data.append(", ".join(category_strs))
      Severity: Major
      Found in tabbycat/utils/tables.py - About 45 mins to fix

        Function duplicateAdjudicatorAllocations has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring.
        Open

            duplicateAdjudicatorAllocations: (state) => {
              let allocatedIDs = []
              let doubleAllocatedIDs = []
              for (let debateOrPanelID in state.debatesOrPanels) {
                const debate = state.debatesOrPanels[debateOrPanelID]
        Severity: Minor
        Found in tabbycat/templates/allocations/DragAndDropStore.js - 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 add_ballot_check_in_columns has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring.
        Open

            def add_ballot_check_in_columns(self, debates, key):
        
                status_header = {
                    'key': key,
                    'tooltip': _("Whether this debate's ballot has been checked in"),
        Severity: Minor
        Found in tabbycat/results/tables.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

                                if int(side.find('ballot').get('rank')) == 1:
                                    dr.add_winner(side_code)
                            else:
        Severity: Major
        Found in tabbycat/importer/archive.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                      if ('teams' in debate && debate.teams) {
                        for (const keyAndEntry of Object.entries(debate.teams)) {
                          let team = keyAndEntry[1]
                          // Team can be a number (ID) or null (e.g. when editing sides)
                          if (team !== null && typeof team === 'object' && 'break_categories' in team) {
          Severity: Major
          Found in tabbycat/templates/allocations/DragAndDropStore.js - About 45 mins to fix

            Function import_venues has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring.
            Open

                def import_venues(self, f, auto_create_categories=True):
                    interpreter = make_interpreter(tournament=self.tournament,
                        DELETE=['category', lambda x: x.startswith('available:')])
            
                    venues = self._import(f, vm.Venue, interpreter)
            Severity: Minor
            Found in tabbycat/importer/importers/boots.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 __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def __init__(self, teams, bracket, room_rank, flags=[], team_flags={}, advancing=[]):
            Severity: Minor
            Found in tabbycat/draw/generator/pairing.py - About 45 mins to fix

              Function add_speakers has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring.
              Open

                  def add_speakers(self, side_tag, debate, result, side):
                      for pos in self.t.positions:
                          speaker = result.get_speaker(side, pos)
              
                          if speaker is not None:
              Severity: Minor
              Found in tabbycat/importer/archive.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 _add_constraint_message has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def _add_constraint_message(debate, instance, venue, success_message, failure_message, message_args):
              Severity: Minor
              Found in tabbycat/venues/utils.py - About 45 mins to fix

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

                def add_feedback(debate, submitter_type, user, probability=1.0, discarded=False, confirmed=False):
                Severity: Minor
                Found in tabbycat/adjfeedback/dbutils.py - About 45 mins to fix

                  Consider simplifying this complex logical expression.
                  Open

                      if feedback_paths == 'no-adjs':
                          targets = []
                      elif feedback_paths == 'all-adjs' or debateadj.type == DebateAdjudicator.TYPE_CHAIR:
                          targets = [(adj, pos) for adj, pos in adjudicators.with_positions() if adj.id != debateadj.adjudicator_id]
                      elif feedback_paths == 'with-p-on-p' and debateadj.type == DebateAdjudicator.TYPE_PANEL:
                  Severity: Major
                  Found in tabbycat/adjfeedback/utils.py - About 40 mins to fix

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

                        def build(self, debates, teams, side_histories_before, side_histories_now, standings):
                    Severity: Minor
                    Found in tabbycat/draw/tables.py - About 35 mins to fix

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

                          def construct_info(self, venue, source, source_p, target, target_p):
                      Severity: Minor
                      Found in tabbycat/printing/views.py - About 35 mins to fix

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

                            def build(self, draw, teams, side_histories_before, side_histories_now, standings):
                        Severity: Minor
                        Found in tabbycat/draw/tables.py - About 35 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language