QuantLaw/quantlaw

View on GitHub

Showing 21 of 21 total issues

Function quotient_graph has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

def quotient_graph(
    G,
    node_attribute,
    edge_types=["reference", "cooccurrence"],
    self_loops=False,
Severity: Minor
Found in src/quantlaw/utils/networkx.py - About 4 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 get_suffix_and_law_name has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    def get_suffix_and_law_name(self, string: str):
        """
        Returns: A tuple containing length of

            1. the article between numbers and law name (eg. " der ")
Severity: Minor
Found in src/quantlaw/de_extract/statutes_areas.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 statutes_parse.py has 263 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import itertools
from collections import Counter

from regex import regex

Severity: Minor
Found in src/quantlaw/de_extract/statutes_parse.py - About 2 hrs to fix

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

        def parse_law(self, law_text: str, match_type: str, current_lawid: str = None):
            """
            Parses the law information from a references found by StatutesMatchWithMainArea
    
            Args:
    Severity: Minor
    Found in src/quantlaw/de_extract/statutes_parse.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 split_citation_part has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def split_citation_part(string: str):
            """
            A string a tokenizes. Tokens are identified as units or values. Pairs are
            built to connect the units with their respective values. If the unit cannot
            be indentified (and must be inferred later) None is returned.
    Severity: Minor
    Found in src/quantlaw/de_extract/statutes_parse.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 load_law_names has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def load_law_names(date, path):
        r = requests.get(
            f"https://github.com/QuantLaw/gesetze-im-internet/archive/{date}.zip",
            stream=True,
        )
    Severity: Minor
    Found in src/quantlaw/de_extract/load_statute_names.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 split_parts_accidently_joined has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def split_parts_accidently_joined(reference_paths):
            """
            Reformats the parsed references to separate accitently joined references.
            E.g. the original referehence "§ 123 § 126" will not be split by
            split_citation_into_enum_parts because the separation is falsly not indicated by
    Severity: Minor
    Found in src/quantlaw/de_extract/statutes_parse.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 execute_filtered_items has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def execute_filtered_items(self, items, filters=None, *args, **kwargs):
            if filters:
                filtered_items = []
                for item in list(items):
                    for filter_str in filters:
    Severity: Minor
    Found in src/quantlaw/utils/pipeline.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 parse_main has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def parse_main(self, main_text: str) -> list:
            """
            Parses a string containing a reference to a specific section within a given law.
            E.g. "§ 123 Abs. 4 Satz 5 und 6".
            The parsed informtaion is formatted into lists nested in lists nested in lists.
    Severity: Minor
    Found in src/quantlaw/de_extract/statutes_parse.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 quotient_graph has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def quotient_graph(
    Severity: Minor
    Found in src/quantlaw/utils/networkx.py - About 45 mins to fix

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

          def __init__(
      Severity: Minor
      Found in src/quantlaw/de_extract/statutes_abstract.py - About 35 mins to fix

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

        def induced_subgraph(
        Severity: Minor
        Found in src/quantlaw/utils/networkx.py - About 35 mins to fix

          Avoid too many return statements within this function.
          Open

                      return suffix_len, 0, "unknown"
          Severity: Major
          Found in src/quantlaw/de_extract/statutes_areas.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                                return suffix_len, ignore_no_suffix_len, "ignore"
            Severity: Major
            Found in src/quantlaw/de_extract/statutes_areas.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                          return None  # match_type: ignore or unknown
              Severity: Major
              Found in src/quantlaw/de_extract/statutes_parse.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                                    return suffix_len, sgb_suffix_len, "sgb"
                Severity: Major
                Found in src/quantlaw/de_extract/statutes_areas.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                                  return lawid
                  Severity: Major
                  Found in src/quantlaw/de_extract/statutes_parse.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                        return suffix_len, dict_suffix_len, "dict"
                    Severity: Major
                    Found in src/quantlaw/de_extract/statutes_areas.py - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                  return current_lawid
                      Severity: Major
                      Found in src/quantlaw/de_extract/statutes_parse.py - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                    return 0, 0, "internal"
                        Severity: Major
                        Found in src/quantlaw/de_extract/statutes_areas.py - About 30 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language