Skip to content

Ruff SIM108: if/else-to-ternary findings #497

Closed

Description

@squid-protocol

Objective

Part of the ruff lint baseline cleanup (SIM108 -- if/else block that could be a ternary). Chunked out of the larger sub-issue this replaces, so it's a manageable, self-contained pickup.

Findings

  • gitgalaxy/core/detector.py:1598 (SIM108) -- Use ternary operator line_end = len(safe_code) if next_nl == -1 else next_nl + 1 instead of if-else-block
  • gitgalaxy/core/detector.py:2043 (SIM108) -- Use ternary operator args_count = args_str.count(",") + 1 if "," in args_str else len(args_str.strip().split()) instead of if-else-block
  • gitgalaxy/metrics/signal_processor.py:1679 (SIM108) -- Use ternary operator network_multiplier = 0.2 if popularity == 0 else min(1.0 + math.log1p(popularity) / 5.0, 2.0) instead of if-else-block
  • gitgalaxy/tools/terabyte_log_scanning/pii_leak_hunter.py:125 (SIM108) -- Use ternary operator out_dir = Path(args.out).resolve() if args.out else target_path.parent instead of if-else-block
  • gitgalaxy/tools/terabyte_log_scanning/terabyte_log_scanner.py:161 (SIM108) -- Use ternary operator out_dir = Path(args.out).resolve() if args.out else target_path.parent instead of if-else-block

Fix in a small PR, removing resolved entries from tests/ruff_audit_baseline.json (see tests/ruff_audit.py's module docstring for the regen command).

Parent: #469

Activity

  1. added
    good first issue
    python
    refactor
    priority: low
    on Jul 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issuepriority: lowpythonrefactor

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions