fossasia/knittingpattern

View on GitHub

Showing 33 of 166 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

          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

            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

              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

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

                """Test the layout of knitting patterns."""
                from test_convert import fixture
                import os
                from knittingpattern.convert.Layout import GridLayout, InstructionInGrid
                from knittingpattern import load_from_relative_file
                Severity: Minor
                Found in knittingpattern/convert/test/test_layout.py - About 2 hrs to fix

                  Function test_disconnected_from has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  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:
                  Severity: Minor
                  Found in knittingpattern/test/test_change_row_mapping.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 insert_defs has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def insert_defs(self, defs):
                          """Adds the defs to the SVG structure.
                  
                          :param defs: a list of SVG dictionaries, which contain the defs,
                            which should be added to the SVG structure.
                  Severity: Minor
                  Found in knittingpattern/convert/SVGBuilder.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 10 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def __init__(self,
                  Severity: Major
                  Found in knittingpattern/ParsingSpecification.py - About 1 hr to fix

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

                    def walk(knitting_pattern):
                        """Walk the knitting pattern in a right-to-left fashion.
                    
                        :return: an iterable to walk the rows
                        :rtype: list
                    Severity: Minor
                    Found in knittingpattern/walk.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 convert_image_to_knitting_pattern has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def convert_image_to_knitting_pattern(path, colors=("white", "black")):
                        """Load a image file such as a png bitmap of jpeg file and convert it
                        to a :ref:`knitting pattern file <FileFormatSpecification>`.
                    
                        :param list colors: a list of strings that should be used as
                    Severity: Minor
                    Found in knittingpattern/convert/image_to_knittingpattern.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 walk_connections has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def walk_connections(self, mapping=identity):
                            """Iterate over connections between instructions.
                    
                            :return: an iterator over :class:`connections <Connection>` between
                              :class:`instructions in grid <InstructionInGrid>`
                    Severity: Minor
                    Found in knittingpattern/convert/Layout.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 construct_graph has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def construct_graph(links):
                        pattern = new_knitting_pattern("constructed_graph")
                        rows = pattern.rows
                        for link in links:
                            for row_id in link:
                    Severity: Minor
                    Found in knittingpattern/test/test_walk.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 test_replace_a_connection has 7 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    def test_replace_a_connection(disconnect, connect, mesh21p, mesh31c, mesh12p,
                    Severity: Major
                    Found in knittingpattern/test/test_change_row_mapping.py - About 50 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if style:
                                                  style = style.split(";")
                                                  processed_style = []
                                                  for style_element in style:
                                                      if style_element.startswith("fill:"):
                      Severity: Major
                      Found in knittingpattern/convert/InstructionToSVG.py - About 45 mins to fix

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

                            def place_svg_use_coords(self, x, y, symbol_id, layer_id, group=None):
                        Severity: Minor
                        Found in knittingpattern/convert/SVGBuilder.py - About 35 mins to fix

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

                              def __init__(self, min_x, min_y, max_x, max_y,
                          Severity: Minor
                          Found in knittingpattern/convert/AYABPNGBuilder.py - About 35 mins to fix
                            Severity
                            Category
                            Status
                            Source
                            Language