1
0
mirror of https://github.com/mgechev/revive.git synced 2024-11-28 08:49:11 +02:00
revive/testdata
Abhinav Gupta b03e54f617
empty-block: Fix false positive on select {} (#805)
This fixes a false positive reported by revive on the following:

    select {}

This is a way to block the program indefinitely.
It is used in cases like:

- Running a long-running server in a background thread
  and blocking `main` from exiting until the application dies.
  This is something you might do if your process has
  multiple servers/listeners in the same process.

  ```go
  go grpcListenAndServe()
  go httpListenAndServe()
  go logFlusher()

  select {}
  ```

- In programs compiled to WASM to prevent the application from exiting,
  so that the Javascript components may interact with it.

  ```go
  func main() {
    js.Global().Set("foo", foo)
    select {}
  }
  ```

  Without this, one may see an error like,
  "Error: Go program has already exited"

As a workaround, these programs can block forever
by receiving from a throwaway channel (`<-make(chan struct{})`),
but `select {}` is still a completely valid way of doing this,
so supporting it makes sense.

The issue was previously reported in #698 but was closed
because the author was satisfied with a `//nolint` comment.

Now that this rule is part of the default rule set (#799)
the case for addressing the false positive is stronger.

Resolves #804
2023-03-16 13:39:52 -07:00
..
golint add golint's package name MixedCaps rule as in 83fdc39ff7/lint.go (L561-L563) (#797) 2023-02-27 19:56:30 +01:00
add-constant.go fix #759 [rule.add-constant] change 'ignoreFuncs' expressions in documentation and test (#760) 2022-10-15 11:24:32 +02:00
argument-limit.go renames fixtures as testdata to avoid spurious dependencies (#359) 2020-03-02 09:12:43 -10:00
atomic.go renames fixtures as testdata to avoid spurious dependencies (#359) 2020-03-02 09:12:43 -10:00
banned-characters.go Add banned characters rule (#532) (#591) 2021-10-14 20:56:29 +02:00
bare-return.go renames fixtures as testdata to avoid spurious dependencies (#359) 2020-03-02 09:12:43 -10:00
bool-literal-in-expr.go renames fixtures as testdata to avoid spurious dependencies (#359) 2020-03-02 09:12:43 -10:00
call-to-gc.go renames fixtures as testdata to avoid spurious dependencies (#359) 2020-03-02 09:12:43 -10:00
cognitive-complexity.go fixes issue #451 (#452) 2020-08-05 19:25:57 +03:00
comment-spacings.go fixing comment spacings (#789) 2023-02-17 21:03:11 +01:00
confusing-naming1.go renames fixtures as testdata to avoid spurious dependencies (#359) 2020-03-02 09:12:43 -10:00
confusing-naming2.go renames fixtures as testdata to avoid spurious dependencies (#359) 2020-03-02 09:12:43 -10:00
confusing-results.go renames fixtures as testdata to avoid spurious dependencies (#359) 2020-03-02 09:12:43 -10:00
constant-logical-expr.go Incorrect handling of token.{LEQ,GEQ} for constant-logical-expr (#642) 2022-02-27 09:37:51 +01:00
context-as-argument.go Allow whitelist for the context parameter check (#616) 2021-12-31 17:11:18 -08:00
cyclomatic-2.go refactor(cyclomatic): improved message for cyclomatic rule (#629) 2022-01-31 17:33:43 +01:00
cyclomatic.go refactor(cyclomatic): improved message for cyclomatic rule (#629) 2022-01-31 17:33:43 +01:00
datarace.go add rule datarace (#683) 2022-04-18 09:45:42 -07:00
deep-exit_test.go renames fixtures as testdata to avoid spurious dependencies (#359) 2020-03-02 09:12:43 -10:00
deep-exit.go renames fixtures as testdata to avoid spurious dependencies (#359) 2020-03-02 09:12:43 -10:00
defer-loop-disabled.go adds defer rule 2020-06-08 09:40:38 -07:00
defer-only-loop-enabled.go adds defer rule 2020-06-08 09:40:38 -07:00
defer.go Capture yet more bad defer / recover patterns (#719) 2022-07-24 09:34:16 +02:00
disable-annotations2.go renames fixtures as testdata to avoid spurious dependencies (#359) 2020-03-02 09:12:43 -10:00
disable-annotations3.go fix issue #540 (#543) 2021-07-11 21:31:46 -07:00
disable-annotations.go renames fixtures as testdata to avoid spurious dependencies (#359) 2020-03-02 09:12:43 -10:00
duplicated-imports.go renames fixtures as testdata to avoid spurious dependencies (#359) 2020-03-02 09:12:43 -10:00
early-return.go Fix early-return false positive and other tweaks (#776) 2022-11-27 13:23:51 +01:00
empty-block.go empty-block: Fix false positive on select {} (#805) 2023-03-16 13:39:52 -07:00
empty-lines.go fix bug #739: empty-lines false positive (#742) 2022-08-27 13:18:17 +02:00
error-strings-with-custom-functions.go Allow to customize user functions in rule error-strings (#703) 2022-07-05 21:51:50 +02:00
exported-issue-519.go Exported config (#565) 2021-08-26 08:36:24 -07:00
exported-issue-552.go Exported config (#565) 2021-08-26 08:36:24 -07:00
exported-issue-555.go Exported config (#565) 2021-08-26 08:36:24 -07:00
flag-param.go renames fixtures as testdata to avoid spurious dependencies (#359) 2020-03-02 09:12:43 -10:00
function-length1.go new rule function-length (#504) 2021-03-20 15:45:30 -07:00
function-length2.go new rule function-length (#504) 2021-03-20 15:45:30 -07:00
function-length3.go new rule function-length (#504) 2021-03-20 15:45:30 -07:00
function-result-limit.go renames fixtures as testdata to avoid spurious dependencies (#359) 2020-03-02 09:12:43 -10:00
get-return.go renames fixtures as testdata to avoid spurious dependencies (#359) 2020-03-02 09:12:43 -10:00
identical-branches.go identical-branches initial implementation 2020-05-08 22:08:16 +02:00
if-return.go fix issue #537 (#538) 2021-06-29 13:04:51 -07:00
import-shadowing.go fix 534 (#536) 2021-06-29 21:40:40 +02:00
imports-blacklist-original.go Fixes issue #619 imports-blacklist support regex (#684) 2022-04-21 16:04:00 +02:00
imports-blacklist.go Fixes issue #619 imports-blacklist support regex (#684) 2022-04-21 16:04:00 +02:00
line-length-limit.go renames fixtures as testdata to avoid spurious dependencies (#359) 2020-03-02 09:12:43 -10:00
lint-file-header1.go renames fixtures as testdata to avoid spurious dependencies (#359) 2020-03-02 09:12:43 -10:00
lint-file-header2.go renames fixtures as testdata to avoid spurious dependencies (#359) 2020-03-02 09:12:43 -10:00
lint-file-header3.go renames fixtures as testdata to avoid spurious dependencies (#359) 2020-03-02 09:12:43 -10:00
lint-file-header4.go renames fixtures as testdata to avoid spurious dependencies (#359) 2020-03-02 09:12:43 -10:00
lint-file-header5.go renames fixtures as testdata to avoid spurious dependencies (#359) 2020-03-02 09:12:43 -10:00
lint-file-header6.go renames fixtures as testdata to avoid spurious dependencies (#359) 2020-03-02 09:12:43 -10:00
max-public-structs.go renames fixtures as testdata to avoid spurious dependencies (#359) 2020-03-02 09:12:43 -10:00
modifies-param.go renames fixtures as testdata to avoid spurious dependencies (#359) 2020-03-02 09:12:43 -10:00
modifies-value-receiver.go renames fixtures as testdata to avoid spurious dependencies (#359) 2020-03-02 09:12:43 -10:00
nested-structs.go fix #781 (#782) 2023-01-26 13:50:35 -08:00
optimize-operands-order.go Add optimize-operands-order rule (#599) (#603) 2021-10-23 09:29:14 +02:00
range-val-address.go range-val-address: improve detection (#647) 2022-03-12 09:32:57 +01:00
range-val-in-closure.go fix issue #637 (#638) 2022-02-15 22:46:24 +01:00
receiver-naming-issue-669.go fix(receiver-naming): distinguish types with parameters (#692) 2022-06-18 18:47:53 +02:00
redefines-builtin-id.go fix issue #792 (#793) 2023-02-18 10:57:06 +01:00
string-format.go Check string literals against regular expressions (#511) 2021-04-18 18:35:30 +02:00
string-of-int.go Add banned characters rule (#532) (#591) 2021-10-14 20:56:29 +02:00
struct-tag-useroptions.go fix issue #520 (#802) 2023-03-14 16:16:12 -07:00
struct-tag.go adds checks for protobuf struct tags (#707) 2022-07-15 11:15:55 -07:00
superfluous-else.go renames fixtures as testdata to avoid spurious dependencies (#359) 2020-03-02 09:12:43 -10:00
time-equal.go add new rule time equal (#584) 2021-10-01 13:55:53 +02:00
time-naming.go fix: time-naming issue #571 (#572) 2021-09-12 16:09:14 -07:00
unconditional-recursion.go fixes false positive in unconditional-recursion 2021-10-15 13:14:03 -07:00
unexported-naming.go new rule: unexported-naming (#443) 2020-07-23 02:17:20 +03:00
unhandled-error-w-ignorelist.go fix #754 [rule.unhandled-error] change arguments to regexp (#757) 2022-11-09 13:13:52 +01:00
unhandled-error.go renames fixtures as testdata to avoid spurious dependencies (#359) 2020-03-02 09:12:43 -10:00
unnecessary-stmt.go renames fixtures as testdata to avoid spurious dependencies (#359) 2020-03-02 09:12:43 -10:00
unreachable-code.go add testing.FailNow and related function to unreachable check (#711) 2022-07-20 15:41:31 -07:00
unused-param.go renames fixtures as testdata to avoid spurious dependencies (#359) 2020-03-02 09:12:43 -10:00
unused-receiver.go renames fixtures as testdata to avoid spurious dependencies (#359) 2020-03-02 09:12:43 -10:00
use-any.go adds rule use-any (#660) 2022-03-29 11:25:38 -07:00
useless-break.go fix issue 556 (#557) 2021-08-16 12:15:17 +02:00
var-naming_test.go fix #622 (Rule 'var-naming' should allow Fuzz_xxx) (#623) 2022-01-18 15:26:29 +01:00
var-naming.go renames fixtures as testdata to avoid spurious dependencies (#359) 2020-03-02 09:12:43 -10:00
waitgroup-by-value.go renames fixtures as testdata to avoid spurious dependencies (#359) 2020-03-02 09:12:43 -10:00