Giter Club home page Giter Club logo

whitespace's People

Contributors

bombsimon avatar nisevoid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

whitespace's Issues

should not complain about unnecessary whitespace if func decleration is spread over multiple lines

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?)

Inline function not recognized as multi-line function

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.

Whitespace complains about multi-line if statements

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.)

Option to ignore newline in functions

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: Don't lint leading empty line after function using multiple lines

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 { ... }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.