Comments (4)
I don't think I agree here, it still doesn't separate control flow which is the intent here. Also in general cuddling anything with another block (a closing }
) feels like something against the wsl
philosophy.
But either way, as noted in #110 I'm more likely to drop this rule completely since it overlaps with nlreturn
. I won't close this because I haven't decided yet.
from wsl.
Both of these are valid:
if err != nil {
return 0, err
} else {
return 1, nil
}
if err != nil {
return 0, err
}
return 1, nil
Just because something fits in an else block does not mean I want to reduce separation of control flow. The point of this rule is similar to the philosophy of nlreturn
and for any non single line function wsl
will require an empty line.
The ticket mentions to read any bracket as an empty line even though the example is for error checking. I think that's also against the idea with wsl
since that would allow something like this which is one of the most important rules in my opinion:
if expr {
//
}
if expr {
//
}
I will close this as wontfix but feel free to add more context or thoughts if you think this would fit wsl
or if I misinterpreted your thoughts here.
from wsl.
For the first example, I think I could agree with you, but for the second, the control flow, is like this:
if err != nil
return nil, err
} else { // this
return
} // this
^ I would say the second return is part of the same flow.
from wsl.
I disagree with my OP, you are right. Thanks
from wsl.
Related Issues (20)
- False-negative cuddled assignment line above HOT 3
- Require new lines after multiline function signature HOT 1
- Drop overlapping support for v4 HOT 4
- allow go statements invoke inline function HOT 4
- [Docs] `force-err-cuddling` is referenced as `enforce-err-cuddling` in the documentation HOT 2
- Comment in default block should not be seen as trailing comment HOT 1
- Incorrect check of assignment usage in loop and if statements HOT 1
- `++`/`--` should be treated as an assignment HOT 1
- Group `DeclStmt` instead of splitting with empty lines
- Error installing: does not contain packages matching github.com/bombsimon/wsl/v4/cmd/... HOT 5
- `else`/`else if` blocks are not processed
- Install instructions don't work (for me) HOT 1
- `--fix` ? HOT 2
- Issue with accessing functions and variables across files within the same package in v4 HOT 2
- Allow cuddled return for variable just declared HOT 1
- Cuddle function call expression on var declared in line above HOT 2
- output of wsl and golangci-lint are different HOT 2
- Panic when compiled on go 1.22 HOT 2
- Allow cuddling of deferred statements referencing a pointer 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 wsl.