torvalds/linux

View on GitHub

Showing 1,485 of 1,485 total issues

File kunit.py has 462 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0
#
# A thin wrapper on top of the KUnit Kernel
#
Severity: Minor
Found in tools/testing/kunit/kunit.py - About 7 hrs to fix

    Function read_spdxdata has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
    Open

    def read_spdxdata(repo):
    
        # The subdirectories of LICENSES in the kernel source
        # Note: exceptions needs to be parsed as last directory.
        license_dirs = [ "preferred", "dual", "deprecated", "exceptions" ]
    Severity: Minor
    Found in scripts/spdxcheck.py - About 6 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

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

            for i in range(2):
                s = sorted(tMed[i])
                list[lastmode]['med'][i] = s[int(len(s)//2)]
                iMed[i] = tMed[i][list[lastmode]['med'][i]]
    Severity: Major
    Found in tools/power/pm-graph/sleepgraph.py and 1 other location - About 6 hrs to fix
    tools/power/pm-graph/sleepgraph.py on lines 4325..4328

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

    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

                for i in range(2):
                    s = sorted(tMed[i])
                    list[lastmode]['med'][i] = s[int(len(s)//2)]
                    iMed[i] = tMed[i][list[lastmode]['med'][i]]
    Severity: Major
    Found in tools/power/pm-graph/sleepgraph.py and 1 other location - About 6 hrs to fix
    tools/power/pm-graph/sleepgraph.py on lines 4367..4370

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

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

    def createBootGraph(data):
        # html function templates
        html_srccall = '<div id={6} title="{5}" class="srccall" style="left:{1}%;top:{2}px;height:{3}px;width:{4}%;line-height:{3}px;">{0}</div>\n'
        html_timetotal = '<table class="time1">\n<tr>'\
            '<td class="blue">Init process starts @ <b>{0} ms</b></td>'\
    Severity: Minor
    Found in tools/power/pm-graph/bootgraph.py - About 6 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

    Data has 48 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Data:
        phasedef = {
            'suspend_prepare': {'order': 0, 'color': '#CCFFCC'},
                    'suspend': {'order': 1, 'color': '#88FF88'},
               'suspend_late': {'order': 2, 'color': '#00AA00'},
    Severity: Minor
    Found in tools/power/pm-graph/sleepgraph.py - About 6 hrs to fix

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

      def plot_duration_cpu():
          """ Plot all cpu durations """
      
          output_png = 'all_cpu_durations.png'
          g_plot = common_all_gnuplot_settings(output_png)
      Severity: Major
      Found in tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py and 4 other locations - About 6 hrs to fix
      tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py on lines 187..202
      tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py on lines 218..230
      tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py on lines 246..258
      tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py on lines 274..286

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

      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 5 locations. Consider refactoring.
      Open

      def plot_scaled_cpu():
          """ Plot all cpu scaled busy """
      
          output_png = 'all_cpu_scaled.png'
          g_plot = common_all_gnuplot_settings(output_png)
      Severity: Major
      Found in tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py and 4 other locations - About 6 hrs to fix
      tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py on lines 187..202
      tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py on lines 218..230
      tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py on lines 232..244
      tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py on lines 274..286

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

      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 5 locations. Consider refactoring.
      Open

      def plot_ghz_cpu():
          """ Plot all cpu tsc ghz """
      
          output_png = 'all_cpu_ghz.png'
          g_plot = common_all_gnuplot_settings(output_png)
      Severity: Major
      Found in tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py and 4 other locations - About 6 hrs to fix
      tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py on lines 187..202
      tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py on lines 218..230
      tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py on lines 232..244
      tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py on lines 246..258

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

      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 5 locations. Consider refactoring.
      Open

      def plot_frequency_cpu():
          """ Plot all cpu frequencies """
      
          output_png = 'all_cpu_frequencies.png'
          g_plot = common_all_gnuplot_settings(output_png)
      Severity: Major
      Found in tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py and 4 other locations - About 6 hrs to fix
      tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py on lines 187..202
      tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py on lines 232..244
      tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py on lines 246..258
      tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py on lines 274..286

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

      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 5 locations. Consider refactoring.
      Open

      def plot_pstate_cpu():
          """ Plot all cpu information from csv files """
      
          output_png = 'all_cpu_pstates.png'
          g_plot = common_all_gnuplot_settings(output_png)
      Severity: Major
      Found in tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py and 4 other locations - About 6 hrs to fix
      tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py on lines 218..230
      tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py on lines 232..244
      tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py on lines 246..258
      tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py on lines 274..286

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

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

      # SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
      """Parse or generate representations of perf metrics."""
      import ast
      import decimal
      import json
      Severity: Minor
      Found in tools/perf/pmu-events/metric.py - About 6 hrs to fix

        Function addCallgraphs has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
        Open

        def addCallgraphs(sv, hf, data):
            hf.write('<section id="callgraphs" class="callgraph">\n')
            # write out the ftrace data converted to html
            num = 0
            for p in data.sortedPhases():
        Severity: Minor
        Found in tools/power/pm-graph/sleepgraph.py - About 6 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 roundOffTableDefinition has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
        Open

            def roundOffTableDefinition(self):
                u"""Round off the table definition.
        
                This method rounds off the table definition in :py:member:`rows`.
        
        
        Severity: Minor
        Found in Documentation/sphinx/rstFlatTable.py - About 6 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 _add_attr has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
        Open

            def _add_attr(self, space, name, value, search_attrs):
                try:
                    attr = self.attr_sets[space][name]
                except KeyError:
                    raise Exception(f"Space '{space}' has no attribute '{name}'")
        Severity: Minor
        Found in tools/net/ynl/lib/ynl.py - About 6 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

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

        class LxSym2PFN(gdb.Command):
            """symbol address to PFN"""
        
            def __init__(self):
                super(LxSym2PFN, self).__init__("lx-sym_to_pfn", gdb.COMMAND_USER)
        Severity: Major
        Found in scripts/gdb/linux/mm.py and 2 other locations - About 6 hrs to fix
        scripts/gdb/linux/mm.py on lines 344..354
        scripts/gdb/linux/mm.py on lines 358..368

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

        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 3 locations. Consider refactoring.
        Open

        class LxVirt2Page(gdb.Command):
            """virtual address to struct page"""
        
            def __init__(self):
                super(LxVirt2Page, self).__init__("lx-virt_to_page", gdb.COMMAND_USER)
        Severity: Major
        Found in scripts/gdb/linux/mm.py and 2 other locations - About 6 hrs to fix
        scripts/gdb/linux/mm.py on lines 344..354
        scripts/gdb/linux/mm.py on lines 372..382

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

        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 3 locations. Consider refactoring.
        Open

        class LxVirt2Phys(gdb.Command):
            """virtual address to physical address"""
        
            def __init__(self):
                super(LxVirt2Phys, self).__init__("lx-virt_to_phys", gdb.COMMAND_USER)
        Severity: Major
        Found in scripts/gdb/linux/mm.py and 2 other locations - About 6 hrs to fix
        scripts/gdb/linux/mm.py on lines 358..368
        scripts/gdb/linux/mm.py on lines 372..382

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

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

            def cmdinfo(self, begin, debug=False):
                out = []
                if begin:
                    self.cmd1 = dict()
                for cargs in self.infocmds:
        Severity: Minor
        Found in tools/power/pm-graph/sleepgraph.py - About 6 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

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

        class LxPFN2Page(gdb.Command):
            """PFN to struct page"""
        
            def __init__(self):
                super(LxPFN2Page, self).__init__("lx-pfn_to_page", gdb.COMMAND_USER)
        Severity: Major
        Found in scripts/gdb/linux/mm.py and 1 other location - About 6 hrs to fix
        scripts/gdb/linux/mm.py on lines 386..396

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

        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

        Severity
        Category
        Status
        Source
        Language