simonkowallik/tmconfpy

View on GitHub

Showing 35 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

Cyclomatic complexity is too high in method _orchestrate. (29)
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 by radon

Cyclomatic Complexity

Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

Construct Effect on CC Reasoning
if +1 An if statement is a single decision.
elif +1 The elif statement adds another decision.
else +0 The else statement does not cause a new decision. The decision is at the if.
for +1 There is a decision at the start of the loop.
while +1 There is a decision at the while statement.
except +1 Each except branch adds a new conditional path of execution.
finally +0 The finally block is unconditionally executed.
with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
assert +1 The assert statement internally roughly equals a conditional statement.
Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

Source: http://radon.readthedocs.org/en/latest/intro.html

Cyclomatic complexity is too high in method _orchestrate. (29)
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

Cyclomatic Complexity

Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

Construct Effect on CC Reasoning
if +1 An if statement is a single decision.
elif +1 The elif statement adds another decision.
else +0 The else statement does not cause a new decision. The decision is at the if.
for +1 There is a decision at the start of the loop.
while +1 There is a decision at the while statement.
except +1 Each except branch adds a new conditional path of execution.
finally +0 The finally block is unconditionally executed.
with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
assert +1 The assert statement internally roughly equals a conditional statement.
Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

Source: http://radon.readthedocs.org/en/latest/intro.html

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

      Cyclomatic complexity is too high in method _group_objects. (21)
      Open

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

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Cyclomatic complexity is too high in method _group_objects. (21)
      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 by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Cyclomatic complexity is too high in method _parse_tmconf_content. (18)
      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 by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Cyclomatic complexity is too high in method _parse_tmconf_content. (18)
      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

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      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

          Cyclomatic complexity is too high in function cli. (6)
          Open

          def cli():
              """Handle CLI interaction."""
              args = _cli_arg_parser()
          
              tmconf_content = args.file_path.read() if args.file_path is not None else ""
          Severity: Minor
          Found in tmconfpy/cli.py by radon

          Cyclomatic Complexity

          Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

          Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

          Construct Effect on CC Reasoning
          if +1 An if statement is a single decision.
          elif +1 The elif statement adds another decision.
          else +0 The else statement does not cause a new decision. The decision is at the if.
          for +1 There is a decision at the start of the loop.
          while +1 There is a decision at the while statement.
          except +1 Each except branch adds a new conditional path of execution.
          finally +0 The finally block is unconditionally executed.
          with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
          assert +1 The assert statement internally roughly equals a conditional statement.
          Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
          Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

          Source: http://radon.readthedocs.org/en/latest/intro.html

          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])
                Severity
                Category
                Status
                Source
                Language