import logging
from typing import List, Tuple

# Configure logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')


def review_code(diff: str) -> List[Tuple[str, str]]:
    """
    Simulates reviewing a code diff and returns a list of findings.

    Args:
        diff: The code diff as a string.

    Returns:
        A list of tuples, where each tuple contains the line of code with an issue and the suggested change.
    """
    try:
        findings = []
        lines = diff.splitlines()
        for i, line in enumerate(lines):
            if "TODO" in line:
                findings.append((line, "Remove or address TODO comments before submitting."))
            if len(line) > 120:
                findings.append((line, "Consider shortening this line to improve readability."))
            if "print(" in line:
                findings.append((line, "Remove print statements before submitting."))

        return findings
    except Exception as e:
        logging.error(f"An error occurred during code review: {e}")
        return [("", f"Review failed due to error: {e}")]


def main():
    """
    Main function to demonstrate the code review process.
    """
    example_diff = """
    +def my_function(arg1, arg2):
    +    # TODO: Implement the main logic here
    +    print("Hello, world!")
    +    result = arg1 + arg2  # This is a very long comment that might exceed the recommended line length
    +    return result
    """

    print("Example Diff:")
    print(example_diff)

    findings = review_code(example_diff)

    if findings:
        print("\nReview Findings:")
        for line, suggestion in findings:
            print(f"- Line: {line}")
            print(f"  Suggestion: {suggestion}")
    else:
        print("\nNo issues found.")


if __name__ == "__main__":
    main()