TabbycatDebate/tabbycat

View on GitHub

Showing 231 of 446 total issues

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

    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

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

    def DrawGenerator(teams_in_debate, draw_type, teams, results=None, rrseq=None, **kwargs):  # noqa: N802 (factory function)
    Severity: Minor
    Found in tabbycat/draw/generator/__init__.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if field == 'speaker':
                                  message += " (original score {})".format(ss.score)
                              self.stdout.write(message)
      Severity: Major
      Found in tabbycat/results/management/commands/compareballots.py - About 45 mins to fix

        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

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

                      def validate(self, data):
                          # Convert answer to correct type
                          model = AdjudicatorFeedbackQuestion.ANSWER_TYPE_CLASSES[data['question'].answer_type]
                          if type(data['answer']) != model.ANSWER_TYPE:
                              raise serializers.ValidationError({'answer': 'The answer must be of type %s' % model.ANSWER_TYPE.__name__})
              Severity: Minor
              Found in tabbycat/api/serializers.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 a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring.
              Open

                  def __init__(self, *args, **kwargs):
                      super().__init__(*args, **kwargs)
                      if not is_staff(kwargs.get('context')):
                          t = kwargs['context']['tournament']
                          with_permission = partial(has_permission, user=kwargs['context']['request'].user, tournament=t)
              Severity: Minor
              Found in tabbycat/api/serializers.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

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

                    def add_team_ballots(self, side_tag, result, adj, scoresheet, side):
                Severity: Minor
                Found in tabbycat/importer/archive.py - About 35 mins to fix

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

                      def __init__(self, ballotsub, tabroom, password=False, *args, **kwargs):
                  Severity: Minor
                  Found in tabbycat/results/forms.py - About 35 mins to fix

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

                        def set_criterion_score(self, adj, side, pos, criterion, score):
                    Severity: Minor
                    Found in tabbycat/results/result.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

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

                            def receive_debate_change(self, content, key, content_name, field_name, serializer):
                        Severity: Minor
                        Found in tabbycat/draw/consumers.py - About 35 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 add_debate_adjudicators_column has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                def add_debate_adjudicators_column(self, debates, title="Adjudicators",
                            Severity: Minor
                            Found in tabbycat/utils/tables.py - About 35 mins to fix

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

                              def liveness(self, team, teams_count, prelims, current_round):
                              Severity: Minor
                              Found in tabbycat/breakqual/utils.py - About 35 mins to fix

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

                                    def __init__(self, teams, bracket, room_rank, flags=[], team_flags={}):
                                Severity: Minor
                                Found in tabbycat/draw/generator/pairing.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
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language