Files
Dan Guido 42691e50b4 style: apply ruff auto-fixes and formatting across entire codebase (#309)
* style: apply ruff auto-fixes and formatting across entire codebase

Applied safe auto-fixes from ruff v0.12.9 with --select ALL to improve code quality:
- Reorder imports (stdlib → third-party → local)
- Use modern type hints (collections.abc.Generator instead of typing.Generator)
- Add trailing commas for better diffs
- Format multi-line function parameters for readability
- Add strict=False to zip() calls for explicit behavior
- Simplify redundant elif to if after return statements
- Consistent code formatting with ruff format

These are all mechanical, non-controversial changes that improve code consistency
without altering functionality. Changes affect 180 files across all modules:
common, fuzzer, orchestrator, patcher, program-model, and seed-gen.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* re-applt ruff after merge

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Michael D Brown <michael.brown@trailofbits.com>
2025-08-22 10:30:12 -04:00

35 lines
1.4 KiB
Python

import pytest
from buttercup.program_model.api.fuzzy_imports_resolver import FuzzyJavaImportsResolver
test_cases = [
("a.b(c).d(e())", ("a.b(c)", "d", "method")),
("a.b(d.e()).f.c()", ("a.b(d.e()).f", "c", "method")),
(
"object.method1().method2(arg1, arg2.test()).property",
("object.method1().method2(arg1, arg2.test())", "property", "field"),
),
("a.b.c", ("a.b", "c", "field")),
("a().b().c()", ("a().b()", "c", "method")),
(
"complex.method(nested.calls(with.more.nesting()))",
("complex", "method", "method"),
),
("module.submodule.function()", ("module.submodule", "function", "method")),
("a.b().c.d().e", ("a.b().c.d()", "e", "field")),
("a.b(c.d).e.f(g.h().i)", ("a.b(c.d).e", "f", "method")),
# Edge cases
("", ("", "", None)), # Empty string
("single", ("", "single", "field")), # Single identifier without dots
("method()", ("", "method", "method")), # Just a method call
("a.(b.c).d", ("a.(b.c)", "d", "field")), # Parenthesized expression
]
@pytest.mark.parametrize("input_expr,expected", test_cases)
def test_split_rightmost_component(input_expr, expected):
"""Test the split_rightmost_component function with various test cases."""
resolver = FuzzyJavaImportsResolver(None, None)
result = resolver.split_rightmost_dotexpr(input_expr)
assert result == expected, f"Failed on: {input_expr}\nExpected: {expected}\nGot: {result}"