torvalds/linux

View on GitHub

Showing 1,485 of 1,485 total issues

File ynl.py has 767 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause

from collections import namedtuple
import functools
import os
Severity: Major
Found in tools/net/ynl/lib/ynl.py - About 1 day to fix

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

        def Select(self):
            super(CallGraphLevelTwoItem, self).Select()
            for child_item in self.child_items:
                self.time += child_item.time
                self.insn_cnt += child_item.insn_cnt
    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 879..893

    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 197.

    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

        def Select(self):
            super(CallTreeLevelTwoItem, self).Select()
            for child_item in self.child_items:
                self.time += child_item.time
                self.insn_cnt += child_item.insn_cnt
    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 597..611

    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 197.

    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 bpf_doc.py has 733 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    #!/usr/bin/env python3
    # SPDX-License-Identifier: GPL-2.0-only
    #
    # Copyright (C) 2018-2019 Netronome Systems, Inc.
    # Copyright (C) 2021 Isovalent, Inc.
    Severity: Major
    Found in scripts/bpf_doc.py - About 1 day to fix

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

          if source_file_name:
              if glb_line_number == line_number and glb_source_file_name == source_file_name:
                  src_str = ""
              else:
                  if len(source_file_name) > 40:
      Severity: Major
      Found in tools/perf/scripts/python/arm-cs-trace-disasm.py and 1 other location - About 1 day to fix
      tools/perf/scripts/python/intel-pt-events.py on lines 318..335

      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 183.

      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

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

          if source_file_name:
              if glb_line_number == line_number and glb_source_file_name == source_file_name:
                  src_str = ""
              else:
                  if len(source_file_name) > 40:
      Severity: Major
      Found in tools/perf/scripts/python/intel-pt-events.py and 1 other location - About 1 day to fix
      tools/perf/scripts/python/arm-cs-trace-disasm.py on lines 152..170

      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 183.

      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

      Function print_kernel_op_table has a Cognitive Complexity of 81 (exceeds 5 allowed). Consider refactoring.
      Open

      def print_kernel_op_table(family, cw):
          print_kernel_op_table_fwd(family, cw, terminate=False)
          if family.kernel_policy == 'global' or family.kernel_policy == 'per-op':
              for op_name, op in family.ops.items():
                  if op.is_async:
      Severity: Minor
      Found in tools/net/ynl/ynl-gen-c.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 data_from_html has a Cognitive Complexity of 79 (exceeds 5 allowed). Consider refactoring.
      Open

      def data_from_html(file, outpath, issues, fulldetail=False):
          html = open(file, 'r').read()
          sysvals.htmlfile = os.path.relpath(file, outpath)
          # extract general info
          suspend = find_in_html(html, 'Kernel Suspend', 'ms')
      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

          def parse_ret(self, proto):
              p = re.compile(r' \* ?(?:\t| {5,8})Return$')
              capture = p.match(self.line)
              if not capture:
                  raise Exception("No return section found for " + proto)
      Severity: Major
      Found in scripts/bpf_doc.py and 1 other location - About 1 day to fix
      scripts/bpf_doc.py on lines 143..167

      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 177.

      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

          def parse_desc(self, proto):
              p = re.compile(r' \* ?(?:\t| {5,8})Description$')
              capture = p.match(self.line)
              if not capture:
                  raise Exception("No description section found for " + proto)
      Severity: Major
      Found in scripts/bpf_doc.py and 1 other location - About 1 day to fix
      scripts/bpf_doc.py on lines 169..193

      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 177.

      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

      Function executeSuspend has a Cognitive Complexity of 78 (exceeds 5 allowed). Consider refactoring.
      Open

      def executeSuspend(quiet=False):
          sv, tp, pm = sysvals, sysvals.tpath, ProcessMonitor()
          if sv.wifi:
              wifi = sv.checkWifi()
              sv.dlog('wifi check, connected device is "%s"' % wifi)
      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 CallGraphRootItem(CallGraphLevelItemBase):
      
          def __init__(self, glb, params):
              super(CallGraphRootItem, self).__init__(glb, params, 0, None)
              self.dbid = 0
      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 921..937

      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 174.

      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 CallTreeRootItem(CallGraphLevelItemBase):
      
          def __init__(self, glb, params):
              super(CallTreeRootItem, self).__init__(glb, params, 0, None)
              self.dbid = 0
      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 639..655

      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 174.

      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

              while query.next():
                  if self.params.have_ipc:
                      insn_cnt = int(query.value(5))
                      cyc_cnt = int(query.value(6))
                      branch_count = int(query.value(7))
      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 837..848

      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 173.

      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

              while query.next():
                  if self.params.have_ipc:
                      insn_cnt = int(query.value(5))
                      cyc_cnt = int(query.value(6))
                      branch_count = int(query.value(7))
      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 555..566

      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 173.

      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

      Function render_uapi has a Cognitive Complexity of 76 (exceeds 5 allowed). Consider refactoring.
      Open

      def render_uapi(family, cw):
          hdr_prot = f"_UAPI_LINUX_{c_upper(family.uapi_header_name)}_H"
          cw.p('#ifndef ' + hdr_prot)
          cw.p('#define ' + hdr_prot)
          cw.nl()
      Severity: Minor
      Found in tools/net/ynl/ynl-gen-c.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 appendIncompleteTraceLog has a Cognitive Complexity of 76 (exceeds 5 allowed). Consider refactoring.
      Open

      def appendIncompleteTraceLog(testruns):
          # create TestRun vessels for ftrace parsing
          testcnt = len(testruns)
          testidx = 0
          testrun = []
      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

      File kunit_tool_test.py has 666 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      #!/usr/bin/env python3
      # SPDX-License-Identifier: GPL-2.0
      #
      # A collection of tests for tools/testing/kunit/kunit.py
      #
      Severity: Major
      Found in tools/testing/kunit/kunit_tool_test.py - About 1 day to fix

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

        # export-to-sqlite.py: export perf data to a sqlite3 database
        # Copyright (c) 2017, 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-sqlite.py - About 1 day to fix

          SystemValues has 77 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class SystemValues:
              title = 'SleepGraph'
              version = '5.11'
              ansi = False
              rs = 0
          Severity: Major
          Found in tools/power/pm-graph/sleepgraph.py - About 1 day to fix
            Severity
            Category
            Status
            Source
            Language