mirror of
https://github.com/mgechev/revive.git
synced 2025-01-10 03:17:11 +02:00
simplify: redundant map composite literal (#528)
This commit is contained in:
parent
c4d52d202d
commit
b5ff6325c2
@ -2,10 +2,11 @@ package rule
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/mgechev/revive/lint"
|
||||
"go/ast"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/mgechev/revive/lint"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -18,7 +19,7 @@ const (
|
||||
type whiteList map[string]map[string]bool
|
||||
|
||||
func newWhiteList() whiteList {
|
||||
return map[string]map[string]bool{kindINT: map[string]bool{}, kindFLOAT: map[string]bool{}, kindSTRING: map[string]bool{}}
|
||||
return map[string]map[string]bool{kindINT: {}, kindFLOAT: {}, kindSTRING: {}}
|
||||
}
|
||||
|
||||
func (wl whiteList) add(kind string, list string) {
|
||||
|
@ -17,7 +17,7 @@ func (r *CallToGCRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
|
||||
}
|
||||
|
||||
var gcTriggeringFunctions = map[string]map[string]bool{
|
||||
"runtime": map[string]bool{"GC": true},
|
||||
"runtime": {"GC": true},
|
||||
}
|
||||
|
||||
w := lintCallToGC{onFailure, gcTriggeringFunctions}
|
||||
|
@ -18,9 +18,9 @@ func (r *DeepExitRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
|
||||
}
|
||||
|
||||
var exitFunctions = map[string]map[string]bool{
|
||||
"os": map[string]bool{"Exit": true},
|
||||
"syscall": map[string]bool{"Exit": true},
|
||||
"log": map[string]bool{
|
||||
"os": {"Exit": true},
|
||||
"syscall": {"Exit": true},
|
||||
"log": {
|
||||
"Fatal": true,
|
||||
"Fatalf": true,
|
||||
"Fatalln": true,
|
||||
|
@ -19,8 +19,8 @@ func (r *SuperfluousElseRule) Apply(file *lint.File, _ lint.Arguments) []lint.Fa
|
||||
}
|
||||
|
||||
var branchingFunctions = map[string]map[string]bool{
|
||||
"os": map[string]bool{"Exit": true},
|
||||
"log": map[string]bool{
|
||||
"os": {"Exit": true},
|
||||
"log": {
|
||||
"Fatal": true,
|
||||
"Fatalf": true,
|
||||
"Fatalln": true,
|
||||
|
@ -137,9 +137,9 @@ func (w *lintUnconditionalRecursionRule) updateFuncStatus(node ast.Node) {
|
||||
}
|
||||
|
||||
var exitFunctions = map[string]map[string]bool{
|
||||
"os": map[string]bool{"Exit": true},
|
||||
"syscall": map[string]bool{"Exit": true},
|
||||
"log": map[string]bool{
|
||||
"os": {"Exit": true},
|
||||
"syscall": {"Exit": true},
|
||||
"log": {
|
||||
"Fatal": true,
|
||||
"Fatalf": true,
|
||||
"Fatalln": true,
|
||||
|
@ -17,8 +17,8 @@ func (r *UnreachableCodeRule) Apply(file *lint.File, _ lint.Arguments) []lint.Fa
|
||||
}
|
||||
|
||||
var branchingFunctions = map[string]map[string]bool{
|
||||
"os": map[string]bool{"Exit": true},
|
||||
"log": map[string]bool{
|
||||
"os": {"Exit": true},
|
||||
"log": {
|
||||
"Fatal": true,
|
||||
"Fatalf": true,
|
||||
"Fatalln": true,
|
||||
|
Loading…
Reference in New Issue
Block a user