torvalds/linux

View on GitHub
tools/perf/scripts/python/arm-cs-trace-disasm.py

Summary

Maintainability
F
4 days
Test Coverage

Function process_event has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

def process_event(param_dict):
    global cache_size
    global options

    sample = param_dict["sample"]
Severity: Minor
Found in tools/perf/scripts/python/arm-cs-trace-disasm.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 print_srccode has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

def print_srccode(comm, param_dict, sample, symbol, dso):
    ip = sample["ip"]
    if symbol == "[unknown]":
        start_str = common_start_str(comm, sample) + ("%x" % ip).rjust(16).ljust(40)
    else:
Severity: Minor
Found in tools/perf/scripts/python/arm-cs-trace-disasm.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 print_srccode has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

def print_srccode(comm, param_dict, sample, symbol, dso):
Severity: Minor
Found in tools/perf/scripts/python/arm-cs-trace-disasm.py - About 35 mins to fix

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

    def get_dso_file_path(dso_name, dso_build_id):
        if (dso_name == "[kernel.kallsyms]" or dso_name == "vmlinux"):
            if (options.vmlinux_name):
                return options.vmlinux_name;
            else:
    Severity: Minor
    Found in tools/perf/scripts/python/arm-cs-trace-disasm.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/perf/scripts/python/arm-cs-trace-disasm.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return
      Severity: Major
      Found in tools/perf/scripts/python/arm-cs-trace-disasm.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return
        Severity: Major
        Found in tools/perf/scripts/python/arm-cs-trace-disasm.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return
          Severity: Major
          Found in tools/perf/scripts/python/arm-cs-trace-disasm.py - About 30 mins to fix

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

            def print_disam(dso_fname, dso_start, start_addr, stop_addr):
                for line in read_disam(dso_fname, dso_start, start_addr, stop_addr):
                    m = disasm_func_re.search(line)
                    if m is None:
                        m = disasm_re.search(line)
            Severity: Minor
            Found in tools/perf/scripts/python/arm-cs-trace-disasm.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

            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 symbol == "[unknown]":
                    start_str = common_start_str(comm, sample) + ("%x" % ip).rjust(16).ljust(40)
                else:
                    offs = get_offset(param_dict, "symoff")
                    start_str = common_start_str(comm, sample) + (symbol + offs).ljust(40)
            Severity: Major
            Found in tools/perf/scripts/python/arm-cs-trace-disasm.py and 1 other location - About 4 hrs to fix
            tools/perf/scripts/python/intel-pt-events.py on lines 301..305

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

            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

                if (start_addr < int(dso_start) or start_addr > int(dso_end)):
                    print("Start address 0x%x is out of range [ 0x%x .. 0x%x ] for dso %s" % (start_addr, int(dso_start), int(dso_end), dso))
                    return
            Severity: Major
            Found in tools/perf/scripts/python/arm-cs-trace-disasm.py and 1 other location - About 2 hrs to fix
            tools/perf/scripts/python/arm-cs-trace-disasm.py on lines 256..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 56.

            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

                if (stop_addr < int(dso_start) or stop_addr > int(dso_end)):
                    print("Stop address 0x%x is out of range [ 0x%x .. 0x%x ] for dso %s" % (stop_addr, int(dso_start), int(dso_end), dso))
                    return
            Severity: Major
            Found in tools/perf/scripts/python/arm-cs-trace-disasm.py and 1 other location - About 2 hrs to fix
            tools/perf/scripts/python/arm-cs-trace-disasm.py on lines 252..254

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

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

            def trace_unhandled(event_name, context, event_fields_dict):
                print(' '.join(['%s=%s'%(k,str(v))for k,v in sorted(event_fields_dict.items())]))
            Severity: Major
            Found in tools/perf/scripts/python/arm-cs-trace-disasm.py and 2 other locations - About 2 hrs to fix
            tools/perf/scripts/python/event_analyzing_sample.py on lines 191..192
            tools/perf/scripts/python/intel-pt-events.py on lines 109..110

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

            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

            def get_offset(perf_dict, field):
                if field in perf_dict:
                    return "+%#x" % perf_dict[field]
                return ""
            Severity: Minor
            Found in tools/perf/scripts/python/arm-cs-trace-disasm.py and 1 other location - About 45 mins to fix
            tools/perf/scripts/python/intel-pt-events.py on lines 70..73

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

            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

                addr_range = str(start_addr) + ":" + str(stop_addr) + ":" + dso_fname
            Severity: Minor
            Found in tools/perf/scripts/python/arm-cs-trace-disasm.py and 1 other location - About 35 mins to fix
            tools/perf/scripts/python/exported-sql-viewer.py on lines 1242..1242

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

            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

            There are no issues that match your filters.

            Category
            Status