Skip to content

Use :block rule as baseline indentation for :stair rule#98

Open
bullfest wants to merge 1 commit intogreglook:mainfrom
bullfest:main
Open

Use :block rule as baseline indentation for :stair rule#98
bullfest wants to merge 1 commit intogreglook:mainfrom
bullfest:main

Conversation

@bullfest
Copy link
Copy Markdown

Fix #97

Sorry about opening this before the underlying issue has been responded to, I had some extra time and thought I'd try my proposed fix.

A better solution might be to introduce a new rule instead, or add extra parameters to the rule as this would change some behaviour when leading forms are missing (see my comment in the tests).

Comment thread test/cljstyle/format/indent_test.clj Outdated
indent/reindent-lines {:indents indents}
;; Note that this is parsed "wrong" as the expr-part is missing from the cond->
"(cond-> a? (a 123)\n b?\n(b true))"
(str "(cond-> a? (a 123)\n" (space 13) "b?\n" (space 11) "(b true))")))
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This is some changed behaviour that I don't think would be possible to keep backwards compatibility with, afaik there's no way for the stair-indentation to tell if the form that's on the same line is the "leading form" (expr in cond->) or if it's a condition that's on the same line...

Copy link
Copy Markdown
Author

@bullfest bullfest Feb 21, 2023

Choose a reason for hiding this comment

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

On further consideration, it could be solved by only using block-indent as the base when the idx parameter is 0 which probably is reasonable.

Things like

(cond-> x a? (a 123) 
          b? (b true))

is quite silly after all and probably not something that should be encouraged.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Feb 21, 2023

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.83%. Comparing base (14c18e5) to head (e2f7ef2).
⚠️ Report is 39 commits behind head on main.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #98      +/-   ##
==========================================
+ Coverage   89.82%   89.83%   +0.01%     
==========================================
  Files          20       20              
  Lines        1907     1909       +2     
  Branches       60       60              
==========================================
+ Hits         1713     1715       +2     
  Misses        134      134              
  Partials       60       60              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

:stair does not behave like documented when multiple arguments on first line

2 participants