File tree Expand file tree Collapse file tree 6 files changed +68
-8
lines changed Expand file tree Collapse file tree 6 files changed +68
-8
lines changed Original file line number Diff line number Diff line change @@ -2243,23 +2243,37 @@ linters-settings:
22432243 # still required to have `t.Parallel`, but subtests are allowed to skip it.
22442244 # Default: false
22452245 ignore-missing-subtests : true
2246-
22472246 perfsprint :
2247+ # Enable/disable optimization of integer formatting.
2248+ # Default: true
2249+ integer-format : false
22482250 # Optimizes even if it requires an int or uint type cast.
22492251 # Default: true
22502252 int-conversion : false
2253+ # Enable/disable optimization of error formatting.
2254+ # Default: true
2255+ error-format : false
22512256 # Optimizes into `err.Error()` even if it is only equivalent for non-nil errors.
22522257 # Default: false
22532258 err-error : true
22542259 # Optimizes `fmt.Errorf`.
22552260 # Default: true
22562261 errorf : false
2262+ # Enable/disable optimization of string formatting.
2263+ # Default: true
2264+ string-format : false
22572265 # Optimizes `fmt.Sprintf` with only one argument.
22582266 # Default: true
22592267 sprintf1 : false
22602268 # Optimizes into strings concatenation.
22612269 # Default: true
22622270 strconcat : false
2271+ # Enable/disable optimization of bool formatting.
2272+ # Default: true
2273+ bool-format : false
2274+ # Enable/disable optimization of hex formatting.
2275+ # Default: true
2276+ hex-format : false
22632277
22642278 prealloc :
22652279 # IMPORTANT: we don't recommend using this linter before doing performance profiling.
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ require (
2929 github.com/breml/errchkjson v0.4.0
3030 github.com/butuzov/ireturn v0.3.1
3131 github.com/butuzov/mirror v1.3.0
32- github.com/catenacyber/perfsprint v0.7.1
32+ github.com/catenacyber/perfsprint v0.8.0
3333 github.com/charithe/durationcheck v0.0.10
3434 github.com/ckaznocha/intrange v0.3.0
3535 github.com/curioswitch/go-reassign v0.3.0
Original file line number Diff line number Diff line change 24722472 "type" : " object" ,
24732473 "additionalProperties" : false ,
24742474 "properties" : {
2475+ "integer-format" : {
2476+ "description" : " Enable/disable optimization of integer formatting." ,
2477+ "type" : " boolean" ,
2478+ "default" : true
2479+ },
24752480 "int-conversion" : {
24762481 "description" : " Optimizes even if it requires an int or uint type cast." ,
24772482 "type" : " boolean" ,
24782483 "default" : true
24792484 },
2485+ "error-format" : {
2486+ "description" : " Enable/disable optimization of error formatting." ,
2487+ "type" : " boolean" ,
2488+ "default" : true
2489+ },
24802490 "err-error" : {
24812491 "description" : " Optimizes into `err.Error()` even if it is only equivalent for non-nil errors." ,
24822492 "type" : " boolean" ,
24872497 "type" : " boolean" ,
24882498 "default" : true
24892499 },
2500+ "string-format" : {
2501+ "description" : " Enable/disable optimization of string formatting." ,
2502+ "type" : " boolean" ,
2503+ "default" : true
2504+ },
24902505 "sprintf1" : {
24912506 "description" : " Optimizes `fmt.Sprintf` with only one argument." ,
24922507 "type" : " boolean" ,
24962511 "description" : " Optimizes into strings concatenation." ,
24972512 "type" : " boolean" ,
24982513 "default" : true
2514+ },
2515+ "bool-format" : {
2516+ "description" : " Enable/disable optimization of bool formatting." ,
2517+ "type" : " boolean" ,
2518+ "default" : true
2519+ },
2520+ "hex-format" : {
2521+ "description" : " Enable/disable optimization of hex formatting." ,
2522+ "type" : " boolean" ,
2523+ "default" : true
24992524 }
25002525 }
25012526 },
Original file line number Diff line number Diff line change @@ -126,11 +126,16 @@ var defaultLintersSettings = LintersSettings{
126126 AllowUnused : false ,
127127 },
128128 PerfSprint : PerfSprintSettings {
129+ IntegerFormat : true ,
129130 IntConversion : true ,
131+ ErrorFormat : true ,
130132 ErrError : false ,
131133 ErrorF : true ,
134+ StringFormat : true ,
132135 SprintF1 : true ,
133136 StrConcat : true ,
137+ BoolFormat : true ,
138+ HexFormat : true ,
134139 },
135140 Prealloc : PreallocSettings {
136141 Simple : true ,
@@ -791,11 +796,19 @@ type ParallelTestSettings struct {
791796}
792797
793798type PerfSprintSettings struct {
799+ IntegerFormat bool `mapstructure:"integer-format"`
794800 IntConversion bool `mapstructure:"int-conversion"`
795- ErrError bool `mapstructure:"err-error"`
796- ErrorF bool `mapstructure:"errorf"`
797- SprintF1 bool `mapstructure:"sprintf1"`
798- StrConcat bool `mapstructure:"strconcat"`
801+
802+ ErrorFormat bool `mapstructure:"error-format"`
803+ ErrError bool `mapstructure:"err-error"`
804+ ErrorF bool `mapstructure:"errorf"`
805+
806+ StringFormat bool `mapstructure:"string-format"`
807+ SprintF1 bool `mapstructure:"sprintf1"`
808+ StrConcat bool `mapstructure:"strconcat"`
809+
810+ BoolFormat bool `mapstructure:"bool-format"`
811+ HexFormat bool `mapstructure:"hex-format"`
799812}
800813
801814type PreallocSettings struct {
Original file line number Diff line number Diff line change @@ -16,11 +16,19 @@ func New(settings *config.PerfSprintSettings) *goanalysis.Linter {
1616 }
1717
1818 if settings != nil {
19+ cfg [a .Name ]["integer-format" ] = settings .IntegerFormat
1920 cfg [a .Name ]["int-conversion" ] = settings .IntConversion
21+
22+ cfg [a .Name ]["error-format" ] = settings .ErrorFormat
2023 cfg [a .Name ]["err-error" ] = settings .ErrError
2124 cfg [a .Name ]["errorf" ] = settings .ErrorF
25+
26+ cfg [a .Name ]["string-format" ] = settings .StringFormat
2227 cfg [a .Name ]["sprintf1" ] = settings .SprintF1
2328 cfg [a .Name ]["strconcat" ] = settings .StrConcat
29+
30+ cfg [a .Name ]["bool-format" ] = settings .BoolFormat
31+ cfg [a .Name ]["hex-format" ] = settings .HexFormat
2432 }
2533
2634 return goanalysis .NewLinter (
You can’t perform that action at this time.
0 commit comments