torvalds/linux

View on GitHub

Showing 1,487 of 1,487 total issues

File sleepgraph.py has 6387 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0-only
#
# Tool for analyzing suspend/resume timing
# Copyright (c) 2013, Intel Corporation.
Severity: Major
Found in tools/power/pm-graph/sleepgraph.py - About 2 wks to fix

    File exported-sql-viewer.py has 3884 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    #!/usr/bin/env python
    # SPDX-License-Identifier: GPL-2.0
    # exported-sql-viewer.py: view data from sql database
    # Copyright (c) 2014-2018, Intel Corporation.
    
    
    Severity: Major
    Found in tools/perf/scripts/python/exported-sql-viewer.py - About 1 wk to fix

      Function parseTraceLog has a Cognitive Complexity of 477 (exceeds 5 allowed). Consider refactoring.
      Open

      def parseTraceLog(live=False):
          sysvals.vprint('Analyzing the ftrace data (%s)...' % \
              os.path.basename(sysvals.ftracefile))
          if(os.path.exists(sysvals.ftracefile) == False):
              doError('%s does not exist' % sysvals.ftracefile)
      Severity: Minor
      Found in tools/power/pm-graph/sleepgraph.py - About 1 wk 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 ynl-gen-c.py has 2318 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      #!/usr/bin/env python3
      # SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)
      
      import argparse
      import collections
      Severity: Major
      Found in tools/net/ynl/ynl-gen-c.py - About 6 days to fix

        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 main has a Cognitive Complexity of 234 (exceeds 5 allowed). Consider refactoring.
          Open

          def main():
              parser = argparse.ArgumentParser(description='Netlink simple parsing generator')
              parser.add_argument('--mode', dest='mode', type=str, required=True)
              parser.add_argument('--spec', dest='spec', type=str, required=True)
              parser.add_argument('--header', dest='header', action='store_true', default=None)
          Severity: Minor
          Found in tools/net/ynl/ynl-gen-c.py - About 4 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 createHTML has a Cognitive Complexity of 210 (exceeds 5 allowed). Consider refactoring.
          Open

          def createHTML(testruns, testfail):
              if len(testruns) < 1:
                  pprint('ERROR: Not enough test data to build a timeline')
                  return
          
          
          Severity: Minor
          Found in tools/power/pm-graph/sleepgraph.py - About 4 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 parseKernelLog has a Cognitive Complexity of 174 (exceeds 5 allowed). Consider refactoring.
          Open

          def parseKernelLog(data):
              phase = 'suspend_runtime'
          
              if(data.fwValid):
                  sysvals.vprint('Firmware Suspend = %u ns, Firmware Resume = %u ns' % \
          Severity: Minor
          Found in tools/power/pm-graph/sleepgraph.py - About 3 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 configFromFile has a Cognitive Complexity of 153 (exceeds 5 allowed). Consider refactoring.
          Open

          def configFromFile(file):
              Config = configparser.ConfigParser()
          
              Config.read(file)
              sections = Config.sections()
          Severity: Minor
          Found in tools/power/pm-graph/sleepgraph.py - About 3 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

          File test_offload.py has 1133 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          #!/usr/bin/env python3
          
          # Copyright (C) 2017 Netronome Systems, Inc.
          # Copyright (c) 2019 Mellanox Technologies. All rights reserved
          #
          Severity: Major
          Found in tools/testing/selftests/bpf/test_offload.py - About 2 days to fix

            File jevents.py has 1088 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            #!/usr/bin/env python3
            # SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
            """Convert directories of JSON events to C code."""
            import argparse
            import csv
            Severity: Major
            Found in tools/perf/pmu-events/jevents.py - About 2 days to fix

              File bootgraph.py has 937 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              #!/usr/bin/env python3
              # SPDX-License-Identifier: GPL-2.0-only
              #
              # Tool for analyzing boot timing
              # Copyright (c) 2013, Intel Corporation.
              Severity: Major
              Found in tools/power/pm-graph/bootgraph.py - About 2 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 addLine has a Cognitive Complexity of 105 (exceeds 5 allowed). Consider refactoring.
                Open

                    def addLine(self, line):
                        # if this is already invalid, just leave
                        if(self.invalid):
                            if(line.depth == 0 and line.freturn):
                                return 1
                Severity: Minor
                Found in tools/power/pm-graph/sleepgraph.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

                File tdc.py has 855 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                #!/usr/bin/env python3
                # SPDX-License-Identifier: GPL-2.0
                
                """
                tdc.py - Linux tc (Traffic Control) unit test driver
                Severity: Major
                Found in tools/testing/selftests/tc-testing/tdc.py - About 2 days to fix

                  File export-to-postgresql.py has 815 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  # export-to-postgresql.py: export perf data to a postgresql database
                  # Copyright (c) 2014, Intel Corporation.
                  #
                  # This program is free software; you can redistribute it and/or modify it
                  # under the terms and conditions of the GNU General Public License,
                  Severity: Major
                  Found in tools/perf/scripts/python/export-to-postgresql.py - About 1 day to fix

                    Function createHTMLSummarySimple has a Cognitive Complexity of 92 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def createHTMLSummarySimple(testruns, htmlfile, title):
                        # write the html header first (html head, css code, up to body start)
                        html = summaryCSS('Summary - SleepGraph')
                    
                        # extract the test data into list
                    Severity: Minor
                    Found in tools/power/pm-graph/sleepgraph.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

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                    class CallGraphLevelOneItem(CallGraphLevelItemBase):
                    
                        def __init__(self, glb, params, row, comm_id, comm, parent_item):
                            super(CallGraphLevelOneItem, self).__init__(glb, params, row, parent_item)
                            if self.params.have_ipc:
                    Severity: Major
                    Found in tools/perf/scripts/python/exported-sql-viewer.py and 1 other location - About 1 day to fix
                    tools/perf/scripts/python/exported-sql-viewer.py on lines 897..917

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 200.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                    class CallTreeLevelOneItem(CallGraphLevelItemBase):
                    
                        def __init__(self, glb, params, row, comm_id, comm, parent_item):
                            super(CallTreeLevelOneItem, self).__init__(glb, params, row, parent_item)
                            if self.params.have_ipc:
                    Severity: Major
                    Found in tools/perf/scripts/python/exported-sql-viewer.py and 1 other location - About 1 day to fix
                    tools/perf/scripts/python/exported-sql-viewer.py on lines 615..635

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 200.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    File task-analyzer.py has 769 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    # task-analyzer.py - comprehensive perf tasks analysis
                    # SPDX-License-Identifier: GPL-2.0
                    # Copyright (c) 2022, Hagen Paul Pfeifer <hagen@jauu.net>
                    # Licensed under the terms of the GNU GPL License version 2
                    #
                    Severity: Major
                    Found in tools/perf/scripts/python/task-analyzer.py - About 1 day to fix
                      Severity
                      Category
                      Status
                      Source
                      Language