koriaf/django-calories-log

View on GitHub

Showing 8 of 22 total issues

Function storeHistoricalData has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        storeHistoricalData(productsToday) {
            // Calculates today total values and saves to indexedDB
            // so we can draw some graphs about how we eat
            // TODO: move process logic level up and here just store it

Severity: Minor
Found in src/frontend/backlog.app/db-storage.js - About 1 hr to fix

    Function doFoodSearch has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            doFoodSearch: function doFoodSearch() {
                var q = document.querySelector("#id_food_search_input").value.trim();
                // fetch list of goods by AJAX from server side using our API
                let url = "/api/v1/products/" + Views.serialize({title: q});
                let errorBlock = document.querySelector("#id_found_food_table_message");
    Severity: Minor
    Found in src/frontend/backlog.app/backlog.app.js - About 1 hr to fix

      Function handle has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def handle(self, *args, **options):
              CATEGORIES = self.parse_categories()
              PRODUCTS = self.parse_foods(CATEGORIES)
              NUTRIENTS = self.parse_nutrients()
      
      
      Severity: Minor
      Found in src/nutricalc/food/management/commands/parse_usa_db.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_queryset has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_queryset(self):
              """Custom filtering procedure.
              Accepts 'title' GET argument.
              Do search from food database and return partial matches
              """
      Severity: Minor
      Found in src/nutricalc/food_api_v1/views.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 env has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def env(name, default):
          """Get variable name and default value, return environment value or default one"""
          value = os.environ.get(name, default)
          if isinstance(default, bool):
              # it's boolean value, must be converted from string
      Severity: Minor
      Found in src/nutricalc/settings/base.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 parse_nutrients has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def parse_nutrients(self):
              raw_defs = open(os.path.join(
                  settings.BASE_DIR,
                  '../var/usa_food_gov',
                  'NUTR_DEF.txt'
      Severity: Minor
      Found in src/nutricalc/food/management/commands/parse_usa_db.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 parse_categories has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def parse_categories(self):
              raw_defs = open(os.path.join(
                  settings.BASE_DIR,
                  '../var/usa_food_gov',
                  'FD_GROUP.txt'
      Severity: Minor
      Found in src/nutricalc/food/management/commands/parse_usa_db.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 parse_foods has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def parse_foods(self, cats):
              raw_defs = open(os.path.join(
                  settings.BASE_DIR,
                  '../var/usa_food_gov',
                  'FOOD_DES.txt'
      Severity: Minor
      Found in src/nutricalc/food/management/commands/parse_usa_db.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