piccolbo/Pweave

View on GitHub

Showing 86 of 86 total issues

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

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

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

        if len(sys.argv) == 1:
            print(
                "Publish a python script. Part of Pweave %s, use -h for help"
                % pweave.__version__
            )
    Severity: Major
    Found in pweave/scripts.py and 3 other locations - About 40 mins to fix
    pweave/scripts.py on lines 16..18
    pweave/scripts.py on lines 187..189
    pweave/scripts.py on lines 213..218

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

    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

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

        if len(sys.argv) == 1:
            print("This is ptangle %s, enter ptangle -h for help" % pweave.__version__)
            sys.exit()
    Severity: Major
    Found in pweave/scripts.py and 3 other locations - About 40 mins to fix
    pweave/scripts.py on lines 16..18
    pweave/scripts.py on lines 142..147
    pweave/scripts.py on lines 213..218

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

    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

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

        if len(sys.argv) == 1:
            print("This is pweave %s, enter Pweave -h for help" % pweave.__version__)
            sys.exit()
    Severity: Major
    Found in pweave/scripts.py and 3 other locations - About 40 mins to fix
    pweave/scripts.py on lines 142..147
    pweave/scripts.py on lines 187..189
    pweave/scripts.py on lines 213..218

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

    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

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

        if len(sys.argv) == 1:
            print(
                "This is Pweave document converter %s. Enter pweave-convert -h for help "
                % pweave.__version__
            )
    Severity: Major
    Found in pweave/scripts.py and 3 other locations - About 40 mins to fix
    pweave/scripts.py on lines 16..18
    pweave/scripts.py on lines 142..147
    pweave/scripts.py on lines 187..189

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

    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

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

    def convert(
    Severity: Minor
    Found in pweave/__init__.py - About 35 mins to fix

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

      def publish(
      Severity: Minor
      Found in pweave/__init__.py - About 35 mins to fix

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

            def formatfigure(self, chunk):
                fignames = chunk["figure"]
                caption = chunk["caption"]
                width = chunk["width"]
                result = ""
        Severity: Minor
        Found in pweave/formatters/tex.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

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

                        if (
                            read.strip() != "" or "source" in opts
                        ):  # Don't parse empty chunks unless source is specified
                            chunks.append(
                                {
        Severity: Minor
        Found in pweave/readers.py and 1 other location - About 35 mins to fix
        pweave/readers.py on lines 124..131

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

        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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                if m.group(2) == "$$":
                    node.text = markdown.util.AtomicString("\[" + m.group(3) + "\]")
        Severity: Minor
        Found in pweave/formatters/markdownmath.py and 1 other location - About 35 mins to fix
        pweave/formatters/markdownmath.py on lines 11..14

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

        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

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

            def convert(self):
                output = []
        
                if self.outformat == "noweb":
                    code = "<<%s>>=%s\n@\n"
        Severity: Minor
        Found in pweave/readers.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 formatfigure has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def formatfigure(self, chunk):
        
                fignames = chunk["figure"]
        
                if chunk["caption"]:
        Severity: Minor
        Found in pweave/formatters/markdown.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

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

                if self.state == "code":
                    chunks.append(
                        {
                            "type": "code",
                            "content": "\n" + read.rstrip(),
        Severity: Minor
        Found in pweave/readers.py and 1 other location - About 35 mins to fix
        pweave/readers.py on lines 99..108

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

        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

        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 chunks
            Severity: Major
            Found in pweave/processors/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

                Avoid too many return statements within this function.
                Open

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

                  Avoid too many return statements within this function.
                  Open

                          return "markdown"
                  Severity: Major
                  Found in pweave/formatters/__init__.py - About 30 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language