[DEPRECATED]
nicklockwood/FXForms 2946
[DEPRECATED]
AutoCoding is a category on NSObject that provides automatic support for NSCoding and NSCopying to every object.
A faster and more flexible binary file format replacement for NSCoding, Property Lists and JSON
nicklockwood/AsyncImageView 912
[DEPRECATED]
[DEPRECATED]
A cross-platform Swift library for evaluating mathematical expressions at runtime
nicklockwood/CountryPicker 741
CountryPicker is a custom UIPickerView subclass that provides an iOS control allowing a user to select a country from a list. It can optionally display a flag next to each country name, and the library includes a set of 249 high-quality, public domain flag images from FAMFAMFAM (http://www.famfamfam.com/lab/icons/flags/) that have been painstakingly re-named by country code to work with the library.
FXImageView is a class designed to simplify the application of common visual effects such as reflections and drop-shadows to images, and also to help the performance of image loading by handling it on a background thread.
[DEPRECATED]
push eventnicklockwood/SwiftFormat
commit sha 307098d885d01973ccc6752a9240ffe706b6d8ae
Fix `hoistTry` with generics, subscripts and collection literals
push time in 5 days
push eventnicklockwood/SwiftFormat
commit sha 308475681796004a28b084ab9b5da61e110dccef
Update README and add fix for common error on Apple Silicon (#1464)
commit sha e875d61ca7340f89da978cdd4c27fe7b4c95779a
`--conditionswrap` option to format condition in Xcode 12 style, in case it's too long or multiline
commit sha c613f8737a63523c8c7bfc2fdd996c04bb4aae4a
Add options for spacing around delimiter (#1335)
commit sha 9303cf1ef2d15cd7e2cdbde7bf733d745c9b1be7
Add redundantStaticSelf rule.
commit sha 38130cd323441031e15eed5c9df8def8dd0fa4da
Add `headerFileName` rule
commit sha f72cbc3e3a07e22cc36f43df2653096a799fb1a4
Refactor typealias parser into shared helper
commit sha b3abd02f9b01ca51b08b6b8d94e527fd23fe0f50
Add sortTypealiases rule
commit sha 4ebab22a50a69e9412755f74239d83628d579fd2
Add endOfDeclaration helper
commit sha be8a63393fed0a0c7a7fd0027c10575ccebe1490
Fix redundantStaticSelf issue #1446
commit sha 22ae5cccc72a6f24e8ba00bd20e19ec4dd6b1164
Enable redundantStaticSelf by default
commit sha 4a06f5f224b6a1133d5fcecf3d3f5eefbc71005a
Add option to 'elseOnSameLine' rule to preserve blank lines before else statements
commit sha 5e7647d149117f9be45b453436a798a57d930a4a
Remove `--elseblankline`, make it the default behavior
commit sha baac869287556d75273b96d132ed04e91231bf15
Add support for `consume` operator
commit sha 252910f4ba6e0b1b825244dfac2eba0cc135e667
Add `applicationMain` rule
commit sha 3bd1379ba7965b06cd00e6cab5ac4949b0b6bdd6
enhancement: initWithCoder (#1442)
commit sha 1bbe6ecc7754a2ef433f8159795cd717b1e4ba4e
Static link Swift stdlib on Linux
commit sha 4793c3e8645f4d40ed06d5339e22ac3f5d768ccf
Fix hoisting `try` inside optional function
commit sha 37995adeb8fa1b9c829f3bafb429754d31d74eec
Fix bug with statements containing both `try?` and `try`
commit sha 0c6479e9937c24206af434ef39f98509931517cb
Fix `hoistTry` with generics, subscripts and collection literals
push time in 5 days
push eventnicklockwood/SwiftFormat
commit sha 308475681796004a28b084ab9b5da61e110dccef
Update README and add fix for common error on Apple Silicon (#1464)
push time in 5 days
pull request commentnicklockwood/SwiftFormat
[UPDATE] Add line break at the end
@shayanaf I'm not sure what you're trying to do here - can you explain?
comment created time in 5 days
push eventnicklockwood/SwiftFormat
commit sha 28b9bb7462ea86e6fd0d46883cde66bdbbd8bb47
Fix `hoistTry` with generics, subscripts and collection literals
push time in 5 days
push eventnicklockwood/SwiftFormat
commit sha e4faa20b65dc48df998b9cda0c4d140324779974
Fix bug with statements containing both `try?` and `try`
push time in 5 days
push eventnicklockwood/SwiftFormat
commit sha 3a9adf4095f87fbb61e9dab75996e627b7d049dd
Fix hoisting `try` inside optional function
push time in 5 days
push eventnicklockwood/SwiftFormat
commit sha 5145179d64b61a5b63e2e95f7f2d9bd751d8f9d8
Fix hoisting `try` inside optional function
push time in 5 days
pull request commentnicklockwood/SwiftFormat
Update README and add fix for common error on Apple Silicon
Thanks!
comment created time in 5 days
issue commentnicklockwood/SwiftFormat
@RomanTysiachnik thanks for reporting these - very helpful examples.
comment created time in 7 days
issue closednicklockwood/SwiftFormat
Running swiftformat test.swift --rules redundantSelf
fails with error: Unexpected static keyword on line 1
for the following code:
public struct FooClient: Sendable {
public let mapFromBar: @Sendable (Bar) async -> Result<Foo, DecodingError>
public let mapManyFromBars: @Sendable ([Bar]) async -> Result<[Foo], DecodingError>
public let mapToBar: @Sendable (Foo) async -> Bar
public let mapManyToBars: @Sendable ([Foo]) async -> [Bar]
public init(
mapFromBar: @escaping @Sendable (Bar) async -> Result<Foo, DecodingError>,
mapManyFromBars: @escaping @Sendable ([Bar]) async -> Result<[Foo], DecodingError>,
mapToBar: @escaping @Sendable (Foo) async -> Bar,
mapManyToBars: @escaping @Sendable ([Foo]) async -> [Bar]
) {
self.mapFromBar = mapFromBar
self.mapManyFromBars = mapManyFromBars
self.mapToBar = mapToBar
self.mapManyToBars = mapManyToBars
}
public init(
mapFromBar: @escaping @Sendable (Bar) async -> Result<Foo, DecodingError>,
mapToBar: @escaping @Sendable (Foo) async -> Bar
) {
self.mapFromBar = mapFromBar
mapManyFromBars = Self.deriveMapFromMany(mapFromBar)
self.mapToBar = mapToBar
mapManyToBars = Self.deriveMapToMany(mapToBar)
}
public static func deriveMapFromMany(
_ closure: @escaping @Sendable (Bar) async -> Result<Foo, DecodingError>
) -> @Sendable ([Bar]) async -> Result<[Foo], DecodingError> {
{ bars in
var widgetBars = [Foo]()
widgetBars.reserveCapacity(bars.count)
for bar in bars {
switch await closure(bar) {
case let .success(widgetBar):
widgetBars.append(widgetBar)
case let .failure(error):
return .failure(error)
}
}
return .success(widgetBars)
}
}
public static func deriveMapToMany(
_ closure: @escaping @Sendable (Foo) async -> Bar
) -> @Sendable ([Foo]) async -> [Bar] {
{ foos in
var bars = [Bar]()
bars.reserveCapacity(foos.count)
for foo in foos {
let bar = await closure(foo)
bars.append(bar)
}
return bars
}
}
}
swiftformat version = 0.51.10
Edit: Updated code sample
closed time in 9 days
roanutilissue commentnicklockwood/SwiftFormat
@roanutil fixed in 0.51.11
comment created time in 9 days
issue closednicklockwood/SwiftFormat
Inconsistent behavior of consecutiveBlankLines rule
Hi!
I'm writing to report an issue related to the consecutiveBlankLines
rule. While using this rule, I've observed inconsistent behavior where it fails to throw a lint warning when there are two blank lines at the end of a file.
The expected behavior of the consecutiveBlankLines
rule is to detect and warn about consecutive blank lines within a file. However, it appears to overlook the presence of two blank lines specifically at the end of a file.
To illustrate the issue further, let me provide an example:
final class NetworkService {
...
<-- 1st blank line
<-- 2nd blank line: consecutiveBlankLines rule works correctly and warns about the blank line
...
}
<-- 1st blank line
<-- 2nd blank line: consecutiveBlankLines rule doesn't throw a warning about the blank line
<-- 3rd blank line: consecutiveBlankLines rule starts acting correctly, throwing a warning
- If a file contains two or more consecutive blank lines within the scope of a type or a function, the
consecutiveBlankLines
rule correctly throws a lint warning indicating the presence of excessive blank lines. - However, if the file concludes with exactly two consecutive blank lines, the
consecutiveBlankLines
rule fails to raise any lint warning. This contradicts the expected behavior, as it should ideally flag such occurrences consistently.
Here is the screenshot that illustrates the Swiftformat
output after running the lint process:
Thanks in advance for investigating this issue.
closed time in 9 days
rodion-artyukhinissue commentnicklockwood/SwiftFormat
Inconsistent behavior of consecutiveBlankLines rule
@rodion-artyukhin fixed in 0.51.11
comment created time in 9 days
issue closednicklockwood/SwiftFormat
docComments produces false positive for TODO comments when ahead of function signatures
By enabling docComments
, it transforms code like this:
-// TODO: Clean up this mess
+/// TODO: Clean up this mess
func doSomething() {
…
}
Probably because it precedes a function signature, so it thinks it should be marked as a doc comment instead of a simple comment.
closed time in 9 days
rogerluanissue closednicklockwood/SwiftFormat
Failed to terminate: Too many trys
When I try to format the following Swift file I get an error:
class Example {
enum Error: Swift.Error {
case exampleError
}
init(string: String) throws {
throw Error.exampleError
}
func exampleFunction() throws -> ManyInitExample {
do {
// let exampleString = try throwingExample()
return ManyInitExample(
a: try Example(string: try throwingExample()), // Comment this out
// a: try Example(string: exampleString),
b: try throwingExample(),
c: try throwingExample(),
d: try throwingExample(),
e: try throwingExample(),
f: try throwingExample(),
g: try throwingExample(),
h: try throwingExample(),
i: try throwingExample()
)
} catch {
throw error
}
}
func throwingExample() throws -> String {
throw Error.exampleError
}
}
class ManyInitExample {
init(a: Example, b: String, c: String, d: String, e: String, f: String, g: String, h: String, i: String) {
}
}
Command:
swiftformat TooManyTrys.swift --swiftversion 5.7 --verbose
Log:
Running SwiftFormat...
Formatting [obmitted]/TooManyTrys.swift
-- error: Failed to terminate
error: 1 file could not be formatted.
SwiftFormat version:
0.51.10
Workaround:
- Comment out the two commented in lines
- Comment in the marked line
closed time in 9 days
fossil12issue commentnicklockwood/SwiftFormat
Failed to terminate: Too many trys
@fossil12 fixed in 0.51.11
comment created time in 9 days
issue commentnicklockwood/SwiftFormat
docComments produces false positive for TODO comments when ahead of function signatures
@rogerluan fixed in 0.51.11
comment created time in 9 days
push eventnicklockwood/SwiftFormat
commit sha ef21f40496558b81e69fc629967449ad5e14e85b
Don't convert TODO: comments to doc comments
commit sha 59db99a011f5a1e89f80aee5230999313eeab644
Fix hoistTry test typos
commit sha f562c27461dfe0048bd0b0c3ad2617391c2a3750
Fix hoistTry failure to terminate
commit sha 2bcdeac050e4d59590d31f14d3d4e56b4dd304d0
Fix failure to report lint error when removing blank line
commit sha 3c4d2883cf36c03cf84b468c836b6d934feb28ef
Fix static function error false positive in `redundantSelf` rule
commit sha 29c5053c803d2f58716aa5028f6ef5e9fd397168
Update for 0.51.11 release
commit sha d06f7821e6e240f6588c268b2fdf0fc8db372069
`--conditionswrap` option to format condition in Xcode 12 style, in case it's too long or multiline
commit sha 6c84a11a28c8bd51e014a59a857ff4576e3deb61
Add options for spacing around delimiter (#1335)
commit sha 3a39a339d0132f27386e073a29cf6aabfe5158cb
Add redundantStaticSelf rule.
commit sha 5d3d47b223101aea10c4231673f4332bdbdc2e1b
Add `headerFileName` rule
commit sha 0bfafaa578f69edc14634347b3b5c5187a813f57
Refactor typealias parser into shared helper
commit sha c303545ad9f649fb955389740800c0690c06d0a9
Add sortTypealiases rule
commit sha 697eca11c7c8dcfc629ca8dd0a12acba8ec3bb14
Add endOfDeclaration helper
commit sha 5d83bd19f8c7164a2161d1b606319293c4cbb49d
Fix redundantStaticSelf issue #1446
commit sha 4027dd8544e1804198e72ee8923cd78477ac83e3
Enable redundantStaticSelf by default
commit sha 552665948dd0e29033744680281d77f0c69b2c8b
Add option to 'elseOnSameLine' rule to preserve blank lines before else statements
commit sha 50dc0a90b83b175a796a18552d0027a2df3db9ed
Remove `--elseblankline`, make it the default behavior
commit sha 33d1cb599e496aa2a5c2bf2748851c3edf13866c
Add support for `consume` operator
commit sha 43c4502829de43b36f6f444d3dd6fbd81e9db16d
Add `applicationMain` rule
commit sha ce2814af469c90e629242c670c1b6aa0c644154f
enhancement: initWithCoder (#1442)
push time in 9 days
release nicklockwood/SwiftFormat
swiftformat.artifactbundle.zip 4.05MB
SwiftFormat.for.Xcode.app.zip 6.81MB
swiftformat.zip 1.58MB
swiftformat_linux.zip 2.46MB
released time in 9 days
created tagnicklockwood/SwiftFormat
A command-line tool and Xcode Extension for formatting Swift code
created time in 9 days
push eventnicklockwood/SwiftFormat
commit sha ef21f40496558b81e69fc629967449ad5e14e85b
Don't convert TODO: comments to doc comments
commit sha 59db99a011f5a1e89f80aee5230999313eeab644
Fix hoistTry test typos
commit sha f562c27461dfe0048bd0b0c3ad2617391c2a3750
Fix hoistTry failure to terminate
commit sha 2bcdeac050e4d59590d31f14d3d4e56b4dd304d0
Fix failure to report lint error when removing blank line
commit sha 3c4d2883cf36c03cf84b468c836b6d934feb28ef
Fix static function error false positive in `redundantSelf` rule
commit sha 29c5053c803d2f58716aa5028f6ef5e9fd397168
Update for 0.51.11 release
push time in 9 days
issue commentnicklockwood/SwiftFormat
SwiftFormat without Unfolding Brackets
@Detnator-Neo hi, I haven't checked recently, but this was certainly the case when I last looked. It's possible there's some way to access code fold state that I'm not aware of, but otherwise yes, changing any folded line appears to unavoidably cause it to be expanded.
It's possible that the situation could be improved a bit by ensuring that only likes which actually need to change are replaced by the extension. If you'd like to have a go at implementing something like that I'd be happy to accept the PR.
comment created time in 9 days
issue commentnicklockwood/SwiftFormat
@roanutil thanks, I was able to reproduce it now 👍
comment created time in 10 days
push eventnicklockwood/SwiftFormat
commit sha 8d05b2092d1e496b66ac1913c477d746f0164caf
Fix static function error false positive in `redundantSelf` rule
push time in 10 days
issue commentnicklockwood/SwiftFormat
@roanutil AFAIK it's illegal in swift to have a static function outside of a class, struct or enum, which is why SwiftFormat is complaining. If I try putting that same code inside a class it works OK.
comment created time in 11 days
issue commentnicklockwood/SwiftFormat
Inconsistent behavior of consecutiveBlankLines rule
@rodion-artyukhin thanks for reporting this, it will be fixed in the next release.
The issue was that SwiftFormat was comparing the line before and after and seeing that nothing had changed (the blank line was still a blank line). It does this to avoid false positives in the lint output (where one rule might have made a change that is cancelled out by another) but obviously in this case it was doing the wrong thing.
comment created time in 11 days
push eventnicklockwood/SwiftFormat
commit sha 71b2e1f6d86e99e2190c521e55a532e0c41ce09e
Fix failure to report lint error when removing blank line
push time in 11 days
push eventnicklockwood/SwiftFormat
commit sha 3716c4aa0aef81a588ceba71649ade55af6d6190
Fix hoistTry test typos
commit sha 7da0c435114cfbbbd4188a74a3fc073b854c2f93
Fix hoistTry failure to terminate
push time in 11 days