piccolbo/Pweave

View on GitHub
pweave/formatters/base.py

Summary

Maintainability
D
2 days
Test Coverage

PwebFormatter has 33 functions (exceeds 20 allowed). Consider refactoring.
Open

class PwebFormatter(object):
    """Base class for all not-notebook formatters"""

    def __init__(
        self,
Severity: Minor
Found in pweave/formatters/base.py - About 4 hrs to fix

    Function format has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        def format(self):
            self.formatted = []
            for chunk in self.executed:
                # Fill in options for code chunks
                if chunk["type"] == "code":
    Severity: Minor
    Found in pweave/formatters/base.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 format_codechunks has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        def format_codechunks(self, chunk):
            chunk["content"] = self._indent(chunk["content"])
    
            # Code is not executed
            if not chunk["evaluate"]:
    Severity: Minor
    Found in pweave/formatters/base.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

    File base.py has 262 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import textwrap
    import os
    import base64
    import copy
    from nbconvert import filters
    Severity: Minor
    Found in pweave/formatters/base.py - About 2 hrs to fix

      Function render_jupyter_output has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def render_jupyter_output(self, out, chunk):
              if out["output_type"] == "error":
                  return self.render_traceback("".join(out["traceback"]), chunk)
      
              if out["output_type"] == "stream":
      Severity: Minor
      Found in pweave/formatters/base.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 9 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(
      Severity: Major
      Found in pweave/formatters/base.py - About 1 hr to fix

        Function format_text_result has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def format_text_result(self, text, chunk):
                chunk["result"] = text
                result = ""
                if "%s" in chunk["outputstart"]:
                    chunk["outputstart"] = chunk["outputstart"] % self.language
        Severity: Minor
        Found in pweave/formatters/base.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 figures_from_chunk has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def figures_from_chunk(self, chunk):
                """Extract base64 encoded figures from chunk"""
                figs = []
                i = 1
                for out in chunk["result"]:
        Severity: Minor
        Found in pweave/formatters/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

        Avoid too many return statements within this function.
        Open

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

          Avoid too many return statements within this function.
          Open

                      return self.render_text(out["data"]["text/plain"], chunk)
          Severity: Major
          Found in pweave/formatters/base.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

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

              There are no issues that match your filters.

              Category
              Status