torvalds/linux

View on GitHub
tools/perf/scripts/python/sched-migration.py

Summary

Maintainability
F
5 days
Test Coverage

File sched-migration.py has 346 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Cpu task migration overview toy
#
# Copyright (C) 2010 Frederic Weisbecker <fweisbec@gmail.com>
#
# perf script event handlers have been generated by perf script -g python
Severity: Minor
Found in tools/perf/scripts/python/sched-migration.py - About 4 hrs to fix

    Function sched__sched_switch has 15 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def sched__sched_switch(event_name, context, common_cpu,
    Severity: Major
    Found in tools/perf/scripts/python/sched-migration.py - About 1 hr to fix

      Function sched__sched_migrate_task has 13 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def sched__sched_migrate_task(event_name, context, common_cpu,
      Severity: Major
      Found in tools/perf/scripts/python/sched-migration.py - About 1 hr to fix

        Function sched__sched_wakeup has 13 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def sched__sched_wakeup(event_name, context, common_cpu,
        Severity: Major
        Found in tools/perf/scripts/python/sched-migration.py - About 1 hr to fix

          Function sched__sched_wakeup_new has 13 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def sched__sched_wakeup_new(event_name, context, common_cpu,
          Severity: Major
          Found in tools/perf/scripts/python/sched-migration.py - About 1 hr to fix

            Function sched__sched_process_fork has 12 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def sched__sched_process_fork(event_name, context, common_cpu,
            Severity: Major
            Found in tools/perf/scripts/python/sched-migration.py - About 1 hr to fix

              Function sched__sched_stat_runtime has 12 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              def sched__sched_stat_runtime(event_name, context, common_cpu,
              Severity: Major
              Found in tools/perf/scripts/python/sched-migration.py - About 1 hr to fix

                Function sched__sched_stat_sleep has 11 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                def sched__sched_stat_sleep(event_name, context, common_cpu,
                Severity: Major
                Found in tools/perf/scripts/python/sched-migration.py - About 1 hr to fix

                  Function sched__sched_wait_task has 11 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  def sched__sched_wait_task(event_name, context, common_cpu,
                  Severity: Major
                  Found in tools/perf/scripts/python/sched-migration.py - About 1 hr to fix

                    Function sched__sched_process_wait has 11 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    def sched__sched_process_wait(event_name, context, common_cpu,
                    Severity: Major
                    Found in tools/perf/scripts/python/sched-migration.py - About 1 hr to fix

                      Function sched__sched_stat_iowait has 11 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      def sched__sched_stat_iowait(event_name, context, common_cpu,
                      Severity: Major
                      Found in tools/perf/scripts/python/sched-migration.py - About 1 hr to fix

                        Function sched__sched_process_exit has 11 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        def sched__sched_process_exit(event_name, context, common_cpu,
                        Severity: Major
                        Found in tools/perf/scripts/python/sched-migration.py - About 1 hr to fix

                          Function sched__sched_stat_wait has 11 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                          def sched__sched_stat_wait(event_name, context, common_cpu,
                          Severity: Major
                          Found in tools/perf/scripts/python/sched-migration.py - About 1 hr to fix

                            Function sched__sched_process_free has 11 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                            def sched__sched_process_free(event_name, context, common_cpu,
                            Severity: Major
                            Found in tools/perf/scripts/python/sched-migration.py - About 1 hr to fix

                              Function sched__sched_kthread_stop has 10 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                              def sched__sched_kthread_stop(event_name, context, common_cpu,
                              Severity: Major
                              Found in tools/perf/scripts/python/sched-migration.py - About 1 hr to fix

                                Function sched__sched_kthread_stop_ret has 9 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                def sched__sched_kthread_stop_ret(event_name, context, common_cpu,
                                Severity: Major
                                Found in tools/perf/scripts/python/sched-migration.py - About 1 hr to fix

                                  Function find_time_slice has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      def find_time_slice(self, ts):
                                          start = 0
                                          end = len(self.data)
                                          found = -1
                                          searching = True
                                  Severity: Minor
                                  Found in tools/perf/scripts/python/sched-migration.py - About 1 hr 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 sched_switch has 8 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                      def sched_switch(self, headers, prev_comm, prev_pid, prev_prio, prev_state,
                                  Severity: Major
                                  Found in tools/perf/scripts/python/sched-migration.py - About 1 hr to fix

                                    Function wake_up has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                    Open

                                        def wake_up(self, headers, comm, pid, success, target_cpu, fork):
                                    Severity: Minor
                                    Found in tools/perf/scripts/python/sched-migration.py - About 45 mins to fix

                                      Function sched_switch has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                          def sched_switch(self, prev, prev_state, next):
                                              event = RunqueueEventUnknown()
                                      
                                              if taskState(prev_state) == "R" and next in self.tasks \
                                                  and prev in self.tasks:
                                      Severity: Minor
                                      Found in tools/perf/scripts/python/sched-migration.py - About 45 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

                                      Function migrate has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                      Open

                                          def migrate(self, headers, pid, prio, orig_cpu, dest_cpu):
                                      Severity: Minor
                                      Found in tools/perf/scripts/python/sched-migration.py - About 35 mins to fix

                                        Function sched_switch has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                        Open

                                            def sched_switch(self, ts_list, prev, prev_state, next, cpu):
                                        Severity: Minor
                                        Found in tools/perf/scripts/python/sched-migration.py - About 35 mins to fix

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

                                              def fill_zone(self, start, end):
                                                  i = self.find_time_slice(start)
                                                  if i == -1:
                                                      return
                                          
                                          
                                          Severity: Minor
                                          Found in tools/perf/scripts/python/sched-migration.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

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

                                          class RunqueueMigrateIn:
                                              @staticmethod
                                              def color():
                                                  return (0, 0xf0, 0xff)
                                          
                                          
                                          Severity: Major
                                          Found in tools/perf/scripts/python/sched-migration.py and 4 other locations - About 2 hrs to fix
                                          tools/perf/scripts/python/sched-migration.py on lines 44..53
                                          tools/perf/scripts/python/sched-migration.py on lines 55..64
                                          tools/perf/scripts/python/sched-migration.py on lines 66..75
                                          tools/perf/scripts/python/sched-migration.py on lines 88..97

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

                                          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

                                          class RunqueueEventFork:
                                              @staticmethod
                                              def color():
                                                  return (0, 0xff, 0)
                                          
                                          
                                          Severity: Major
                                          Found in tools/perf/scripts/python/sched-migration.py and 4 other locations - About 2 hrs to fix
                                          tools/perf/scripts/python/sched-migration.py on lines 44..53
                                          tools/perf/scripts/python/sched-migration.py on lines 55..64
                                          tools/perf/scripts/python/sched-migration.py on lines 77..86
                                          tools/perf/scripts/python/sched-migration.py on lines 88..97

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

                                          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

                                          class RunqueueMigrateOut:
                                              @staticmethod
                                              def color():
                                                  return (0xff, 0, 0xff)
                                          
                                          
                                          Severity: Major
                                          Found in tools/perf/scripts/python/sched-migration.py and 4 other locations - About 2 hrs to fix
                                          tools/perf/scripts/python/sched-migration.py on lines 44..53
                                          tools/perf/scripts/python/sched-migration.py on lines 55..64
                                          tools/perf/scripts/python/sched-migration.py on lines 66..75
                                          tools/perf/scripts/python/sched-migration.py on lines 77..86

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

                                          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

                                          class RunqueueEventWakeup:
                                              @staticmethod
                                              def color():
                                                  return (0xff, 0xff, 0)
                                          
                                          
                                          Severity: Major
                                          Found in tools/perf/scripts/python/sched-migration.py and 4 other locations - About 2 hrs to fix
                                          tools/perf/scripts/python/sched-migration.py on lines 44..53
                                          tools/perf/scripts/python/sched-migration.py on lines 66..75
                                          tools/perf/scripts/python/sched-migration.py on lines 77..86
                                          tools/perf/scripts/python/sched-migration.py on lines 88..97

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

                                          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

                                          class RunqueueEventSleep:
                                              @staticmethod
                                              def color():
                                                  return (0, 0, 0xff)
                                          
                                          
                                          Severity: Major
                                          Found in tools/perf/scripts/python/sched-migration.py and 4 other locations - About 2 hrs to fix
                                          tools/perf/scripts/python/sched-migration.py on lines 55..64
                                          tools/perf/scripts/python/sched-migration.py on lines 66..75
                                          tools/perf/scripts/python/sched-migration.py on lines 77..86
                                          tools/perf/scripts/python/sched-migration.py on lines 88..97

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

                                          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 sched__sched_wakeup_new(event_name, context, common_cpu,
                                              common_secs, common_nsecs, common_pid, common_comm,
                                              common_callchain, comm, pid, prio, success,
                                              target_cpu):
                                              headers = EventHeaders(common_cpu, common_secs, common_nsecs,
                                          Severity: Major
                                          Found in tools/perf/scripts/python/sched-migration.py and 1 other location - About 1 hr to fix
                                          tools/perf/scripts/python/sched-migration.py on lines 438..444

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

                                          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 sched__sched_wakeup(event_name, context, common_cpu,
                                              common_secs, common_nsecs, common_pid, common_comm,
                                              common_callchain, comm, pid, prio, success,
                                              target_cpu):
                                              headers = EventHeaders(common_cpu, common_secs, common_nsecs,
                                          Severity: Major
                                          Found in tools/perf/scripts/python/sched-migration.py and 1 other location - About 1 hr to fix
                                          tools/perf/scripts/python/sched-migration.py on lines 430..436

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

                                          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