ultraware / whitespace Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
https://github.com/anz-bank/sysl/blob/master/sysl2/sysl/parse/parse.go#L316 is triggering this new linter to complain about the empty line between the func line and the code. In my opinion, removing that empty line makes this much less readable (in that the code gets lost in the parameter list).
https://github.com/anz-bank/sysl/blob/8e4fac991a393c5af362e83ab0a0687fbcb23dd6/sysl2/sysl/sysl.go#L76 on the other-hand is a reasonable error.
Can you please allow this construct (or add a configuration option to allow it?)
Thank you for this linter plugin! This is exactly what I've been looking for.
Unfortunately there seems to be a bug which causes the "insert blank line after multi-line function definition" not to work for inline functions.
Settings:
linters-settings:
whitespace:
multi-func: true
multi-if: true
Code as I want it to look in my projects:
func Example1() {
inlineFunction := func(veryLongArgumentName *withALongType,
secondArgument *anotherLongType) {
// Code or comments should start after an empty line here.
}
}
func Example2() {
testCases := []struct {
name string
caseFn func(*testing.T, *someLongType, *fooBar) error
}{
{
name: "example",
caseFn: func(t *testing.T, myLongVar *someLongType,
myOtherVar *fooBar) error {
// Code or comments should start after an
// empty line here.
return nil
}
},
}
}
But on both cases the linter complains about the blank line before the // Code or comments should start after an empty line here
comment.
Greetings. whitespace
complains about the following if statement, claiming that it has a "unnecessary leading newline":
# Multi-line if statement 1
if condition1ThatisReallyLong &&
condition2ThatisReallyLong &&
condition3ThatisReallyLong &&
condition4ThatisReallyLong {
foo()
}
However, this does not appear to be true - doesn't it have a trailing newline instead of a leading newline? (This appears to be a bug.)
Furthermore, whitespace
does not complain about the following if statement:
# Multi-line if statement 2
if condition1ThatisReallyLong &&
condition2ThatisReallyLong &&
condition3ThatisReallyLong &&
condition4ThatisReallyLong {
foo()
}
Is complaining about the former but not the latter the intended behavior?
From a coding style perspective, I submit that the first multi-line if statement should be preferred - it helps distinguish between the conditionals and the block code. (Furthermore, this style strikes me as the conventional Golang standard, although I have no empirical data with which to back up that claim. gofmt
seems to be fine with both styles.)
This is completely opinion-based. I find this:
func CryptoGenericHash(buffer string, watermark []byte) ([]byte, error) {
// Convert hex buffer to bytes
bufferBytes, err := hex.DecodeString(buffer)
if err != nil {
return []byte{0}, errors.Wrap(err, "Unable to hex decode buffer bytes")
}
}
more cumbersome to read than this:
func CryptoGenericHash(buffer string, watermark []byte) ([]byte, error) {
// Convert hex buffer to bytes
bufferBytes, err := hex.DecodeString(buffer)
if err != nil {
return []byte{0}, errors.Wrap(err, "Unable to hex decode buffer bytes")
}
}
I really enjoy having that blank space right after func declarations. My code seems less "cluttered" with that spacing. Is there a way to disable this specific check but keep the others?
Suggestion: Ignore (or option to ignore) empty line after a function declaration that takes more than a single line. If the empty line is removed after, it makes it a lot harder to read.
Sample:
// Connect connects to the scylla database.
func Connect(ctx context.Context, connStrs []string, user string, pass string, keyspace string,
tlsCa string, clientCert string, clientKey string) (*Conn, error) {
conn, err := scylla.Connect(connStrs, user, pass, keyspace, tlsCa, clientCert, clientKey)
if err != nil { ... }
}
Please add some instructions to the README
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.