hackedteam/vector-edk

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

Summary

Maintainability
F
2 mos
Test Coverage

Function _parse has a Cognitive Complexity of 355 (exceeds 5 allowed). Consider refactoring.
Open

def _parse(source, state):
    # parse a simple pattern
    subpattern = SubPattern(state)

    # precompute constants into local variables
Severity: Minor
Found in vector-uefi/fd/efi/StdLib/lib/python.27/sre_parse.py - About 1 wk 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 parse_template has a Cognitive Complexity of 91 (exceeds 5 allowed). Consider refactoring.
Open

def parse_template(source, pattern):
    # parse 're' replacement string into list of literals and
    # group references
    s = Tokenizer(source)
    sget = s.get
Severity: Minor
Found in vector-uefi/fd/efi/StdLib/lib/python.27/sre_parse.py - About 1 day 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

File sre_parse.py has 671 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#
# Secret Labs' Regular Expression Engine
#
# convert re-style regular expression to sre pattern
#
Severity: Major
Found in vector-uefi/fd/efi/StdLib/lib/python.27/sre_parse.py - About 1 day to fix

    Function dump has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

        def dump(self, level=0):
            nl = 1
            seqtypes = type(()), type([])
            for op, av in self.data:
                print level*"  " + op,; nl = 0
    Severity: Minor
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/sre_parse.py - About 4 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 _parse_sub has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

    def _parse_sub(source, state, nested=1):
        # parse an alternation: a|b|c
    
        items = []
        itemsappend = items.append
    Severity: Minor
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/sre_parse.py - About 4 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 _escape has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

    def _escape(source, escape, state):
        # handle escape code in expression
        code = CATEGORIES.get(escape)
        if code:
            return code
    Severity: Minor
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/sre_parse.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 _class_escape has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def _class_escape(source, escape):
        # handle escape code inside character class
        code = ESCAPES.get(escape)
        if code:
            return code
    Severity: Minor
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/sre_parse.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 getwidth has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def getwidth(self):
            # determine the width (min, max) for this subpattern
            if self.width:
                return self.width
            lo = hi = 0L
    Severity: Minor
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/sre_parse.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

    Avoid deeply nested control flow statements.
    Open

                        while 1:
                            if source.next is None or source.next == ")":
                                break
                            sourceget()
                        if not sourcematch(")"):
    Severity: Major
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/sre_parse.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if isname(condname):
                              condgroup = state.groupdict.get(condname)
                              if condgroup is None:
                                  raise error, "unknown group name"
                          else:
      Severity: Major
      Found in vector-uefi/fd/efi/StdLib/lib/python.27/sre_parse.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if code1[0] is IN:
                                code1 = code1[1][0]
                            setappend(code1)
        Severity: Major
        Found in vector-uefi/fd/efi/StdLib/lib/python.27/sre_parse.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              while 1:
                                  char = sourceget()
                                  if char is None:
                                      raise error, "unterminated name"
                                  if char == ")":
          Severity: Major
          Found in vector-uefi/fd/efi/StdLib/lib/python.27/sre_parse.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if not source.next in FLAGS:
                                    raise error, "unexpected end of pattern"
                                while source.next in FLAGS:
            Severity: Major
            Found in vector-uefi/fd/efi/StdLib/lib/python.27/sre_parse.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  while 1:
                                      char = sget()
                                      if char is None:
                                          raise error, "unterminated group name"
                                      if char == ">":
              Severity: Major
              Found in vector-uefi/fd/efi/StdLib/lib/python.27/sre_parse.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if not nl: print
                                        a.dump(level+1); nl = 1
                Severity: Major
                Found in vector-uefi/fd/efi/StdLib/lib/python.27/sre_parse.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if char is None:
                                          raise error, "unexpected end of pattern"
                                      if char == ")":
                  Severity: Major
                  Found in vector-uefi/fd/efi/StdLib/lib/python.27/sre_parse.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        while source.next in DIGITS:
                                            hi = hi + sourceget()
                                    else:
                    Severity: Major
                    Found in vector-uefi/fd/efi/StdLib/lib/python.27/sre_parse.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          if char == "<":
                                              if source.next not in LOOKBEHINDASSERTCHARS:
                                                  raise error, "syntax error"
                                              dir = -1 # lookbehind
                                              char = sourceget()
                      Severity: Major
                      Found in vector-uefi/fd/efi/StdLib/lib/python.27/sre_parse.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                            if char == ")":
                                                break
                                            raise error, "unknown extension"
                        Severity: Major
                        Found in vector-uefi/fd/efi/StdLib/lib/python.27/sre_parse.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                              if this in (None, "\n"):
                                                  break
                                          continue
                          Severity: Major
                          Found in vector-uefi/fd/efi/StdLib/lib/python.27/sre_parse.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                if not sourcematch(")"):
                                                    raise error, "unbalanced parenthesis"
                                                continue
                            Severity: Major
                            Found in vector-uefi/fd/efi/StdLib/lib/python.27/sre_parse.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                  if not sourcematch(")"):
                                                      raise error, "unbalanced parenthesis"
                                                  if char == "=":
                              Severity: Major
                              Found in vector-uefi/fd/efi/StdLib/lib/python.27/sre_parse.py - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                    if (c in OCTDIGITS and this[2] in OCTDIGITS and
                                                        s.next in OCTDIGITS):
                                                        this = this + sget()
                                                        isoctal = True
                                                        literal(makechar(int(this[1:], 8) & 0xff))
                                Severity: Major
                                Found in vector-uefi/fd/efi/StdLib/lib/python.27/sre_parse.py - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                      if this == "]":
                                                          if code1[0] is IN:
                                                              code1 = code1[1][0]
                                                          setappend(code1)
                                                          setappend((LITERAL, ord("-")))
                                  Severity: Major
                                  Found in vector-uefi/fd/efi/StdLib/lib/python.27/sre_parse.py - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                                        while source.next in FLAGS:
                                                            state.flags = state.flags | FLAGS[sourceget()]
                                                if group:
                                    Severity: Major
                                    Found in vector-uefi/fd/efi/StdLib/lib/python.27/sre_parse.py - About 45 mins to fix

                                      Avoid deeply nested control flow statements.
                                      Open

                                                          if s.next in OCTDIGITS:
                                                              this = this + sget()
                                                      literal(makechar(int(this[1:], 8) & 0xff))
                                      Severity: Major
                                      Found in vector-uefi/fd/efi/StdLib/lib/python.27/sre_parse.py - About 45 mins to fix

                                        Avoid deeply nested control flow statements.
                                        Open

                                                            if sourcematch("<"):
                                                                # named group: skip forward to end of name
                                                                name = ""
                                                                while 1:
                                                                    char = sourceget()
                                        Severity: Major
                                        Found in vector-uefi/fd/efi/StdLib/lib/python.27/sre_parse.py - About 45 mins to fix

                                          Avoid deeply nested control flow statements.
                                          Open

                                                              if char == "=":
                                                                  subpatternappend((ASSERT, (dir, p)))
                                                              else:
                                                                  subpatternappend((ASSERT_NOT, (dir, p)))
                                                              continue
                                          Severity: Major
                                          Found in vector-uefi/fd/efi/StdLib/lib/python.27/sre_parse.py - About 45 mins to fix

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

                                            def parse(str, flags=0, pattern=None):
                                                # parse 're' pattern into list of (opcode, argument) tuples
                                            
                                                source = Tokenizer(str)
                                            
                                            Severity: Minor
                                            Found in vector-uefi/fd/efi/StdLib/lib/python.27/sre_parse.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 LITERAL, ord(escape[1])
                                            Severity: Major
                                            Found in vector-uefi/fd/efi/StdLib/lib/python.27/sre_parse.py - About 30 mins to fix

                                              Avoid too many return statements within this function.
                                              Open

                                                                  return LITERAL, int(escape[1:], 8) & 0xff
                                              Severity: Major
                                              Found in vector-uefi/fd/efi/StdLib/lib/python.27/sre_parse.py - About 30 mins to fix

                                                Avoid too many return statements within this function.
                                                Open

                                                                return GROUPREF, group
                                                Severity: Major
                                                Found in vector-uefi/fd/efi/StdLib/lib/python.27/sre_parse.py - About 30 mins to fix

                                                  Avoid too many return statements within this function.
                                                  Open

                                                              return LITERAL, ord(escape[1])
                                                  Severity: Major
                                                  Found in vector-uefi/fd/efi/StdLib/lib/python.27/sre_parse.py - About 30 mins to fix

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

                                                    def _parse_sub_cond(source, state, condgroup):
                                                        item_yes = _parse(source, state)
                                                        if source.match("|"):
                                                            item_no = _parse(source, state)
                                                            if source.match("|"):
                                                    Severity: Minor
                                                    Found in vector-uefi/fd/efi/StdLib/lib/python.27/sre_parse.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/sre_parse.py and 1 other location - About 2 mos to fix
                                                    AppPkg/Applications/Python/Python-2.7.2/Lib/sre_parse.py on lines 0..790

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

                                                    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