avocado-framework/avocado

View on GitHub
avocado/utils/nvme.py

Summary

Maintainability
C
1 day
Test Coverage

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

    if not process.run(cmd, shell=True, ignore_status=True):
Severity: Minor
Found in avocado/utils/nvme.py by bandit

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

    out = process.run(cmd, ignore_status=True, sudo=True, shell=True).stdout_text
Severity: Minor
Found in avocado/utils/nvme.py by bandit

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

    if process.system(cmd, shell=True, ignore_status=True):
Severity: Minor
Found in avocado/utils/nvme.py by bandit

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

    if not process.run(cmd, shell=True, ignore_status=True):
Severity: Minor
Found in avocado/utils/nvme.py by bandit

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

    output = process.run(cmd, shell=True, sudo=True, ignore_status=True).stdout_text
Severity: Minor
Found in avocado/utils/nvme.py by bandit

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

    output = process.run(cmd, shell=True, sudo=True, ignore_status=True).stdout_text
Severity: Minor
Found in avocado/utils/nvme.py by bandit

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

    data = process.run(cmd, ignore_status=True, sudo=True, shell=True).stdout_text
Severity: Minor
Found in avocado/utils/nvme.py by bandit

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

    out = process.run(cmd, ignore_status=True, sudo=True, shell=True).stdout_text
Severity: Minor
Found in avocado/utils/nvme.py by bandit

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

        out = process.run(cmd, shell=True, ignore_status=True)
Severity: Minor
Found in avocado/utils/nvme.py by bandit

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

        out = process.run(cmd, shell=True, ignore_status=True).stdout_text
Severity: Minor
Found in avocado/utils/nvme.py by bandit

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

        process.run(cmd, shell=True, ignore_status=True)
Severity: Minor
Found in avocado/utils/nvme.py by bandit

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

    data = process.run(cmd, ignore_status=True, sudo=True, shell=True).stdout_text
Severity: Minor
Found in avocado/utils/nvme.py by bandit

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

    out = process.run(cmd, ignore_status=True, sudo=True, shell=True).stdout_text
Severity: Minor
Found in avocado/utils/nvme.py by bandit

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

    if process.system(cmd, shell=True, ignore_status=True):
Severity: Minor
Found in avocado/utils/nvme.py by bandit

File nvme.py has 295 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/nvme.py - About 3 hrs to fix

    Function get_ns_status has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_ns_status(controller_name, ns_id):
        """
        Returns the status of namespaces on the specified controller
    
        :param controller_name: name of the controller like nvme0
    Severity: Minor
    Found in avocado/utils/nvme.py - About 2 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 get_nslist_with_pci has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_nslist_with_pci(pci_address):
        """
        Fetches and returns list of namespaces for specified pci_address
    
        :param pci_address: pci_address of any nvme adapter
    Severity: Minor
    Found in avocado/utils/nvme.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

    Avoid deeply nested control flow statements.
    Open

                        if nsid == ns_id and paths["Name"] == controller_name:
                            stat.extend([paths["State"], paths["ANAState"]])
        return stat
    Severity: Major
    Found in avocado/utils/nvme.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if paths["Address"] == pci_address:
                              ns_list.append(namespace["NSID"])
          return ns_list
      Severity: Major
      Found in avocado/utils/nvme.py - About 45 mins to fix

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

        def get_block_size(controller_name):
            """
            Returns the block size of the namespace.
            If not found, return defaults to 4k.
        
        
        Severity: Minor
        Found in avocado/utils/nvme.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 get_lba has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        def get_lba(namespace):
            """
            Returns LBA of the namespace. If not found, return defaults to 0.
        
            :param namespace: nvme namespace like /dev/nvme0n1, /dev/nvme0n2 etc..
        Severity: Minor
        Found in avocado/utils/nvme.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