avocado-framework/avocado

View on GitHub
avocado/utils/partition.py

Summary

Maintainability
C
1 day
Test Coverage
F
26%

Use of insecure MD2, MD4, MD5, or SHA1 hash function.
Open

        device_hash = hashlib.sha1(self.device.encode("utf-8")).hexdigest()
Severity: Minor
Found in avocado/utils/partition.py by bandit

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

            process.system_output(f"yes | {mkfs_cmd}", shell=True)
Severity: Minor
Found in avocado/utils/partition.py by bandit

File partition.py has 251 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: Minor
Found in avocado/utils/partition.py - About 2 hrs to fix

    Function get_mountpoint has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_mountpoint(self, filename=None):
            """
            Find the mount point of this partition object.
    
            :param filename: where to look for the mounted partitions information
    Severity: Minor
    Found in avocado/utils/partition.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 mkfs has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def mkfs(self, fstype=None, args=""):
            """
            Format a partition to filesystem type
    
            :param fstype: the filesystem type, such as "ext3", "ext2". Defaults
    Severity: Minor
    Found in avocado/utils/partition.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 mount has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def mount(self, mountpoint=None, fstype=None, args="", mnt_check=True):
            """
            Mount this partition to a mount point
    
            :param mountpoint: If you have not provided a mountpoint to partition
    Severity: Minor
    Found in avocado/utils/partition.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 unmount has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def unmount(self, force=True):
            """
            Umount this partition.
    
            It's easier said than done to umount a partition.
    Severity: Minor
    Found in avocado/utils/partition.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

    Avoid deeply nested control flow statements.
    Open

                            if parts[1] == self.mountpoint:
                                return parts[1]  # The mountpoint where it's mounted
                    return None
    Severity: Major
    Found in avocado/utils/partition.py - About 45 mins to fix

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

          def __init__(
      Severity: Minor
      Found in avocado/utils/partition.py - About 35 mins to fix

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

            def _unmount_force(self, mountpoint):
                """
                Kill all other jobs accessing this partition and force unmount it.
        
                :return: None
        Severity: Minor
        Found in avocado/utils/partition.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