Comments (10)
I've decided to take a different approach. I'm now adding space between functions, classes, etc regardless of scope. May not be popular with everyone, but we'll see.
from swiftformat.
This would be in conflict with the blankLinesAtEndOfScope
rule, which removes blank lines before a closing }.
This looks wrong to me.
enum Foo {
case a
case b
case c
}
I feel like it should be
enum Foo {
case a
case b
case c
}
But I haven't managed to come up with a rule for blank lines at the beginning of a scope. Normally I remove them, but there are exceptions, e.g. in a class.
I may need to make this configurable if people feel strongly about it.
from swiftformat.
The enum
example looks wrong by itself, but people may add functions:
enum Foo {
case a, b, c
func bar() {
// Do something here
}
func baz() {
// Do something else here
}
}
If I understand it correctly, blankLinesAtEndOfScope
will affect all curly brackets? But this rule should be a special caseโit will only affect out-most brackets.
Making this configurable sounds like a good idea!
from swiftformat.
Sometimes I write functions like this:
class Foo {
class Bar {
/// Other Methods
}
}
I won't add empty line inside Bar
. Mainly because Foo
is much longer.
from swiftformat.
blankLinesAtEndOfScope
currently only removes the blank line at the end - it doesn't add one. So it will change this:
class Foo {
class Bar {
/// Other Methods
}
}
to this:
class Foo {
class Bar {
/// Other Methods
}
}
from swiftformat.
I get what you're saying about scopes at root level possibly requiring different treatment than ones that are nested. You might be right, but I still don't think I know what the rule should be yet. I'll think about it some more.
from swiftformat.
Sounds good. In this case maybe blankLinesAtEndOfScope
should be reevaluated? It can be submerged into blankLinesBetweenScopes
.
Btw, what about properties?
from swiftformat.
I'm pretty happy with not having a blank line at the end of a scope. Since the scope always ends with a } and a lower indent level than the previous line, there's never any visual overlap:
last line
}
I'm not sure if I like the blank line at the start of a scope or not, which is why I current ignore it. I may eventually make this configurable though.
Btw, what about properties?
I haven't worked out what to do about those yet. I definitely don't want to put blank lines between them, but I'd like to separate groups of them from a previous function, e.g.
func foo () {
}
<-- there should always be a blank line here, but I don't enforce that yet
var bar: Int
from swiftformat.
I haven't worked out what to do about those yet. I definitely don't want to put blank lines between them, but I'd like to separate groups of them from a previous function
I agree.
from swiftformat.
Have you work this case out?
from swiftformat.
Related Issues (20)
- Question: Wrap function calls HOT 7
- `hoistAwait` removes necessary `await` for operators/functions with async autoclosures. HOT 5
- opaqueGenericParameters cannot be disabled? HOT 8
- `Alman = false` in combination with long char count in line breaks the `{` into a new row HOT 7
- redundantReturn removes return statements of consecutive if statements HOT 4
- conditionalAssignment matches expression within try block HOT 11
- Rule Request: Remove redundant parenthesis from closures HOT 7
- conditionalAssignment rule HOT 4
- doesn't recognize both --disable all and // swiftformat:disable all HOT 1
- Make blankLinesAroundMark prioritized over blankLinesAtStartOfScope
- Compile error with conditionalAssignment and Swift version 5.9 HOT 5
- App doesn't manage non-rule config file options HOT 1
- Compiler error with 5.9 conversion to switch expression HOT 1
- Swift warning: BuildTools should be located under 'Sources/BuildTools' HOT 1
- How do I use the `--funcattributes prev-line` rule in the config file? HOT 2
- Outputted code doesn't build HOT 3
- error: 'switch' may only be used as expression in return, throw, or as the source of an assignment HOT 3
- error: Failed to write file <File Location> HOT 11
- Wrapping nested calls HOT 1
- docComments removes macro documentation HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swiftformat.