avocado-framework/avocado

View on GitHub
avocado/utils/pmem.py

Summary

Maintainability
D
1 day
Test Coverage
F
19%

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

        if process.system(
            f"{self.ndctl} create-namespace {args}", shell=True, ignore_status=True
Severity: Minor
Found in avocado/utils/pmem.py by bandit

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

                process.system_output(
                    f"{self.ndctl} read-labels -j {nmem} ", shell=True
Severity: Minor
Found in avocado/utils/pmem.py by bandit

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

        if process.system(
            f"{self.ndctl} destroy-namespace {args}", shell=True, ignore_status=True
Severity: Minor
Found in avocado/utils/pmem.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/pmem.py by bandit

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

        if process.system(
            f"{self.ndctl} enable-region {name}", shell=True, ignore_status=True
Severity: Minor
Found in avocado/utils/pmem.py by bandit

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

        if process.system(
            f"{self.ndctl} disable-namespace {args}", shell=True, ignore_status=True
Severity: Minor
Found in avocado/utils/pmem.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/pmem.py by bandit

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

        if process.system(
            f"{self.ndctl} disable-region {name}", shell=True, ignore_status=True
Severity: Minor
Found in avocado/utils/pmem.py by bandit

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

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

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

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

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

        if process.system(
            f"{self.ndctl} enable-namespace {args}", shell=True, ignore_status=True
Severity: Minor
Found in avocado/utils/pmem.py by bandit

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

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

File pmem.py has 439 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/pmem.py - About 6 hrs to fix

    PMem has 24 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class PMem:
        """
        PMem class which provides function to perform ndctl and daxctl operations
    
        This class can be used only if ndctl binaries are provided before hand
    Severity: Minor
    Found in avocado/utils/pmem.py - About 2 hrs to fix

      Function create_namespace has 13 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def create_namespace(
      Severity: Major
      Found in avocado/utils/pmem.py - About 1 hr to fix

        Function write_infoblock has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def write_infoblock(self, namespace="", stdout=False, output=None, **kwargs):
                """
                Write an infoblock to the specified medium.
        
                :param namespace: Write the infoblock to given namespace
        Severity: Minor
        Found in avocado/utils/pmem.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 create_namespace has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def create_namespace(
                self,
                region="",
                bus="",
                n_type="pmem",
        Severity: Minor
        Found in avocado/utils/pmem.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 read_infoblock has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def read_infoblock(self, namespace="", inp_file="", **kwargs):
                """
                Read an infoblock from the specified medium
        
                :param namespace: Read the infoblock from given namespace
        Severity: Minor
        Found in avocado/utils/pmem.py - About 55 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 reconfigure_dax_device has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

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

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

              def destroy_namespace(self, namespace="all", region="", bus="", force=False):
                  """
                  Destroy namespaces, skipped in case of legacy namespace
          
                  :param namespace: name of the namespace to be destroyed
          Severity: Minor
          Found in avocado/utils/pmem.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