torvalds/linux

View on GitHub
tools/testing/selftests/net/openvswitch/ovs-dpctl.py

Summary

Maintainability
F
1 wk
Test Coverage

File ovs-dpctl.py has 1946 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0

# Controls the openvswitch module.  Part of the kselftest suite, but
# can be used for some diagnostic purpose as well.
Severity: Major
Found in tools/testing/selftests/net/openvswitch/ovs-dpctl.py - About 5 days to fix

    Function parse has a Cognitive Complexity of 112 (exceeds 5 allowed). Consider refactoring.
    Open

        def parse(self, actstr):
            totallen = len(actstr)
            while len(actstr) != 0:
                parsed = False
                parencount = 0
    Severity: Minor
    Found in tools/testing/selftests/net/openvswitch/ovs-dpctl.py - About 2 days 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 main has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
    Open

    def main(argv):
        nlmsg_atoms.ovskey = ovskey
        nlmsg_atoms.ovsactions = ovsactions
    
        # version check for pyroute2
    Severity: Minor
    Found in tools/testing/selftests/net/openvswitch/ovs-dpctl.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 dpstr has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        def dpstr(self, more=False):
            print_str = ""
    
            for field in self.nla_map:
                if field[1] == "none" or self.get_attr(field[0]) is None:
    Severity: Minor
    Found in tools/testing/selftests/net/openvswitch/ovs-dpctl.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_flags has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    def parse_flags(flag_str, flag_vals):
        bitResult = 0
        maskResult = 0
    
        if len(flag_str) == 0:
    Severity: Minor
    Found in tools/testing/selftests/net/openvswitch/ovs-dpctl.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 has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

            def parse(self, flowstr, typeInst):
                if not flowstr.startswith(self.proto_str):
                    return None, None
    
                k = typeInst()
    Severity: Minor
    Found in tools/testing/selftests/net/openvswitch/ovs-dpctl.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 dpstr has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

            def dpstr(self, masked=None, more=False):
                outstr = self.proto_str + "("
                first = False
                for f in self.fields_map:
                    if first:
    Severity: Minor
    Found in tools/testing/selftests/net/openvswitch/ovs-dpctl.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 dpstr has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        def dpstr(self, mask=None, more=False):
            print_str = ""
    
            for field in (
                (
    Severity: Minor
    Found in tools/testing/selftests/net/openvswitch/ovs-dpctl.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 create has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def create(
            self, dpname, shouldUpcall=False, versionStr=None, p=OvsPacket()
        ):
            msg = OvsDatapath.dp_cmd_msg()
            msg["cmd"] = OVS_DP_CMD_NEW
    Severity: Minor
    Found in tools/testing/selftests/net/openvswitch/ovs-dpctl.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 dpstr has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

                def dpstr(self, more=False):
                    print_str = "nat("
    
                    if self.get_attr("OVS_NAT_ATTR_SRC"):
                        print_str += "src"
    Severity: Minor
    Found in tools/testing/selftests/net/openvswitch/ovs-dpctl.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 upcall_handler has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def upcall_handler(self, up=None):
            print("listening on upcall packet handler:", self.epid)
            while True:
                try:
                    msgs = self.get()
    Severity: Minor
    Found in tools/testing/selftests/net/openvswitch/ovs-dpctl.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 main has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def main(argv):
        nlmsg_atoms.ovskey = ovskey
        nlmsg_atoms.ovsactions = ovsactions
    
        # version check for pyroute2
    Severity: Minor
    Found in tools/testing/selftests/net/openvswitch/ovs-dpctl.py - About 1 hr to fix

      Function parse_starts_block has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      def parse_starts_block(block_str, scanstr, returnskipped, scanregex=False):
          if scanregex:
              m = re.search(scanstr, block_str)
              if m is None:
                  if returnskipped:
      Severity: Minor
      Found in tools/testing/selftests/net/openvswitch/ovs-dpctl.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 dpstr has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

              def dpstr(self, more=False):
                  ufid = self.get_attr("OVS_FLOW_ATTR_UFID")
                  ufid_str = ""
                  if ufid is not None:
                      ufid_str = (
      Severity: Minor
      Found in tools/testing/selftests/net/openvswitch/ovs-dpctl.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 parse_extract_field has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      def parse_extract_field(
          block_str, fieldstr, scanfmt, convert, masked=False, defval=None
      ):
          if fieldstr and not block_str.startswith(fieldstr):
              return block_str, defval
      Severity: Minor
      Found in tools/testing/selftests/net/openvswitch/ovs-dpctl.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 parse has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def parse(self, flowstr, mask=None):
              for field in (
                  ("OVS_KEY_ATTR_PRIORITY", "skb_priority", intparse),
                  ("OVS_KEY_ATTR_SKB_MARK", "skb_mark", intparse),
                  ("OVS_KEY_ATTR_RECIRC_ID", "recirc_id", intparse),
      Severity: Minor
      Found in tools/testing/selftests/net/openvswitch/ovs-dpctl.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

      Avoid deeply nested control flow statements.
      Open

                              if scan[2] is not None:
                                  if actstr[0] != "=":
                                      raise ValueError("Invalid ct attr")
                                  actstr = actstr[1:]
                                  pos = strcspn(actstr, ",)")
      Severity: Major
      Found in tools/testing/selftests/net/openvswitch/ovs-dpctl.py - About 45 mins to fix

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

                def __init__(
        Severity: Minor
        Found in tools/testing/selftests/net/openvswitch/ovs-dpctl.py - About 45 mins to fix

          Function parse_extract_field has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def parse_extract_field(
          Severity: Minor
          Found in tools/testing/selftests/net/openvswitch/ovs-dpctl.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if actstr.startswith("("):
                                        parencount += 1
                                        t = None
                                        actstr = actstr[1:]
                                        if actstr.startswith("src"):
            Severity: Major
            Found in tools/testing/selftests/net/openvswitch/ovs-dpctl.py - About 45 mins to fix

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

                      def __init__(
              Severity: Minor
              Found in tools/testing/selftests/net/openvswitch/ovs-dpctl.py - About 35 mins to fix

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

                        def __init__(
                Severity: Minor
                Found in tools/testing/selftests/net/openvswitch/ovs-dpctl.py - About 35 mins to fix

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

                          def __init__(
                  Severity: Minor
                  Found in tools/testing/selftests/net/openvswitch/ovs-dpctl.py - About 35 mins to fix

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

                            def __init__(
                    Severity: Minor
                    Found in tools/testing/selftests/net/openvswitch/ovs-dpctl.py - About 35 mins to fix

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

                              def __init__(
                      Severity: Minor
                      Found in tools/testing/selftests/net/openvswitch/ovs-dpctl.py - About 35 mins to fix

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

                                def __init__(
                        Severity: Minor
                        Found in tools/testing/selftests/net/openvswitch/ovs-dpctl.py - About 35 mins to fix

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

                                  def __init__(
                          Severity: Minor
                          Found in tools/testing/selftests/net/openvswitch/ovs-dpctl.py - About 35 mins to fix

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

                                    def __init__(
                            Severity: Minor
                            Found in tools/testing/selftests/net/openvswitch/ovs-dpctl.py - About 35 mins to fix

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

                                      def __init__(
                              Severity: Minor
                              Found in tools/testing/selftests/net/openvswitch/ovs-dpctl.py - About 35 mins to fix

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

                                    def create(
                                Severity: Minor
                                Found in tools/testing/selftests/net/openvswitch/ovs-dpctl.py - About 35 mins to fix

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

                                          def __init__(
                                  Severity: Minor
                                  Found in tools/testing/selftests/net/openvswitch/ovs-dpctl.py - About 35 mins to fix

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

                                            def __init__(
                                    Severity: Minor
                                    Found in tools/testing/selftests/net/openvswitch/ovs-dpctl.py - About 35 mins to fix

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

                                              def __init__(
                                      Severity: Minor
                                      Found in tools/testing/selftests/net/openvswitch/ovs-dpctl.py - About 35 mins to fix

                                        Function dpstr has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                        Open

                                                def dpstr(self, more=False):
                                                    print_str = "ct("
                                        
                                                    if self.get_attr("OVS_CT_ATTR_COMMIT") is not None:
                                                        print_str += "commit,"
                                        Severity: Minor
                                        Found in tools/testing/selftests/net/openvswitch/ovs-dpctl.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 tools/testing/selftests/net/openvswitch/ovs-dpctl.py - About 30 mins to fix

                                          Avoid too many return statements within this function.
                                          Open

                                                      return "geneve"
                                          Severity: Major
                                          Found in tools/testing/selftests/net/openvswitch/ovs-dpctl.py - About 30 mins to fix

                                            Avoid too many return statements within this function.
                                            Open

                                                    return block_str
                                            Severity: Major
                                            Found in tools/testing/selftests/net/openvswitch/ovs-dpctl.py - About 30 mins to fix

                                              Avoid too many return statements within this function.
                                              Open

                                                  return 0
                                              Severity: Major
                                              Found in tools/testing/selftests/net/openvswitch/ovs-dpctl.py - About 30 mins to fix

                                                Avoid too many return statements within this function.
                                                Open

                                                            return OvsVport.OVS_VPORT_TYPE_GENEVE
                                                Severity: Major
                                                Found in tools/testing/selftests/net/openvswitch/ovs-dpctl.py - About 30 mins to fix

                                                  Avoid too many return statements within this function.
                                                  Open

                                                      return False
                                                  Severity: Major
                                                  Found in tools/testing/selftests/net/openvswitch/ovs-dpctl.py - About 30 mins to fix

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

                                                        def info(self, vport_name, dpifindex=0, portno=None):
                                                            msg = OvsVport.ovs_vport_msg()
                                                    
                                                            msg["cmd"] = OVS_VPORT_CMD_GET
                                                            msg["version"] = OVS_DATAPATH_VERSION
                                                    Severity: Minor
                                                    Found in tools/testing/selftests/net/openvswitch/ovs-dpctl.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