hackedteam/vector-edk

View on GitHub
AppPkg/Applications/Python/Python-2.7.2/Lib/optparse.py

Summary

Maintainability
F
3 mos
Test Coverage

File optparse.py has 1256 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""A powerful, extensible, and easy-to-use option parser.

By Greg Ward <gward@python.net>

Originally distributed as Optik.
Severity: Major
Found in AppPkg/Applications/Python/Python-2.7.2/Lib/optparse.py - About 3 days to fix

    OptionParser has 38 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class OptionParser (OptionContainer):
    
        """
        Class attributes:
          standard_option_list : [Option]
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Lib/optparse.py - About 5 hrs to fix

      Function _check_conflict has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          def _check_conflict(self, option):
              conflict_opts = []
              for opt in option._short_opts:
                  if opt in self._short_opt:
                      conflict_opts.append((opt, self._short_opt[opt]))
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/optparse.py - About 3 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 _process_short_opts has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

          def _process_short_opts(self, rargs, values):
              arg = rargs.pop(0)
              stop = False
              i = 1
              for ch in arg[1:]:
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/optparse.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 _check_type has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          def _check_type(self):
              if self.type is None:
                  if self.action in self.ALWAYS_TYPED_ACTIONS:
                      if self.choices is not None:
                          # The "choices" attribute implies "choice" type.
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/optparse.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 _check_callback has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def _check_callback(self):
              if self.action == "callback":
                  if not hasattr(self.callback, '__call__'):
                      raise OptionError(
                          "callback not callable: %r" % self.callback, self)
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/optparse.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 _process_long_opt has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def _process_long_opt(self, rargs, values):
              arg = rargs.pop(0)
      
              # Value explicitly attached to arg?  Pretend it's the next
              # argument.
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/optparse.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 _set_opt_strings has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def _set_opt_strings(self, opts):
              for opt in opts:
                  if len(opt) < 2:
                      raise OptionError(
                          "invalid option string %r: "
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/optparse.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_option has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def add_option(self, *args, **kwargs):
              """add_option(Option)
                 add_option(opt_str, ..., kwarg=val, ...)
              """
              if type(args[0]) in types.StringTypes:
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/optparse.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 take_action has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def take_action(self, action, dest, opt, value, values, parser):
              if action == "store":
                  setattr(values, dest, value)
              elif action == "store_const":
                  setattr(values, dest, self.const)
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/optparse.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 __init__ has 10 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(self,
      Severity: Major
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/optparse.py - About 1 hr to fix

        Function _set_attrs has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def _set_attrs(self, attrs):
                for attr in self.ATTRS:
                    if attr in attrs:
                        setattr(self, attr, attrs[attr])
                        del attrs[attr]
        Severity: Minor
        Found in AppPkg/Applications/Python/Python-2.7.2/Lib/optparse.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 take_action has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def take_action(self, action, dest, opt, value, values, parser):
        Severity: Minor
        Found in AppPkg/Applications/Python/Python-2.7.2/Lib/optparse.py - About 45 mins to fix

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

              def add_option_group(self, *args, **kwargs):
                  # XXX lots of overlap with OptionContainer.add_option()
                  if type(args[0]) is types.StringType:
                      group = OptionGroup(self, *args, **kwargs)
                  elif len(args) == 1 and not kwargs:
          Severity: Minor
          Found in AppPkg/Applications/Python/Python-2.7.2/Lib/optparse.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 _process_args has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def _process_args(self, largs, rargs, values):
                  """_process_args(largs : [string],
                                   rargs : [string],
                                   values : Values)
          
          Severity: Minor
          Found in AppPkg/Applications/Python/Python-2.7.2/Lib/optparse.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 _update_careful has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def _update_careful(self, dict):
                  """
                  Update the option values from an arbitrary dictionary, but only
                  use keys from dict that already have a corresponding attribute
                  in self.  Any keys in dict without a corresponding attribute
          Severity: Minor
          Found in AppPkg/Applications/Python/Python-2.7.2/Lib/optparse.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 _match_abbrev has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          def _match_abbrev(s, wordmap):
              """_match_abbrev(s : string, wordmap : {string : Option}) -> string
          
              Return the string key in 'wordmap' for which 's' is an unambiguous
              abbreviation.  If 's' is found to be ambiguous or doesn't match any of
          Severity: Minor
          Found in AppPkg/Applications/Python/Python-2.7.2/Lib/optparse.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 _check_dest has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def _check_dest(self):
                  # No destination given, and we need one for this action.  The
                  # self.type check is for callbacks that take a value.
                  takes_value = (self.action in self.STORE_ACTIONS or
                                 self.type is not None)
          Severity: Minor
          Found in AppPkg/Applications/Python/Python-2.7.2/Lib/optparse.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 AppPkg/Applications/Python/Python-2.7.2/Lib/optparse.py and 1 other location - About 2 mos to fix
          vector-uefi/fd/efi/StdLib/lib/python.27/optparse.py on lines 0..1703

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

          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