switchchecker

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2023 License: MIT Imports: 11 Imported by: 0

README

switchchecker

This Repository is inspired from https://github.com/knightso/allcases

Install

$ go get github.com/esh2n/switchchecker/cmd/switchchecker

How to use

Usage

$ allcases [-flag] [package]

Annotation

This checker checks for switch statements which have an annotation comment // switchchecker to have all cases for consts of the expression type.

For example if there is a type and consts like:

	type TestKind int

	const (
		TestKindHoge TestKind = iota
		TestKindFuga
		TestKindPiyo
	)

and switch statements like:

	// allcases
	switch v {
	case TestKindHoge:
		// do something
	case TestKindFuga:
		// do something
	}

and also exclude case like:

	// allcases -exclude TestKindFuga
	switch v {
	case TestKindHoge:
		// do something
	}

then the checker reports that the switch statement doesn't have the TestKindPiyo case.

Documentation

Index

Constants

View Source
const Doc = `` /* 565-byte string literal not displayed */

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name:             "switchchecker",
	Doc:              Doc,
	Run:              run,
	RunDespiteErrors: true,
	Requires: []*analysis.Analyzer{
		inspect.Analyzer,
		commentmap.Analyzer,
	},
	FactTypes: []analysis.Fact{new(fact)},
}

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