muter-mutation-testing / muter

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

ApplySchemata step doesn't generate formatted code #263

Closed hoangatuan closed 9 months ago

hoangatuan commented 11 months ago

Describe the bug

The ApplySchemata step generates not formatted code, which makes the debug process harder

To reproduce

Given this piece of code

final class AlgoService: IAlgo {
    func isGreater(n1: Int, n2: Int) -> Bool {
        return n1 > n2
    }
}

Current behavior

The generated code after the ApplySchemata step is:

final class AlgoService: IAlgo {
    func isGreater(n1: Int, n2: Int) -> Bool { if ProcessInfo.processInfo.environment["AlgoService_17_19_346"] != nil {
        return n1 < n2
} else {
        return n1 > n2
}
    }
}

In this scenario, since we don't add a new line for the part if ProcessInfo.processInfo..., so we can't not use Command + I to format the code

Expected behavior

final class AlgoService: IAlgo {
    func isGreater(n1: Int, n2: Int) -> Bool {
        if ProcessInfo.processInfo.environment["AlgoService_17_19_346"] != nil {
            return n1 < n2
        } else {
            return n1 > n2
        }
    }
}

Which version I'm using

I'm using Muter by running the latest code on master branch

hoangatuan commented 11 months ago

Hi @rakaramos @ZevEisenberg, please take a look. If you find that it's an issue, I can help to fix

ZevEisenberg commented 11 months ago

Thanks for taking the time to report this! This does look familiar to me, and I believe we just didn't bother to add the formatting because it's a bunch of tedious work that didn't directly contribute to getting schemata to work. But if you're interested in putting in the work, I'm sure @rakaramos or I could review a PR. It's great to get feedback like this from real users!

hoangatuan commented 11 months ago

@ZevEisenberg Yeah I agree, it's a bit tedious. For me I want to play around with SwiftSyntax, so it's still interesting for me a bit. I want to integrate Muter into the production app, so I want to make Muter as neat as possible. Let me know if you need any help with some other part that you think is important, I'm ready to help

ZevEisenberg commented 11 months ago

That'll be up to Rafael. I'm mostly serving in an advisory capacity at the moment.