simonkowallik/tmconfpy

View on GitHub

Showing 25 of 35 total issues

Function _orchestrate has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
Open

    def _orchestrate(self, arr):
        """Orchestrate the parsing of tmconf objects."""
        key = self._get_object_name(arr[0])

        # remove opening and closing brackets which are at the first and last position
Severity: Minor
Found in tmconfpy/parser.py - About 1 day 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 _orchestrate has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
Open

    def _orchestrate(self, arr):
        """Orchestrate the parsing of tmconf objects."""
        key = self._get_object_name(arr[0])

        # remove opening and closing brackets which are at the first and last position

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 _group_objects has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
Open

    def _group_objects(self, arr) -> list:
        """Group tmconf objects into a list."""
        group = []
        i = 0
        while i < len(arr):
Severity: Minor
Found in tmconfpy/parser.py - About 6 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 _group_objects has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
Open

    def _group_objects(self, arr) -> list:
        """Group tmconf objects into a list."""
        group = []
        i = 0
        while i < len(arr):

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 parser.py has 349 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
"""tmconfpy - Serialize F5 BIG-IP tmconf files to dict/JSON."""

import json
import logging

    File parser.py has 349 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # -*- coding: utf-8 -*-
    """tmconfpy - Serialize F5 BIG-IP tmconf files to dict/JSON."""
    
    import json
    import logging
    Severity: Minor
    Found in tmconfpy/parser.py - About 4 hrs to fix

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

          def _parse_tmconf_content(self) -> Dict:
              """Parse the text of a tmconf file and return a dictionary of objects."""
              file_arr = self._tmconf_text.split("\n")
      
              # gtm topology
      Severity: Minor
      Found in tmconfpy/parser.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 _parse_tmconf_content has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          def _parse_tmconf_content(self) -> Dict:
              """Parse the text of a tmconf file and return a dictionary of objects."""
              file_arr = self._tmconf_text.split("\n")
      
              # gtm topology

      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

      Parser has 22 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Parser:
          """Parse tmconf data or file and serialize it to a python dict or JSON (str)."""
      
          def __init__(self, tmconf: str, is_filepath: bool = False, sort: bool = False):
              '''

        Parser has 22 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class Parser:
            """Parse tmconf data or file and serialize it to a python dict or JSON (str)."""
        
            def __init__(self, tmconf: str, is_filepath: bool = False, sort: bool = False):
                '''
        Severity: Minor
        Found in tmconfpy/parser.py - About 2 hrs to fix

          Consider simplifying this complex logical expression.
          Open

                          if arr[i].endswith("{") and len(arr) != 1:
                              c = 0
                              while arr[i + c] != "    }":
                                  c += 1
                                  if (i + c) >= len(arr):

            Consider simplifying this complex logical expression.
            Open

                            if arr[i].endswith("{") and len(arr) != 1:
                                c = 0
                                while arr[i + c] != "    }":
                                    c += 1
                                    if (i + c) >= len(arr):
            Severity: Major
            Found in tmconfpy/parser.py - About 1 hr to fix

              Avoid deeply nested control flow statements.
              Open

                                      if (i + c) >= len(arr):
                                          raise ValueError(
                                              f"Missing or mis-indented '}}' for line number {i+1}: '{arr[i]}'"
                                          )
                                  sub_obj_arr = self._remove_indent(arr[i : i + c + 1])

                Avoid deeply nested control flow statements.
                Open

                                        if line == "    {":
                                            line = line.replace("{", f"{arr_idx} {{")
                                            arr_idx += 1
                                        coerce_arr.append(line)

                  Avoid deeply nested control flow statements.
                  Open

                                          if line == "    {":
                                              line = line.replace("{", f"{arr_idx} {{")
                                              arr_idx += 1
                                          coerce_arr.append(line)
                  Severity: Major
                  Found in tmconfpy/parser.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            for char in updated_line:
                                                if char == '"' and previous_char != "\\":
                                                    quoted = not quoted
                                                if not quoted and char == "{" and previous_char != "\\":
                                                    subcount += 1
                    Severity: Major
                    Found in tmconfpy/parser.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if self._is_irule(line):
                                                  c -= 1
                                                  bracket_count = 0
                                              bracket_count += subcount
                      Severity: Major
                      Found in tmconfpy/parser.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                if (
                                                    key.startswith("gtm monitor external")
                                                    and "user-defined" in tmp
                                                ):
                                                    if "user-defined" not in obj:
                        Severity: Major
                        Found in tmconfpy/parser.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                  for char in updated_line:
                                                      if char == '"' and previous_char != "\\":
                                                          quoted = not quoted
                                                      if not quoted and char == "{" and previous_char != "\\":
                                                          subcount += 1

                            Avoid deeply nested control flow statements.
                            Open

                                                    if self._is_irule(line):
                                                        c -= 1
                                                        bracket_count = 0
                                                    bracket_count += subcount
                              Severity
                              Category
                              Status
                              Source
                              Language