Skip to content

Conversation

@ChrisRackauckas
Copy link
Member

@ChrisRackauckas ChrisRackauckas commented Aug 1, 2025

Summary

Fix all unnecessary line splits in Julia code following the guidelines established in Catalyst.jl PR #1306. This PR improves code readability by consolidating short expressions that were unnecessarily split across multiple lines.

Background

These formatting issues are being addressed upstream in JuliaFormatter.jl PR #934, which implements algorithmic fixes to prevent these unnecessary line splits. However, since that PR is not yet merged, manual fixes are needed in the meantime to improve code readability.

Changes Made

Fixed 30 instances of problematic line splits across 11 files:

Source Files (9 instances)

  • src/coupling.jl: 2 lambda parameter lists
  • src/spatial/flatten.jl: 1 arithmetic expression
  • src/spatial/hop_rates.jl: 6 arithmetic expressions
  • src/jumps.jl: 2 variable assignments

Test Files (18 instances)

  • test/extended_jump_array.jl: 2 arithmetic expressions
  • test/bracketing.jl: 2 test assertions
  • test/ssa_callback_test.jl: 8 function calls
  • test/degenerate_rx_cases.jl: 2 instances (tuple assignment + function call)
  • test/spatial/hop_rates.jl: 3 instances (function calls + array comprehension)
  • test/hawkes_test.jl: 1 function call

Documentation (3 instances)

  • docs/make.jl: 3 function calls

Examples of Fixes

Before:

new_rate = (u, p,
    t) -> rate(u.u, p, t) -
          min(rate(u.u, p, t), rate_control(u.u_control, p, t))

After:

new_rate = (u, p, t) -> rate(u.u, p, t) -
          min(rate(u.u, p, t), rate_control(u.u_control, p, t))

Before:

@inbounds u[species, site] * hop_rates.hopping_constants[species] *
          outdegree(spatial_system, site)

After:

@inbounds u[species, site] * hop_rates.hopping_constants[species] * outdegree(spatial_system, site)

Rationale

Following Catalyst.jl PR #1306's approach:

  • Prioritize readability over strict formatter rules for short expressions
  • Keep semantically related code units together
  • All modified lines stay well under 120 characters (typically 85-115 chars)
  • Use JuliaFormatter as a helpful tool rather than a strict rule enforcer

Note on JuliaFormatter

Running the current JuliaFormatter on this codebase will revert these manual fixes because the underlying formatting algorithm hasn't been updated yet. Once JuliaFormatter.jl PR #934 is merged, these manual fixes should no longer be necessary as the formatter will handle these cases correctly.

Test Plan

  • All syntax validated and files parse correctly
  • No functional changes to code logic
  • All expressions remain under reasonable line length limits
  • Comprehensive search performed to ensure all cases found
  • Verified that current JuliaFormatter reverts these fixes (confirming the need for manual intervention)

🤖 Generated with Claude Code

claude added 3 commits August 1, 2025 00:30
- Fix lambda function parameter lists in coupling.jl (2 instances)
- Fix arithmetic expressions in spatial/flatten.jl (1 instance)
- Fix arithmetic expressions in spatial/hop_rates.jl (6 instances)

These changes improve code readability by keeping short expressions
on single lines while staying well under 120-character line limits.

All modified expressions are under 120 characters and splitting them
across multiple lines reduces readability without providing benefit.

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

Co-Authored-By: Claude <[email protected]>
- Fix variable assignments in src/jumps.jl (2 instances)
- Fix arithmetic expressions in test/extended_jump_array.jl (2 instances)
- Fix test assertions in test/bracketing.jl (2 instances)

These changes improve readability by keeping short expressions on single
lines following Catalyst.jl PR #1306 guidelines.

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

Co-Authored-By: Claude <[email protected]>
Fixed the final 15 instances across 5 files:
- test/ssa_callback_test.jl: 8 function calls
- test/degenerate_rx_cases.jl: 2 instances (tuple assignment + function call)
- test/spatial/hop_rates.jl: 3 instances (function calls + array comprehension)
- test/hawkes_test.jl: 1 function call
- docs/make.jl: 3 function calls

All 30 problematic line splits in the codebase have now been fixed.
These changes improve readability by keeping short expressions on single
lines while staying well under 120-character line limits.

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

Co-Authored-By: Claude <[email protected]>
@ChrisRackauckas ChrisRackauckas merged commit 68599d3 into master Aug 2, 2025
14 of 17 checks passed
@ChrisRackauckas ChrisRackauckas deleted the fix-formatter-line-splits branch August 2, 2025 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants