fossasia/knittingpattern

View on GitHub

Showing 150 of 150 total issues

File Instruction.py has 469 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""Knitting patterns consist of instructions.

The :class:`instructions <Instruction>`. that are used in the
:class:`knitting patterns <KnittingPattern>` can be foudn in this module.
They have certain attributes in common.
Severity: Minor
Found in knittingpattern/Instruction.py - About 7 hrs to fix

    Function _set_fills_in_color_layer has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
    Open

        def _set_fills_in_color_layer(self, svg_string, color):
            """replaces fill colors in ``<g inkscape:label="color"
            inkscape:groupmode="layer">`` with :paramref:`color`
    
            :param color: a color fill the objects in the layer with
    Severity: Minor
    Found in knittingpattern/convert/InstructionToSVG.py - About 6 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

    TestAddAndRemoveMeshes has 41 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class TestAddAndRemoveMeshes(BaseTest):
        """take away and add meshes at the right and left."""
        FILE = "add and remove meshes.json"
        SIZES = [(1, 1)] * 17
        COORDINATES = [
    Severity: Minor
    Found in knittingpattern/convert/test/test_layout.py - About 5 hrs to fix

      File Mesh.py has 391 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      """This module contains the meshes of the knit work."""
      from abc import ABCMeta, abstractmethod
      
      
      class Mesh(metaclass=ABCMeta):
      Severity: Minor
      Found in knittingpattern/Mesh.py - About 5 hrs to fix

        Mesh has 34 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class Mesh(metaclass=ABCMeta):
        
            """A mesh that is either consumed or produced by an instruction.
        
            .. code:: python
        Severity: Minor
        Found in knittingpattern/Mesh.py - About 4 hrs to fix

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

          class TextWrapper(object):
              """Use this class if you have a binary-file but you want to
              write strings to it.
              """
          
          
          Severity: Major
          Found in knittingpattern/Dumper/FileWrapper.py and 1 other location - About 3 hrs to fix
          knittingpattern/Dumper/FileWrapper.py on lines 7..27

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

          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

          class BytesWrapper(object):
              """Use this class if you have a text-file but you want to
              write bytes to it.
              """
          
          
          Severity: Major
          Found in knittingpattern/Dumper/FileWrapper.py and 1 other location - About 3 hrs to fix
          knittingpattern/Dumper/FileWrapper.py on lines 30..50

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

          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

          Cyclomatic complexity is too high in method _set_fills_in_color_layer. (15)
          Open

              def _set_fills_in_color_layer(self, svg_string, color):
                  """replaces fill colors in ``<g inkscape:label="color"
                  inkscape:groupmode="layer">`` with :paramref:`color`
          
                  :param color: a color fill the objects in the layer with

          Cyclomatic Complexity

          Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

          Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

          Construct Effect on CC Reasoning
          if +1 An if statement is a single decision.
          elif +1 The elif statement adds another decision.
          else +0 The else statement does not cause a new decision. The decision is at the if.
          for +1 There is a decision at the start of the loop.
          while +1 There is a decision at the while statement.
          except +1 Each except branch adds a new conditional path of execution.
          finally +0 The finally block is unconditionally executed.
          with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
          assert +1 The assert statement internally roughly equals a conditional statement.
          Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
          Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

          Source: http://radon.readthedocs.org/en/latest/intro.html

          Cyclomatic complexity is too high in function test_skp_consumed_meshes_from_row1. (14)
          Open

          def test_skp_consumed_meshes_from_row1(skp, row1, row2):

          Cyclomatic Complexity

          Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

          Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

          Construct Effect on CC Reasoning
          if +1 An if statement is a single decision.
          elif +1 The elif statement adds another decision.
          else +0 The else statement does not cause a new decision. The decision is at the if.
          for +1 There is a decision at the start of the loop.
          while +1 There is a decision at the while statement.
          except +1 Each except branch adds a new conditional path of execution.
          finally +0 The finally block is unconditionally executed.
          with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
          assert +1 The assert statement internally roughly equals a conditional statement.
          Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
          Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

          Source: http://radon.readthedocs.org/en/latest/intro.html

          InstructionInRow has 27 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class InstructionInRow(Instruction):
          
              """Instructions can be placed in rows.
          
              Then, they have additional attributes and properties.
          Severity: Minor
          Found in knittingpattern/Instruction.py - About 3 hrs to fix

            Cyclomatic complexity is too high in method test_disconnected_from. (14)
            Open

                def test_disconnected_from(self, connections, meshes):
                    """Test all the meshes that are disconnected from each other."""
                    for m1 in meshes:
                        assert m1 == m1
                        for m2 in meshes:

            Cyclomatic Complexity

            Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

            Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

            Construct Effect on CC Reasoning
            if +1 An if statement is a single decision.
            elif +1 The elif statement adds another decision.
            else +0 The else statement does not cause a new decision. The decision is at the if.
            for +1 There is a decision at the start of the loop.
            while +1 There is a decision at the while statement.
            except +1 Each except branch adds a new conditional path of execution.
            finally +0 The finally block is unconditionally executed.
            with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
            assert +1 The assert statement internally roughly equals a conditional statement.
            Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
            Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

            Source: http://radon.readthedocs.org/en/latest/intro.html

            File Layout.py has 295 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            """Map ``(x, y)`` coordinates to instructions
            
            """
            from itertools import chain
            from collections import namedtuple
            Severity: Minor
            Found in knittingpattern/convert/Layout.py - About 3 hrs to fix

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

                  @property
                  def rows_before(self):
                      """The rows that produce meshes for this row.
              
                      :rtype: list
              Severity: Major
              Found in knittingpattern/Row.py and 1 other location - About 2 hrs to fix
              knittingpattern/Row.py on lines 224..239

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

              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

                  @property
                  def rows_after(self):
                      """The rows that consume meshes from this row.
              
                      :rtype: list
              Severity: Major
              Found in knittingpattern/Row.py and 1 other location - About 2 hrs to fix
              knittingpattern/Row.py on lines 207..222

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

              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

              def test_removed_instruction_raises_exception(removed_instruction):
                  with raises(InstructionNotFoundInRow):
                      removed_instruction.index_of_first_produced_mesh_in_row
                  with raises(InstructionNotFoundInRow):
                      removed_instruction.index_of_last_produced_mesh_in_row
              Severity: Major
              Found in knittingpattern/test/test_row_instructions.py and 1 other location - About 2 hrs to fix
              knittingpattern/test/test_row_meshes.py on lines 34..42

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

              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

              def test_no_meshes(row):
                  with raises(IndexError):
                      row.first_consumed_mesh
                  with raises(IndexError):
                      row.last_consumed_mesh
              Severity: Major
              Found in knittingpattern/test/test_row_meshes.py and 1 other location - About 2 hrs to fix
              knittingpattern/test/test_row_instructions.py on lines 222..230

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

              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

              Cyclomatic complexity is too high in function test_remove_a_connection. (10)
              Open

              def test_remove_a_connection(row1, row2, mesh11p, mesh21c, disconnect):
                  disconnect_meshes(mesh11p, mesh21c, disconnect)
                  assert mesh11p.is_produced()
                  assert not mesh11p.is_consumed()
                  assert mesh11p.producing_row == row1

              Cyclomatic Complexity

              Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

              Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

              Construct Effect on CC Reasoning
              if +1 An if statement is a single decision.
              elif +1 The elif statement adds another decision.
              else +0 The else statement does not cause a new decision. The decision is at the if.
              for +1 There is a decision at the start of the loop.
              while +1 There is a decision at the while statement.
              except +1 Each except branch adds a new conditional path of execution.
              finally +0 The finally block is unconditionally executed.
              with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
              assert +1 The assert statement internally roughly equals a conditional statement.
              Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
              Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

              Source: http://radon.readthedocs.org/en/latest/intro.html

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

                  @property
                  def index_of_first_produced_mesh_in_row(self):
                      """Index of the first produced mesh in the row that consumes it.
              
                      :return: an index of the first produced mesh of rows produced meshes
              Severity: Major
              Found in knittingpattern/Instruction.py and 1 other location - About 2 hrs to fix
              knittingpattern/Instruction.py on lines 458..472

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

              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

                  @property
                  def index_of_first_consumed_mesh_in_row(self):
                      """The index of the first consumed mesh of this instruction in its row.
              
                      Same as :attr:`index_of_first_produced_mesh_in_row`
              Severity: Major
              Found in knittingpattern/Instruction.py and 1 other location - About 2 hrs to fix
              knittingpattern/Instruction.py on lines 412..438

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

              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

              Parser has 22 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class Parser(object):
              
                  """Parses a knitting pattern set and anything in it."""
              
                  def __init__(self, specification):
              Severity: Minor
              Found in knittingpattern/Parser.py - About 2 hrs to fix
                Severity
                Category
                Status
                Source
                Language