mirror of
https://github.com/mgechev/revive.git
synced 2025-11-29 22:28:23 +02:00
Adds new rule empty-block (#14)
* Adds rule superfluous-else (an extension of indent-error-flow) * initial (non functional) version * empty-block working version * adds tests for empty-block rule * Adds empty-block to the rules table * code clean-up
This commit is contained in:
33
fixtures/empty-block.go
Normal file
33
fixtures/empty-block.go
Normal file
@@ -0,0 +1,33 @@
|
||||
// Test of empty-blocks.
|
||||
|
||||
package fixtures
|
||||
|
||||
func f(x int) bool { // MATCH /this block is empty, you can remove it/
|
||||
|
||||
}
|
||||
|
||||
func g(f func() bool) string {
|
||||
{ // MATCH /this block is empty, you can remove it/
|
||||
}
|
||||
|
||||
if ok := f(); ok { // MATCH /this block is empty, you can remove it/
|
||||
// only a comment
|
||||
} else {
|
||||
println("it's NOT empty!")
|
||||
}
|
||||
|
||||
if ok := f(); ok {
|
||||
println("it's NOT empty!")
|
||||
} else { // MATCH /this block is empty, you can remove it/
|
||||
|
||||
}
|
||||
|
||||
for i := 0; i < 10; i++ { // MATCH /this block is empty, you can remove it/
|
||||
|
||||
}
|
||||
|
||||
for { // MATCH /this block is empty, you can remove it/
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user