masschallenge/impact-api

View on GitHub

Showing 20 of 58 total issues

File profile_helper.py has 467 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# MIT License
# Copyright (c) 2017 MassChallenge, Inc.


from django.core.exceptions import (
Severity: Minor
Found in web/impact/impact/v1/helpers/profile_helper.py - About 7 hrs to fix

    File settings.py has 350 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # MIT License
    # Copyright (c) 2017 MassChallenge, Inc.
    
    import datetime
    import os
    Severity: Minor
    Found in web/impact/impact/settings.py - About 4 hrs to fix

      File office_hours_calendar_view.py has 314 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      from datetime import (
          datetime,
          timedelta,
      )
      
      
      Severity: Minor
      Found in web/impact/impact/v1/views/office_hours_calendar_view.py - About 3 hrs to fix

        File reserve_office_hour_view.py has 267 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        from pytz import timezone
        
        from django.contrib.auth import get_user_model
        from django.db.models import Q
        from django.template import loader
        Severity: Minor
        Found in web/impact/impact/v1/views/reserve_office_hour_view.py - About 2 hrs to fix

          Function has_object_permission has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

              def has_object_permission(self, request, view, obj):
                  model = view.kwargs.get('model', '').lower()
                  related_model = view.kwargs.get('related_model', '').lower()
                  model_name = model_name_case(model, related_model)
                  app_label = obj._meta.app_label
          Severity: Minor
          Found in web/impact/impact/permissions/dynamic_model_permissions.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_filters has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

          def _get_filters(request):
              if is_employee(request.user):
                  return []
          
              if request.GET['index'] == 'startup':
          Severity: Minor
          Found in web/impact/impact/views/algolia_api_key_view.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 _created_datetimes has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def _created_datetimes(self, instance):
                  if instance.created_at is not None:
                      self.earliest = instance.created_at
                  elif hasattr(instance, "created_datetime"):
                      if instance.created_datetime is not None:
          Severity: Minor
          Found in web/impact/impact/v1/events/organization_created_event.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 application_criteria_read_state has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def application_criteria_read_state(self, feedbacks):
                  if not self.application_criteria_read_state_cache:
                      ids_cache_value = {}
          
                      db_values = feedbacks.values(
          Severity: Minor
          Found in web/impact/impact/v1/classes/option_analysis.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 __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def __init__(self,
          Severity: Major
          Found in web/impact/impact/minimal_email_handler.py - About 50 mins to fix

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

                def get_calendar_data(self, counterpart_name):
                    if hasattr(self, "calendar_data"):
                        return self.calendar_data
                    name = counterpart_name
                    if self.mentor_recipient:
            Severity: Minor
            Found in web/impact/impact/v1/views/reserve_office_hour_view.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 not get_user(request).has_perm(permission_code):
                                        return False  # pragma: no cover
                                # some other value is in place,
                                # so we don't require permissions
                    return True
            Severity: Major
            Found in web/impact/impact/permissions/dynamic_model_permissions.py - About 45 mins to fix

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

              def confirmed_user_program_data(program_family_data):
                  program_family_to_date_created = {}
                  for program_family in program_family_data:
                      location = program_family["location"]
                      created_at = program_family["created_at"]
              Severity: Minor
              Found in web/impact/impact/v1/helpers/profile_helper.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 _extract_user has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  def _extract_user(self, request):
                      user_id = request.data.get("user_id", None)
                      if user_id is not None and user_id != request.user.id:
                          try:
                              self.target_user = User.objects.get(pk=user_id)
              Severity: Minor
              Found in web/impact/impact/v1/views/reserve_office_hour_view.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 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def __init__(self,
              Severity: Minor
              Found in web/impact/impact/v1/classes/option_analysis.py - About 35 mins to fix

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

                def map_data(klass, query, order, data_keys, output_keys):
                Severity: Minor
                Found in web/impact/impact/v1/views/utils.py - About 35 mins to fix

                  Avoid too many return statements within this function.
                  Open

                              return IS_CONFIRMED_MENTOR_FILTER
                  Severity: Major
                  Found in web/impact/impact/views/algolia_api_key_view.py - About 30 mins to fix

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

                        def analysis_tally(self, app_id, db_value, cache, **kwargs):
                    
                            if not self.reads_options:
                                options = self.subject.criterionoptionspec_set.values_list(
                                    'option', flat=True).distinct()
                    Severity: Minor
                    Found in web/impact/impact/v1/helpers/criterion_helper.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

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

                        def analysis_tally(self, app_id, db_value, cache, **kwargs):
                            apps = kwargs.get("apps")
                            if not self._app_ids_to_pf_name and apps.count() > 0:
                                self.calc_app_ids_to_targets(apps)
                            else:
                    Severity: Minor
                    Found in web/impact/impact/v1/helpers/matching_program_criterion_helper.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

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

                        def _extract_startup(self, request):
                            startup_id = request.data.get("startup_id", None)
                            if startup_id is None:
                                self.startup = None
                            else:
                    Severity: Minor
                    Found in web/impact/impact/v1/views/reserve_office_hour_view.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

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

                        def validate(self, attrs):
                            start_date_time = None
                            end_date_time = None
                            if self.instance is not None:
                                start_date_time = self.instance.start_date_time
                    Severity: Minor
                    Found in web/impact/impact/v1/serializers/office_hours_serializer.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