mirror of
https://github.com/mgechev/revive.git
synced 2025-11-25 22:12:38 +02:00
simplify: redundant map composite literal (#528)
This commit is contained in:
@@ -2,10 +2,11 @@ package rule
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/mgechev/revive/lint"
|
|
||||||
"go/ast"
|
"go/ast"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/mgechev/revive/lint"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -18,7 +19,7 @@ const (
|
|||||||
type whiteList map[string]map[string]bool
|
type whiteList map[string]map[string]bool
|
||||||
|
|
||||||
func newWhiteList() whiteList {
|
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) {
|
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{
|
var gcTriggeringFunctions = map[string]map[string]bool{
|
||||||
"runtime": map[string]bool{"GC": true},
|
"runtime": {"GC": true},
|
||||||
}
|
}
|
||||||
|
|
||||||
w := lintCallToGC{onFailure, gcTriggeringFunctions}
|
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{
|
var exitFunctions = map[string]map[string]bool{
|
||||||
"os": map[string]bool{"Exit": true},
|
"os": {"Exit": true},
|
||||||
"syscall": map[string]bool{"Exit": true},
|
"syscall": {"Exit": true},
|
||||||
"log": map[string]bool{
|
"log": {
|
||||||
"Fatal": true,
|
"Fatal": true,
|
||||||
"Fatalf": true,
|
"Fatalf": true,
|
||||||
"Fatalln": 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{
|
var branchingFunctions = map[string]map[string]bool{
|
||||||
"os": map[string]bool{"Exit": true},
|
"os": {"Exit": true},
|
||||||
"log": map[string]bool{
|
"log": {
|
||||||
"Fatal": true,
|
"Fatal": true,
|
||||||
"Fatalf": true,
|
"Fatalf": true,
|
||||||
"Fatalln": true,
|
"Fatalln": true,
|
||||||
|
|||||||
@@ -137,9 +137,9 @@ func (w *lintUnconditionalRecursionRule) updateFuncStatus(node ast.Node) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var exitFunctions = map[string]map[string]bool{
|
var exitFunctions = map[string]map[string]bool{
|
||||||
"os": map[string]bool{"Exit": true},
|
"os": {"Exit": true},
|
||||||
"syscall": map[string]bool{"Exit": true},
|
"syscall": {"Exit": true},
|
||||||
"log": map[string]bool{
|
"log": {
|
||||||
"Fatal": true,
|
"Fatal": true,
|
||||||
"Fatalf": true,
|
"Fatalf": true,
|
||||||
"Fatalln": 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{
|
var branchingFunctions = map[string]map[string]bool{
|
||||||
"os": map[string]bool{"Exit": true},
|
"os": {"Exit": true},
|
||||||
"log": map[string]bool{
|
"log": {
|
||||||
"Fatal": true,
|
"Fatal": true,
|
||||||
"Fatalf": true,
|
"Fatalf": true,
|
||||||
"Fatalln": true,
|
"Fatalln": true,
|
||||||
|
|||||||
Reference in New Issue
Block a user