ducminh-phan/reformat-gherkin

View on GitHub

Showing 16 of 16 total issues

File formatter.py has 373 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from itertools import chain, groupby
from typing import (
    Any,
    Callable,
    Dict,
Severity: Minor
Found in reformat_gherkin/formatter.py - About 4 hrs to fix

    Function __find_nodes_within_rules has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def __find_nodes_within_rules(self) -> Set[Node]:
            nodes_within_rules: Set[Node] = set()
    
            feature = self.ast.feature
            if feature is not None:
    Severity: Minor
    Found in reformat_gherkin/formatter.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 __construct_contexts has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def __construct_contexts(self) -> ContextMap:
            """
            Construct the information about the context a certain line might need to know to
            properly format these lines.
            """
    Severity: Minor
    Found in reformat_gherkin/formatter.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 main has 10 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def main(
    Severity: Major
    Found in reformat_gherkin/cli.py - About 1 hr to fix

      Function __find_nodes_with_newline has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def __find_nodes_with_newline(self) -> Set[Node]:
              """
              Find all nodes in the AST that needs a new line after it.
              """
      
      
      Severity: Minor
      Found in reformat_gherkin/formatter.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 __str__ has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def __str__(self) -> str:
              """Render a color report of the current state.
      
              Use `click.unstyle` to remove colors.
              """
      Severity: Minor
      Found in reformat_gherkin/report.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 find_project_root has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      def find_project_root(srcs: Iterable[str]) -> Path:
          """
          Return a directory containing .git, .hg, or .reformat-gherkin.yaml.
      
          That directory can be one of the directories passed in `srcs` or their
      Severity: Minor
      Found in reformat_gherkin/config.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

      Avoid deeply nested control flow statements.
      Open

                              if not isinstance(node, Rule):
                                  nodes_within_rules.add(node)
      
      
      Severity: Major
      Found in reformat_gherkin/formatter.py - About 45 mins to fix

        Function generate_step_line has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def generate_step_line(
        Severity: Minor
        Found in reformat_gherkin/formatter.py - About 45 mins to fix

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

          def reformat_stream_or_path(
          Severity: Minor
          Found in reformat_gherkin/core.py - About 35 mins to fix

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

            def read_config_file(
                ctx: click.Context,
                _: click.Parameter,
                value: Optional[str],
            ) -> Optional[str]:
            Severity: Minor
            Found in reformat_gherkin/config.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 __construct_contexts_for_comments has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def __construct_contexts_for_comments(nodes: List[Node]) -> ContextMap:
                    # The context of each comment line is the next non-comment line.
                    #
                    # The steps of the algorithm:
                    # 1. Group the nodes into comments and non-comments
            Severity: Minor
            Found in reformat_gherkin/formatter.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

            Avoid too many return statements within this function.
            Open

                return directory  # pragma: no cover
            Severity: Major
            Found in reformat_gherkin/config.py - About 30 mins to fix

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

                  def __group_tags(self):
                      """
                      Group the tags of a node, so that we can render them on a single line.
                      """
              
              
              Severity: Minor
              Found in reformat_gherkin/formatter.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

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

              def reformat(src: Tuple[str], report: Report, *, options: Options):
                  use_stdin = "-" in src
                  sources = find_sources(filter((lambda it: it != "-"), src))
              
                  if not sources and not use_stdin:
              Severity: Minor
              Found in reformat_gherkin/core.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

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

              def extract_rows(node: Union[DataTable, Examples]) -> List[TableRow]:
                  """
                  Extract table rows from either a Datable or Example instance.
                  """
              
              
              Severity: Minor
              Found in reformat_gherkin/formatter.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

              Severity
              Category
              Status
              Source
              Language