fabiocaccamo/python-codicefiscale

View on GitHub

Showing 7 of 22 total issues

Function _get_birthplace_fallback has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

def _get_birthplace_fallback(
    birthplaces_options: list[dict[str, Any]],
    birthdate_date: datetime,
) -> dict[str, dict[str, Any]] | None:
    # avoid wrong birthplace code error when birthdate falls in
Severity: Minor
Found in codicefiscale/codicefiscale.py - About 3 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

Avoid deeply nested control flow statements.
Open

                    if date_created and date_deleted:
                        date_delta = date_deleted - date_created
                        if date_delta <= timedelta(days=1):
                            return birthplace_option.copy()
                    return birthplace_option_next.copy()
Severity: Major
Found in codicefiscale/codicefiscale.py - About 45 mins to fix

    Function _update_countries_data has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def _update_countries_data() -> None:
        # https://www.anagrafenazionale.interno.it/area-tecnica/tabelle-di-decodifica/
        data_url = (
            "https://www.anagrafenazionale.interno.it"
            "/wp-content/uploads/2022/10/tabella_2_statiesteri.xlsx"
    Severity: Minor
    Found in scripts/updatedata.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 _get_birthplace has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def _get_birthplace(
        birthplace: str,
        birthdate: datetime | str | None = None,
    ) -> dict[str, dict[str, Any]] | None:
        birthplace_slug = slugify(birthplace)
    Severity: Minor
    Found in codicefiscale/codicefiscale.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 run_with_args has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def run_with_args(args: argparse.Namespace) -> None:
        if args.subcommand is None and args.version:
            sys.stdout.write(f"{__version__}\n")
        elif args.subcommand == "decode":
            _decode_from_args(args)
    Severity: Minor
    Found in codicefiscale/cli.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 _update_municipalities_data has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def _update_municipalities_data() -> None:
        # https://www.anagrafenazionale.interno.it/area-tecnica/tabelle-di-decodifica/
        data_url = (
            "https://www.anagrafenazionale.interno.it"
            "/wp-content/uploads/ANPR_archivio_comuni.csv"
    Severity: Minor
    Found in scripts/updatedata.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 get_indexed_data has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_indexed_data() -> (
        dict[str, dict[str, list[dict[str, bool | datetime | str | list[str]]]]]
    ):
        municipalities = get_municipalities_data()
        countries = get_countries_data()
    Severity: Minor
    Found in codicefiscale/data.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