nobreak

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 5, 2021 License: MIT Imports: 5 Imported by: 0

README

nobreak

test_and_lint

nobreak finds infinite for loop

Instruction

go install github.com/sivchari/nobreak/cmd/nobreak

Usage

package sandbox

func infiniteLoop() {
	for { //"this `for statement` occurs infinite loop"
		println("infinite loop")
	}
}

func noCondInfiniteLoop() {
	for i := 0; ; i++ { // "this `for statement` occurs infinite loop"
		println(i)
	}
}

func validLoop() {
	for { // ok
		println("no infinite loop")
		break
	}

	for i := 0; i < 10; i++ { // ok
		println(i)
	}

	for i := 0; ; i++ { // ok
		println(i)
		break
	}
}
fish
go vet -vettool=(which nobreak) ./...

# command-line-arguments
sandbox/main.go:4:2: this `for statement` occurs infinite loop
sandbox/main.go:10:2: this `for statement` occurs infinite loop
bash
$ go vet -vettool=`which nobreak` ./...

# command-line-arguments
sandbox/main.go:4:2: this `for statement` occurs infinite loop
sandbox/main.go:10:2: this `for statement` occurs infinite loop

CI

CircleCI
- run:
    name: Install nobreak
    command: go get github.com/sivchari/nobreak

- run:
    name: Run nobreak
    command: go vet -vettool=`which nobreak` ./...
GitHub Actions
- name: Install nobreak
  run: go get github.com/sivchari/nobreak

- name: Run nobreak
  run: go vet -vettool=`which nobreak` ./...

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name: "nobreak",
	Doc:  doc,
	Run:  run,
	Requires: []*analysis.Analyzer{
		inspect.Analyzer,
	},
}

Analyzer is nobreak analyzer

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL