1
0
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:
sina safari 2021-06-01 00:24:58 +04:30 committed by GitHub
parent c4d52d202d
commit b5ff6325c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 14 additions and 13 deletions

View File

@ -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) {

View File

@ -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}

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,