hackedteam/vector-edk

View on GitHub
vector-uefi/fd/efi/StdLib/lib/python.27/pstats.py

Summary

Maintainability
F
1 mo
Test Coverage

File pstats.py has 575 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""Class for printing reports on profiled python code."""

# Class for printing reports on profiled python code. rev 1.0  4/1/94
#
# Based on prior profile module by Sjoerd Mullender...
Severity: Major
Found in vector-uefi/fd/efi/StdLib/lib/python.27/pstats.py - About 1 day to fix

    ProfileBrowser has 26 functions (exceeds 20 allowed). Consider refactoring.
    Open

        class ProfileBrowser(cmd.Cmd):
            def __init__(self, profile=None):
                cmd.Cmd.__init__(self)
                self.prompt = "% "
                self.stats = None
    Severity: Minor
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/pstats.py - About 3 hrs to fix

      Function get_sort_arg_defs has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_sort_arg_defs(self):
              """Expand all abbreviations that are unique."""
              if not self.sort_arg_dict:
                  self.sort_arg_dict = dict = {}
                  bad_list = {}
      Severity: Minor
      Found in vector-uefi/fd/efi/StdLib/lib/python.27/pstats.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 generic has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

              def generic(self, fn, line):
                  args = line.split()
                  processed = []
                  for term in args:
                      try:
      Severity: Minor
      Found in vector-uefi/fd/efi/StdLib/lib/python.27/pstats.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 eval_print_amount has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def eval_print_amount(self, sel, list, msg):
              new_list = list
              if isinstance(sel, basestring):
                  try:
                      rex = re.compile(sel)
      Severity: Minor
      Found in vector-uefi/fd/efi/StdLib/lib/python.27/pstats.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 do_read has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

              def do_read(self, line):
                  if line:
                      try:
                          self.stats = Stats(line)
                      except IOError, args:
      Severity: Minor
      Found in vector-uefi/fd/efi/StdLib/lib/python.27/pstats.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 add has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def add(self, *arg_list):
              if not arg_list: return self
              if len(arg_list) > 1: self.add(*arg_list[1:])
              other = arg_list[0]
              if type(self) != type(other) or self.__class__ != other.__class__:
      Severity: Minor
      Found in vector-uefi/fd/efi/StdLib/lib/python.27/pstats.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 get_print_list has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_print_list(self, sel_list):
              width = self.max_name_len
              if self.fcn_list:
                  stat_list = self.fcn_list[:]
                  msg = "   Ordered by: " + self.sort_type + '\n'
      Severity: Minor
      Found in vector-uefi/fd/efi/StdLib/lib/python.27/pstats.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 calc_callees has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def calc_callees(self):
              if self.all_callees: return
              self.all_callees = all_callees = {}
              for func, (cc, nc, tt, ct, callers) in self.stats.iteritems():
                  if not func in all_callees:
      Severity: Minor
      Found in vector-uefi/fd/efi/StdLib/lib/python.27/pstats.py - About 55 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 add_callers has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      def add_callers(target, source):
          """Combine two caller lists in a single list."""
          new_callers = {}
          for func, caller in target.iteritems():
              new_callers[func] = caller
      Severity: Minor
      Found in vector-uefi/fd/efi/StdLib/lib/python.27/pstats.py - About 55 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 print_call_line has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def print_call_line(self, name_size, source, call_dict, arrow="->"):
              print >> self.stream, func_std_string(source).ljust(name_size) + arrow,
              if not call_dict:
                  print >> self.stream
                  return
      Severity: Minor
      Found in vector-uefi/fd/efi/StdLib/lib/python.27/pstats.py - About 55 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 do_sort has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

              def do_sort(self, line):
                  if not self.stats:
                      print >> self.stream, "No statistics object is loaded."
                      return
                  abbrevs = self.stats.get_sort_arg_defs()
      Severity: Minor
      Found in vector-uefi/fd/efi/StdLib/lib/python.27/pstats.py - About 55 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 strip_dirs has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def strip_dirs(self):
              oldstats = self.stats
              self.stats = newstats = {}
              max_name_len = 0
              for func, (cc, nc, tt, ct, callers) in oldstats.iteritems():
      Severity: Minor
      Found in vector-uefi/fd/efi/StdLib/lib/python.27/pstats.py - About 55 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 print_stats has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def print_stats(self, *amount):
              for filename in self.files:
                  print >> self.stream, filename
              if self.files: print >> self.stream
              indent = ' ' * 8
      Severity: Minor
      Found in vector-uefi/fd/efi/StdLib/lib/python.27/pstats.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

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

          def print_callees(self, *amount):
              width, list = self.get_print_list(amount)
              if list:
                  self.calc_callees()
      
      Severity: Minor
      Found in vector-uefi/fd/efi/StdLib/lib/python.27/pstats.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

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

          def load_stats(self, arg):
              if not arg:  self.stats = {}
              elif isinstance(arg, basestring):
                  f = open(arg, 'rb')
                  self.stats = marshal.load(f)
      Severity: Minor
      Found in vector-uefi/fd/efi/StdLib/lib/python.27/pstats.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

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

          def sort_stats(self, *field):
              if not field:
                  self.fcn_list = 0
                  return self
              if len(field) == 1 and isinstance(field[0], (int, long)):
      Severity: Minor
      Found in vector-uefi/fd/efi/StdLib/lib/python.27/pstats.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

      Severity: Major
      Found in vector-uefi/fd/efi/StdLib/lib/python.27/pstats.py and 1 other location - About 1 mo to fix
      AppPkg/Applications/Python/Python-2.7.2/Lib/pstats.py on lines 0..710

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

      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