Fiery-brain/acesta

View on GitHub

Showing 22 of 22 total issues

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

def rating_view(request, area=settings.AREA_REGIONS) -> HttpResponse:
    """
    Ratings view
    :param request: django.http.HttpRequest
    :param area: str
Severity: Minor
Found in acesta/stats/views.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

Function region_view has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

def region_view(request) -> HttpResponse:
    """
    Region Page representation
    :param request: django.http.HttpRequest
    :return: django.http.HttpResponse
Severity: Minor
Found in acesta/stats/views.py - About 3 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

Function visitor_request has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

def visitor_request(request: HttpRequest) -> HttpResponse or FileResponse:
    """
    Saves request
    :param request: django.http.HttpRequest
    :return: django.http.HttpResponse
Severity: Minor
Found in acesta/user/views/communications.py - About 3 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

Function update_map has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

def update_map(tourism_type: str, home_area: str, *args, **kwargs) -> go.Figure:
    """
    Updates the map
    :param tourism_type: str
    :param home_area: str
Severity: Minor
Found in acesta/stats/dash/interest/map.py - About 3 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

Function get_interest has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

def get_interest(
    region: str, home_area: str, interesant_area: str, tourism_type: str, id: int = 0
) -> models.QuerySet:
    """
    Returns interest according to areas
Severity: Minor
Found in acesta/stats/dash/helpers/interest.py - About 2 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 views.py has 269 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import numpy as np
from django.conf import settings
from django.db import models
from django.http import HttpRequest
from django.http import HttpResponse
Severity: Minor
Found in acesta/stats/views.py - About 2 hrs to fix

    Function fill_geo_data has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    def fill_geo_data(sender, instance, *args, **kwargs) -> None:
        try:
            from acesta_updater.management.commands.helpers.sight_helper import (
                get_geo_data,
                get_lon_lat,
    Severity: Minor
    Found in acesta/geo/utils.py - About 2 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

    Function update_period_info has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def update_period_info(self, period, order_regions, tourism_types):
            period_info = self.period_info
    
            for region in order_regions.all():
                region_period_data = {region.code: {}}
    Severity: Minor
    Found in acesta/user/models/user.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_sizes has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_sizes(values: list, min_size: int = 10, max_size: int = 30) -> list:
        """
        Returns dots sizes
        :param values: list
        :param min_size: int
    Severity: Minor
    Found in acesta/stats/dash/helpers/interest.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 post_login has 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def post_login(
    Severity: Major
    Found in acesta/account/adapter.py - About 1 hr to fix

      Function update_interest has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def update_interest(
      Severity: Major
      Found in acesta/stats/dash/interest/interest.py - About 50 mins to fix

        Function update_audience_key has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def update_audience_key(
        Severity: Major
        Found in acesta/stats/dash/interest/interest.py - About 50 mins to fix

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

              def extract_common_fields(self, data):
                  common_fields = {}
                  user_data = data.get("Data")
                  if user_data:
                      common_fields.update(
          Severity: Minor
          Found in acesta/socialaccount/providers/leaderid/provider.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 get_interest has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def get_interest(
          Severity: Minor
          Found in acesta/stats/dash/helpers/interest.py - About 35 mins to fix

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

            def update_title(
            Severity: Minor
            Found in acesta/stats/dash/interest/ui.py - About 35 mins to fix

              Function update_title has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              def update_title(
                  home_area: str, map_data: dict, current_state: str, *args, **kwargs
              ) -> str:
                  """
                  Updates the app title
              Severity: Minor
              Found in acesta/stats/dash/interest/ui.py - About 35 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 clean_up_old_periods has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def clean_up_old_periods(self):
                      old_periods = []
                      for region, period in self.period_info.items():
                          end_date = get_date(period.get("end"))
                          if end_date < now():
              Severity: Minor
              Found in acesta/user/models/user.py - About 35 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 updateSplitter has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              function updateSplitter() {
                if (typeof splitter !== "undefined") {
                  if (window.innerWidth >= 992) {
                    splitter.refresh();
                  } else {
              Severity: Minor
              Found in acesta/static/js/dashboard.interest.js - About 35 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 get_ppt_monitor has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              def get_ppt_monitor(queries_data, kwargs) -> dict:
                  """
                  Returns Popularity monitor
                  :param queries_data: list
                  :param kwargs: dict
              Severity: Minor
              Found in acesta/stats/admin/monitor/popularity.py - About 35 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 get_prop has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              def get_prop(obj, key):
                  if isinstance(obj, dict):
                      return obj.get(key) or obj.get(key.lower())
                  elif obj and isinstance(obj, object):
                      return getattr(obj, key) or getattr(obj, key.lower())
              Severity: Minor
              Found in acesta/user/templatetags/user.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