avocado-framework/avocado

View on GitHub
avocado/utils/network/interfaces.py

Summary

Maintainability
D
2 days
Test Coverage

subprocess call with shell=True identified, security issue.
Open

        ping_process = subprocess.Popen(
            cmd,
            shell=True,
            stdout=subprocess.PIPE,
            stderr=subprocess.STDOUT,
Severity: Major
Found in avocado/utils/network/interfaces.py by bandit

Consider possible security implications associated with subprocess module.
Open

import subprocess

Function call with shell=True parameter identified, possible security issue.
Open

            interface_type = process.system_output(
                cmd, shell=True, ignore_status=True
Severity: Minor
Found in avocado/utils/network/interfaces.py by bandit

Function call with shell=True parameter identified, possible security issue.
Open

            interface_type = process.system_output(
                cmd, shell=True, ignore_status=True
Severity: Minor
Found in avocado/utils/network/interfaces.py by bandit

File interfaces.py has 707 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
Severity: Major
Found in avocado/utils/network/interfaces.py - About 1 day to fix

    Function save has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
    Open

        def save(self, ipaddr, netmask):
            """Save current interface IP Address to the system configuration file.
    
            If the ipaddr is valid (currently being used by the interface)
            this will try to save the current settings into /etc/. This
    Severity: Minor
    Found in avocado/utils/network/interfaces.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 validate_ipv4_netmask_format has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def validate_ipv4_netmask_format(self, netmask):
            """
            This function validates IPv4 Netmask address with following format set.
    
            1. A string in decimal-dot notation,consisting of four decimal integers
    Severity: Minor
    Found in avocado/utils/network/interfaces.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 config_filename has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def config_filename(self):
            current_distro = distro_detect()
            if current_distro.name in ["rhel", "fedora"]:
                if self.distro_is_rhel9:
                    path = "/etc/NetworkManager/system-connections"
    Severity: Minor
    Found in avocado/utils/network/interfaces.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 restore_slave_cfg_file has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def restore_slave_cfg_file(self):
            """
            Restore or delete slave config files.
            """
            if self.if_type != "Bond":
    Severity: Minor
    Found in avocado/utils/network/interfaces.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

    Avoid too many return statements within this function.
    Open

            return True
    Severity: Major
    Found in avocado/utils/network/interfaces.py - About 30 mins to fix

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

          def config_file_path(self):
              current_distro = distro_detect()
              if current_distro.name in ["rhel", "fedora"]:
                  if self.distro_is_rhel9:
                      return "/etc/NetworkManager/system-connections"
      Severity: Minor
      Found in avocado/utils/network/interfaces.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

      There are no issues that match your filters.

      Category
      Status