Skip to content

Add support for if else expressions - #303

Open
jgardn3r wants to merge 7 commits into
masterfrom
if-else-expression
Open

Add support for if else expressions#303
jgardn3r wants to merge 7 commits into
masterfrom
if-else-expression

Conversation

@jgardn3r

@jgardn3r jgardn3r commented May 26, 2026

Copy link
Copy Markdown
Collaborator

This PR closes #273.

There are some commits from the compound operator PR that will disappear after it is merged.
Adding a feature like this requires changes to contexts, rules, and the overall understanding of the roles if and else play in the context of a line.

@jgardn3r
jgardn3r requested a review from fourls May 26, 2026 01:20
@codecov

codecov Bot commented May 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.44961% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...re/src/rules/optimising_line_formatter/contexts.rs 98.03% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@fourls fourls left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have played around with it a bit and I'm mostly happy with the rule as it is. Let's add some more complex examples in the tests, especially with anonymous methods and with nesting in the else block, and I think we should have most of the edge cases.

Also there is a commit message typo: Convert get_operator_precedence to a trait routine

Comment thread core/datatests/generators/optimising_line_formatter.rs
Comment thread core/src/rules/optimising_line_formatter/contexts.rs Outdated
Comment thread core/CHANGELOG.md Outdated
Comment thread CHANGELOG.md Outdated
Comment thread core/src/rules/optimising_line_formatter/requirements.rs
Comment thread core/src/rules/optimising_line_formatter/contexts.rs Outdated
Comment thread core/src/rules/optimising_line_formatter/contexts.rs Outdated
Comment thread core/src/rules/optimising_line_formatter/contexts.rs Outdated
Comment thread core/src/rules/optimising_line_formatter/contexts.rs
@jgardn3r
jgardn3r force-pushed the if-else-expression branch from 75bc30a to ba57f10 Compare August 10, 2026 03:49
@jgardn3r
jgardn3r requested a review from fourls August 10, 2026 03:49

@fourls fourls left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

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.

Support new conditional operator (ternary)

2 participants