avocado-framework/avocado

View on GitHub
avocado/utils/external/spark.py

Summary

Maintainability
F
6 days
Test Coverage
F
13%

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Open

        assert 0
Severity: Info
Found in avocado/utils/external/spark.py by bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Open

        assert sym is not None
        #
        #  Compute \epsilon-kernel state's core and see if
        #  it exists already.
        #
Severity: Info
Found in avocado/utils/external/spark.py by bandit

File spark.py has 580 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#  Copyright (c) 1998-2002 John Aycock
#
#  Permission is hereby granted, free of charge, to any person obtaining
#  a copy of this software and associated documentation files (the
#  "Software"), to deal in the Software without restriction, including
Severity: Major
Found in avocado/utils/external/spark.py - About 1 day to fix

    Function makeSet_fast has a Cognitive Complexity of 61 (exceeds 5 allowed). Consider refactoring.
    Open

        def makeSet_fast(self, token, sets, i):
            #
            #  Call *only* when the entire state machine has been built!
            #  It relies on self.edges being filled in completely, and
            #  then duplicates and inlines code to boost speed at the
    Severity: Minor
    Found in avocado/utils/external/spark.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

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

        def makeState(self, state, sym):
            assert sym is not None
            #
            #  Compute \epsilon-kernel state's core and see if
            #  it exists already.
    Severity: Minor
    Found in avocado/utils/external/spark.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 makeSet has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

        def makeSet(self, token, sets, i):
            cur, next_item = sets[i], sets[i + 1]
    
            ttype = (  # pylint: disable=R1709
                token is not None and self.typestring(token) or None
    Severity: Minor
    Found in avocado/utils/external/spark.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 computeNull has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

        def computeNull(self):
            self.nullable = {}  # pylint: disable=W0201
            tbd = []
    
            for rulelist in self.rules.values():
    Severity: Minor
    Found in avocado/utils/external/spark.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

    GenericParser has 29 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class GenericParser:
        #
        #  An Earley parser, as per J. Earley, "An Efficient Context-Free
        #  Parsing Algorithm", CACM 13(2), pp. 94-102.  Also J. C. Earley,
        #  "An Efficient Context-Free Parsing Algorithm", Ph.D. thesis,
    Severity: Minor
    Found in avocado/utils/external/spark.py - About 3 hrs to fix

      Function makeNewRules has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          def makeNewRules(self):
              worklist = []
              for rulelist in self.rules.values():
                  for rule in rulelist:
                      worklist.append((rule, 0, 1, rule))
      Severity: Minor
      Found in avocado/utils/external/spark.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 buildTree has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def buildTree(self, nt, item, tokens, k):
              state, _ = item
      
              choices = []
              for rule in self.states[state].complete:
      Severity: Minor
      Found in avocado/utils/external/spark.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 __getstate__ has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def __getstate__(self):
              if self.ruleschanged:
                  #
                  #  FIX ME - duplicated from parse()
                  #
      Severity: Minor
      Found in avocado/utils/external/spark.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 addRule has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def addRule(self, doc, func, _preprocess=1):
              fn = func
              rules = doc.split()
      
              index = []
      Severity: Minor
      Found in avocado/utils/external/spark.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 parse has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def parse(self, tokens):
              sets = [[(1, 0), (2, 0)]]
              self.links = {}  # pylint: disable=W0201
      
              if self.ruleschanged:
      Severity: Minor
      Found in avocado/utils/external/spark.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

      Avoid deeply nested control flow statements.
      Open

                              if new not in next_item:
                                  next_item.append(new)
                              # INLINED --^
                  else:
      Severity: Major
      Found in avocado/utils/external/spark.py - About 45 mins to fix

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

            def tokenize(self, s):
                pos = 0
                n = len(s)
                while pos < n:
                    m = self.re.match(s, pos)
        Severity: Minor
        Found in avocado/utils/external/spark.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

        Avoid deeply nested control flow statements.
        Open

                                for prule in rules[nextSym]:
                                    ppos = self.skip(prule)
                                    new = (prule, ppos)
                                    NK.items.append(new)
                    #
        Severity: Major
        Found in avocado/utils/external/spark.py - About 45 mins to fix

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

          def _namelist(instance):
              namelist, namedict, classlist = [], {}, [instance.__class__]
              for c in classlist:
                  for b in c.__bases__:
                      classlist.append(b)  # pylint: disable=W4701
          Severity: Minor
          Found in avocado/utils/external/spark.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

          Avoid deeply nested control flow statements.
          Open

                                  if nk is not None:
                                      self.add(cur, (nk, i))
          
          
          Severity: Major
          Found in avocado/utils/external/spark.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if new not in cur:
                                        self.links[key] = []
                                        cur.append(new)
                                    self.links[key].append((pptr, why))
            Severity: Major
            Found in avocado/utils/external/spark.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if nk is not None:
                                          # self.add(cur, (nk, i))
                                          # INLINED --v
                                          new = (nk, i)
                                          if new not in cur:
              Severity: Major
              Found in avocado/utils/external/spark.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if nk is not None:
                                            self.add(next_item, (nk, i + 1))
                
                
                Severity: Major
                Found in avocado/utils/external/spark.py - About 45 mins to fix

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

                      def add(self, input_set, item, i=None, predecessor=None, causal=None):
                  Severity: Minor
                  Found in avocado/utils/external/spark.py - About 35 mins to fix

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

                        def preorder(self, node=None):
                            if node is None:
                                node = self.ast
                    
                            try:
                    Severity: Minor
                    Found in avocado/utils/external/spark.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 add has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def add(self, input_set, item, i=None, predecessor=None, causal=None):
                            if predecessor is None:
                                if item not in input_set:
                                    input_set.append(item)
                            else:
                    Severity: Minor
                    Found in avocado/utils/external/spark.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

                    There are no issues that match your filters.

                    Category
                    Status