torvalds/linux

View on GitHub
tools/net/ynl/ethtool.py

Summary

Maintainability
D
3 days
Test Coverage

Function main has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
Open

def main():
    parser = argparse.ArgumentParser(description='ethtool wannabe')
    parser.add_argument('--json', action=argparse.BooleanOptionalAction)
    parser.add_argument('--show-priv-flags', action=argparse.BooleanOptionalAction)
    parser.add_argument('--set-priv-flags', action=argparse.BooleanOptionalAction)
Severity: Minor
Found in tools/net/ynl/ethtool.py - About 7 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

File ethtool.py has 336 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause

import argparse
import json
Severity: Minor
Found in tools/net/ynl/ethtool.py - About 4 hrs to fix

    Function main has 80 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def main():
        parser = argparse.ArgumentParser(description='ethtool wannabe')
        parser.add_argument('--json', action=argparse.BooleanOptionalAction)
        parser.add_argument('--show-priv-flags', action=argparse.BooleanOptionalAction)
        parser.add_argument('--set-priv-flags', action=argparse.BooleanOptionalAction)
    Severity: Major
    Found in tools/net/ynl/ethtool.py - About 3 hrs to fix

      Function print_field has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

      def print_field(reply, *desc):
          """
          Pretty-print a set of fields from the reply. desc specifies the
          fields and the optional type (bool/yn).
          """
      Severity: Minor
      Found in tools/net/ynl/ethtool.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 dumpit has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def dumpit(ynl, args, op_name, extra = {}):
          """
          Prepare request header, parse arguments and dumpit (filtering out the
          devices we're not interested in).
          """
      Severity: Minor
      Found in tools/net/ynl/ethtool.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
      Severity: Major
      Found in tools/net/ynl/ethtool.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return
        Severity: Major
        Found in tools/net/ynl/ethtool.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return
          Severity: Major
          Found in tools/net/ynl/ethtool.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return
            Severity: Major
            Found in tools/net/ynl/ethtool.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return
              Severity: Major
              Found in tools/net/ynl/ethtool.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return doit(ynl, args, 'rings-set')
                Severity: Major
                Found in tools/net/ynl/ethtool.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                          return
                  Severity: Major
                  Found in tools/net/ynl/ethtool.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return
                    Severity: Major
                    Found in tools/net/ynl/ethtool.py - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                              return
                      Severity: Major
                      Found in tools/net/ynl/ethtool.py - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                return
                        Severity: Major
                        Found in tools/net/ynl/ethtool.py - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                  return
                          Severity: Major
                          Found in tools/net/ynl/ethtool.py - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                    return doit(ynl, args, 'channels-set')
                            Severity: Major
                            Found in tools/net/ynl/ethtool.py - About 30 mins to fix

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

                              def args_to_req(ynl, op_name, args, req):
                                  """
                                  Verify and convert command-line arguments to the ynl-compatible request.
                                  """
                                  valid_attrs = ynl.operation_do_attributes(op_name)
                              Severity: Minor
                              Found in tools/net/ynl/ethtool.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