ActivityWatch/activitywatch

View on GitHub

Showing 10 of 10 total issues

File build_changelog.py has 439 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python3
"""
Script that generates a changelog for the repository and its submodules, and outputs it in the current directory.

NOTE: This script can be downloaded as-is and run from your repository.
Severity: Minor
Found in scripts/build_changelog.py - About 6 hrs to fix

    Function summary_repo has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
    Open

    def summary_repo(
        org: str,
        repo: str,
        path: str,
        commit_range: Tuple[str, str],
    Severity: Minor
    Found in scripts/build_changelog.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 _resolve_email has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
    Open

    def _resolve_email(email: str) -> Optional[str]:
        if "users.noreply.github.com" in email:
            username = email.split("@")[0]
            if "+" in username:
                username = username.split("+")[1]
    Severity: Minor
    Found in scripts/build_changelog.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 remove_duplicates has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    def remove_duplicates(s: List[str], minlen=10, only_sections=True) -> List[str]:
        """
        Removes the longest sequence of repeated elements (they don't have to be adjacent), if sequence if longer than `minlen`.
        Preserves order of elements.
        """
    Severity: Minor
    Found in scripts/build_changelog.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

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

    def get_twitter_of_ghusers(ghusers: Collection[str]):
        logger.info("Getting twitter of GitHub usernames")
    
        # We will commit this file, to act as a cache (preventing us from querying GitHub API every time)
        filename = script_dir / "changelog_contributors_twitter.csv"
    Severity: Minor
    Found in scripts/build_changelog.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 get_all_contributors has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_all_contributors() -> set[str]:
        # TODO: Merge with contributor-stats?
        logger.info("Getting all contributors")
    
        # We will commit this file, to act as a cache (preventing us from querying GitHub API every time)
    Severity: Minor
    Found in scripts/build_changelog.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 a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def main(exclude_testing: bool = False, limit_days: int = 10, limit_lines: int = 10):
        file_lines = collect()
    
        if exclude_testing:
            keys = filter(lambda k: "testing" not in k, file_lines.keys())
    Severity: Minor
    Found in scripts/logcrawler.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 build has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def build(
    Severity: Major
    Found in scripts/build_changelog.py - About 50 mins to fix

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

      def summary_repo(
      Severity: Minor
      Found in scripts/build_changelog.py - About 45 mins to fix

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

        def collect():
            matched_lines = defaultdict(lambda: [])
            for filepath in sorted(get_filepaths()):
                with open(filepath, "r") as f:
                    log = f.read()
        Severity: Minor
        Found in scripts/logcrawler.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