NateScarlet/holiday-cn

View on GitHub

Showing 4 of 4 total issues

File fetch.py has 364 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python3
"""Fetch holidays from gov.cn  """

import argparse
import json
Severity: Minor
Found in scripts/fetch.py - About 4 hrs to fix

    Function get_patch_rules has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_patch_rules(lines: Iterator[str]) -> Iterator[Tuple[str, str]]:
        """Get holiday patch rule for existed holiday
    
        Args:
            lines (Iterator[str]): paper content
    Severity: Minor
    Found in scripts/fetch.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 _get_paper_urls has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def _get_paper_urls(year: int) -> Iterator[str]:
        has_next_page = True
        page_index = 0
        while has_next_page:
            resp = requests.get(
    Severity: Minor
    Found in scripts/fetch.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 _iter_date_ranges has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def _iter_date_ranges(days: Sequence[dict]) -> Iterator[Tuple[dict, dict]]:
        if len(days) == 0:
            return
    
        if len(days) == 1:
    Severity: Minor
    Found in scripts/generate_ics.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

    Severity
    Category
    Status
    Source
    Language