piccolbo/Pweave

View on GitHub
pweave/processors/base.py

Summary

Maintainability
C
1 day
Test Coverage

Function _runcode has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

    def _runcode(self, chunk):
        """Execute code from a code chunk based on options"""
        if chunk["type"] != "doc" and chunk["type"] != "code":
            return chunk

Severity: Minor
Found in pweave/processors/base.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

PwebProcessorBase has 21 functions (exceeds 20 allowed). Consider refactoring.
Open

class PwebProcessorBase(object):
    """Processors run code from parsed Pweave documents. This is an abstract base
    class for specific implementations"""

    def __init__(self, parsed, kernel, source, docmode, figdir, outdir):
Severity: Minor
Found in pweave/processors/base.py - About 2 hrs to fix

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

        def run(self):
            # Create directory for figures
            self.ensureDirectoryExists(self.getFigDirectory())
            # Documentation mode uses results from previous  executions
            # so that compilation is fast if you only work on doc chunks
    Severity: Minor
    Found in pweave/processors/base.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 loadinline has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def loadinline(self, content):
            """Evaluate code from doc chunks using ERB markup"""
            # Flags don't work with ironpython
            splitted = re.split("(<%[\w\s\W]*?%>)", content)  # , flags = re.S)
            # No inline code
    Severity: Minor
    Found in pweave/processors/base.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 __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(self, parsed, kernel, source, docmode, figdir, outdir):
    Severity: Minor
    Found in pweave/processors/base.py - About 45 mins to fix

      Avoid too many return statements within this function.
      Open

                      return chunks
      Severity: Major
      Found in pweave/processors/base.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return chunk
        Severity: Major
        Found in pweave/processors/base.py - About 30 mins to fix

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

              def _getoldresults(self):
                  """Get the results of previous run for documentation mode"""
          
                  success = self.restore()
                  if not success:
          Severity: Minor
          Found in pweave/processors/base.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