muter-mutation-testing / muter

🔎 Automated mutation testing for Swift 🕳️
MIT License
496 stars 39 forks source link

Fix apply schemata step doesnt generate formatted code #264

Closed hoangatuan closed 7 months ago

hoangatuan commented 9 months ago

What it Does

Note

Since we can't get the Xcode indentation setting directly from Swift, I added a .tabs(1) to the leading trivia for If body block and Else body block by default. As long as the Tab Width and Indent Width settings are equal, the Apply schemata will generate formatted code directly.

Screenshot 2024-01-03 at 6 42 49 PM

In case Tab Width and Indent Width are different, the Apply schemata will not be able to generate formatted code.
However, you can use tools like swiftformat or Command + I to format the code easily

ZevEisenberg commented 9 months ago

Apparently you may be able to use this to call .formatted() at the end to get what you want? I haven't tried it, but it sounds interesting!

hoangatuan commented 9 months ago

Apparently you may be able to use this to call .formatted() at the end to get what you want? I haven't tried it, but it sounds interesting!

@ZevEisenberg Thanks for your suggestion. My current approach still faces some limitations here.
Let me try with your suggestion to see if it works

hoangatuan commented 9 months ago

Hi @ZevEisenberg, I pushed the latest change. I've updated the logic to:

rakaramos commented 8 months ago

hey @hoangatuan thanks for effort. I'm wondering why not just use this and skip the property on the configuration. If we that the result is much better because we are using something that goes beyond the indentation we can leave the tab vc spaces war for the rest of the people 😆

hoangatuan commented 8 months ago

@rakaramos Oh wow I don't know about that  😂 That's work too But that code uses indentation = .spaces(2) by default, so should we still support users to configure the indentation in the yaml configure file? (Similar to what apple-swift-format has done)

rakaramos commented 8 months ago

@hoangatuan I think we can live we 2 spaces 😄 it's not super important for the users to lint something as ephemeral as the mutated source code. this is why we disable all the linters.

hoangatuan commented 8 months ago

@rakaramos I've updated the PR base on your suggestion