-
-
Notifications
You must be signed in to change notification settings - Fork 51
Apply JuliaFormatter to fix code formatting #660
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Applied JuliaFormatter with SciML style guide - Formatted 76 files 🤖 Generated by OrgMaintenanceScripts.jl
ChrisRackauckas
added a commit
to ChrisRackauckas/JuliaFormatter.jl
that referenced
this pull request
Jul 31, 2025
- Add conservative line breaking for mathematical expressions (Binary/Chain nodes) - Prevent breaking of function calls that are only slightly over margin - Add comprehensive tests for line break behavior - Fixes issues seen in SciML/NonlinearSolve.jl#660 The changes make SciMLStyle less aggressive about breaking lines when: 1. Mathematical expressions have few operators and fit within margin + 20 chars 2. Function calls with few arguments fit within margin + 20 chars 3. Short type parameters, array indexing, and other constructs remain intact 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
ChrisRackauckas
added a commit
to ChrisRackauckas/JuliaFormatter.jl
that referenced
this pull request
Jul 31, 2025
Previously, array indexing on the left-hand side of assignments could be broken across lines, resulting in undesirable formatting like: du[ i, j, 1] = alpha * expr This commit adds a custom n_ref! implementation for SciMLStyle that detects when a RefN (array reference) node is on the LHS of an assignment and prevents it from being broken across lines. The fix ensures that assignments like: du[i, j, 1] = long_expression Keep the LHS intact while still allowing the RHS to break appropriately. This addresses the issue seen in SciML/NonlinearSolve.jl#660 where array assignments were being formatted in an aesthetically unpleasing way.
domluna
pushed a commit
to domluna/JuliaFormatter.jl
that referenced
this pull request
Jul 31, 2025
…#933) * Fix unnecessary line breaks in SciMLStyle - Add conservative line breaking for mathematical expressions (Binary/Chain nodes) - Prevent breaking of function calls that are only slightly over margin - Add comprehensive tests for line break behavior - Fixes issues seen in SciML/NonlinearSolve.jl#660 The changes make SciMLStyle less aggressive about breaking lines when: 1. Mathematical expressions have few operators and fit within margin + 20 chars 2. Function calls with few arguments fit within margin + 20 chars 3. Short type parameters, array indexing, and other constructs remain intact 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * Fix array indexing line breaks in SciMLStyle - Add conservative nesting rule for RefN (array indexing) nodes - Prevents breaking expressions like du[i, j, 1] when they fit within margin + 30 - Add test to ensure array indexing doesn't break unnecessarily This addresses the remaining formatting issue where array indices were being split across lines even for reasonably-sized expressions. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * Add comprehensive semantic safety tests for SciMLStyle - Add tests for whitespace-sensitive array literals (space vs semicolon) - Test operator precedence preservation - Test coefficient syntax (2x vs 2 x) - Test macro scope preservation - Test string/char/regex/command literals - Test ternary operator associativity - Test anonymous functions and comprehensions - Test broadcasting and type syntax - Test all Julia language constructs for semantic preservation - Add 69 new semantic safety tests These tests ensure the formatter never changes program meaning, only whitespace and formatting. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * Add comprehensive line break quality tests for SciMLStyle - Add helper function analyze_line_quality to measure line utilization efficiency - Test single line preservation for simple expressions - Test efficient breaking of long lines with good space utilization - Test type parameter wrapping to avoid excessive breaks - Test array operation formatting preserves structure - Test function definitions break intelligently based on length - Test nested expressions maintain logical hierarchy - Test mathematical expressions break at natural operator boundaries - Test to avoid orphan parameters on their own lines - Test keyword argument grouping for readability - Test preservation of logical grouping (coordinates, pairs) - Test real-world SciML examples for practical formatting quality These tests ensure the formatter produces aesthetically pleasing output that makes efficient use of the 92-character line limit while maintaining code readability and structure. * Fix assignment LHS breaking issue Previously, array indexing on the left-hand side of assignments could be broken across lines, resulting in undesirable formatting like: du[ i, j, 1] = alpha * expr This commit adds a custom n_ref! implementation for SciMLStyle that detects when a RefN (array reference) node is on the LHS of an assignment and prevents it from being broken across lines. The fix ensures that assignments like: du[i, j, 1] = long_expression Keep the LHS intact while still allowing the RHS to break appropriately. This addresses the issue seen in SciML/NonlinearSolve.jl#660 where array assignments were being formatted in an aesthetically unpleasing way. --------- Co-authored-by: Claude <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Changes
This PR was automatically generated by OrgMaintenanceScripts.jl