replace interface{} with any. (#1771)

This commit is contained in:
ahrav
2023-09-15 04:35:15 -07:00
committed by GitHub
parent dbcb888063
commit 22876f8381
7 changed files with 22 additions and 22 deletions
+1 -1
View File
@@ -96,7 +96,7 @@ func constructRequest(secret, keyID string) (*http.Request, error) {
return nil, err return nil, err
} }
params := map[string]interface{}{ params := map[string]any{
"request": accountDetail, "request": accountDetail,
"nonce": time.Now().UnixNano(), "nonce": time.Now().UnixNano(),
} }
+3 -3
View File
@@ -83,8 +83,8 @@ func (s Scanner) Type() detectorspb.DetectorType {
type typeRes struct { type typeRes struct {
Types []struct { Types []struct {
Name string `json:"name"` Name string `json:"name"`
Type interface{} `json:"type"` Type any `json:"type"`
Parameters []interface{} `json:"parameters"` Parameters []any `json:"parameters"`
} `json:"types"` } `json:"types"`
} }
+1 -1
View File
@@ -21,7 +21,7 @@ var (
ErrUncrackable = errors.New("unable to crack encryption") ErrUncrackable = errors.New("unable to crack encryption")
) )
func crack(in []byte) (interface{}, string, error) { func crack(in []byte) (any, string, error) {
for _, passphrase := range passphrases { for _, passphrase := range passphrases {
parsed, err := ssh.ParseRawPrivateKeyWithPassphrase(in, passphrase) parsed, err := ssh.ParseRawPrivateKeyWithPassphrase(in, passphrase)
if err != nil { if err != nil {
+1 -1
View File
@@ -239,7 +239,7 @@ func (m *Metrics) getScanDuration() time.Duration {
func (e *Engine) DetectorAvgTime() map[string][]time.Duration { func (e *Engine) DetectorAvgTime() map[string][]time.Duration {
logger := context.Background().Logger() logger := context.Background().Logger()
avgTime := map[string][]time.Duration{} avgTime := map[string][]time.Duration{}
e.metrics.detectorAvgTime.Range(func(k, v interface{}) bool { e.metrics.detectorAvgTime.Range(func(k, v any) bool {
key, ok := k.(string) key, ok := k.(string)
if !ok { if !ok {
logger.Info("expected detectorAvgTime key to be a string") logger.Info("expected detectorAvgTime key to be a string")
+2 -2
View File
@@ -76,7 +76,7 @@ func (p *PlainPrinter) Print(_ context.Context, r *detectors.ResultWithMetadata)
} }
} }
aggregateData := make(map[string]interface{}) aggregateData := make(map[string]any)
var aggregateDataKeys []string var aggregateDataKeys []string
for _, data := range meta { for _, data := range meta {
@@ -93,7 +93,7 @@ func (p *PlainPrinter) Print(_ context.Context, r *detectors.ResultWithMetadata)
return nil return nil
} }
func structToMap(obj interface{}) (m map[string]map[string]interface{}, err error) { func structToMap(obj any) (m map[string]map[string]any, err error) {
data, err := json.Marshal(obj) data, err := json.Marshal(obj)
if err != nil { if err != nil {
return return
+4 -4
View File
@@ -190,13 +190,13 @@ func TestAddMembersByApp(t *testing.T) {
gock.New("https://api.github.com"). gock.New("https://api.github.com").
Get("/app/installations"). Get("/app/installations").
Reply(200). Reply(200).
JSON([]map[string]interface{}{ JSON([]map[string]any{
{"account": map[string]string{"login": "super-secret-org", "type": "Organization"}}, {"account": map[string]string{"login": "super-secret-org", "type": "Organization"}},
}) })
gock.New("https://api.github.com"). gock.New("https://api.github.com").
Get("/orgs/super-secret-org/members"). Get("/orgs/super-secret-org/members").
Reply(200). Reply(200).
JSON([]map[string]interface{}{ JSON([]map[string]any{
{"login": "ssm1"}, {"login": "ssm1"},
{"login": "ssm2"}, {"login": "ssm2"},
{"login": "ssm3"}, {"login": "ssm3"},
@@ -221,7 +221,7 @@ func TestAddReposByApp(t *testing.T) {
gock.New("https://api.github.com"). gock.New("https://api.github.com").
Get("/installation/repositories"). Get("/installation/repositories").
Reply(200). Reply(200).
JSON(map[string]interface{}{ JSON(map[string]any{
"repositories": []map[string]string{ "repositories": []map[string]string{
{"clone_url": "https://github/ssr1.git", "full_name": "ssr1"}, {"clone_url": "https://github/ssr1.git", "full_name": "ssr1"},
{"clone_url": "https://github/ssr2.git", "full_name": "ssr2"}, {"clone_url": "https://github/ssr2.git", "full_name": "ssr2"},
@@ -247,7 +247,7 @@ func TestAddOrgsByUser(t *testing.T) {
gock.New("https://api.github.com"). gock.New("https://api.github.com").
Get("/user/orgs"). Get("/user/orgs").
Reply(200). Reply(200).
JSON([]map[string]interface{}{ JSON([]map[string]any{
{"login": "sso2"}, {"login": "sso2"},
}) })
+10 -10
View File
@@ -41,7 +41,7 @@ func (m *MockJobProgressHook) End(arg0 JobProgressRef, arg1 time.Time) {
} }
// End indicates an expected call of End. // End indicates an expected call of End.
func (mr *MockJobProgressHookMockRecorder) End(arg0, arg1 interface{}) *gomock.Call { func (mr *MockJobProgressHookMockRecorder) End(arg0, arg1 any) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "End", reflect.TypeOf((*MockJobProgressHook)(nil).End), arg0, arg1) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "End", reflect.TypeOf((*MockJobProgressHook)(nil).End), arg0, arg1)
} }
@@ -53,7 +53,7 @@ func (m *MockJobProgressHook) EndEnumerating(arg0 JobProgressRef, arg1 time.Time
} }
// EndEnumerating indicates an expected call of EndEnumerating. // EndEnumerating indicates an expected call of EndEnumerating.
func (mr *MockJobProgressHookMockRecorder) EndEnumerating(arg0, arg1 interface{}) *gomock.Call { func (mr *MockJobProgressHookMockRecorder) EndEnumerating(arg0, arg1 any) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EndEnumerating", reflect.TypeOf((*MockJobProgressHook)(nil).EndEnumerating), arg0, arg1) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EndEnumerating", reflect.TypeOf((*MockJobProgressHook)(nil).EndEnumerating), arg0, arg1)
} }
@@ -65,7 +65,7 @@ func (m *MockJobProgressHook) EndUnitChunking(arg0 JobProgressRef, arg1 SourceUn
} }
// EndUnitChunking indicates an expected call of EndUnitChunking. // EndUnitChunking indicates an expected call of EndUnitChunking.
func (mr *MockJobProgressHookMockRecorder) EndUnitChunking(arg0, arg1, arg2 interface{}) *gomock.Call { func (mr *MockJobProgressHookMockRecorder) EndUnitChunking(arg0, arg1, arg2 any) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EndUnitChunking", reflect.TypeOf((*MockJobProgressHook)(nil).EndUnitChunking), arg0, arg1, arg2) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EndUnitChunking", reflect.TypeOf((*MockJobProgressHook)(nil).EndUnitChunking), arg0, arg1, arg2)
} }
@@ -77,7 +77,7 @@ func (m *MockJobProgressHook) Finish(arg0 JobProgressRef) {
} }
// Finish indicates an expected call of Finish. // Finish indicates an expected call of Finish.
func (mr *MockJobProgressHookMockRecorder) Finish(arg0 interface{}) *gomock.Call { func (mr *MockJobProgressHookMockRecorder) Finish(arg0 any) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Finish", reflect.TypeOf((*MockJobProgressHook)(nil).Finish), arg0) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Finish", reflect.TypeOf((*MockJobProgressHook)(nil).Finish), arg0)
} }
@@ -89,7 +89,7 @@ func (m *MockJobProgressHook) ReportChunk(arg0 JobProgressRef, arg1 SourceUnit,
} }
// ReportChunk indicates an expected call of ReportChunk. // ReportChunk indicates an expected call of ReportChunk.
func (mr *MockJobProgressHookMockRecorder) ReportChunk(arg0, arg1, arg2 interface{}) *gomock.Call { func (mr *MockJobProgressHookMockRecorder) ReportChunk(arg0, arg1, arg2 any) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReportChunk", reflect.TypeOf((*MockJobProgressHook)(nil).ReportChunk), arg0, arg1, arg2) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReportChunk", reflect.TypeOf((*MockJobProgressHook)(nil).ReportChunk), arg0, arg1, arg2)
} }
@@ -101,7 +101,7 @@ func (m *MockJobProgressHook) ReportError(arg0 JobProgressRef, arg1 error) {
} }
// ReportError indicates an expected call of ReportError. // ReportError indicates an expected call of ReportError.
func (mr *MockJobProgressHookMockRecorder) ReportError(arg0, arg1 interface{}) *gomock.Call { func (mr *MockJobProgressHookMockRecorder) ReportError(arg0, arg1 any) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReportError", reflect.TypeOf((*MockJobProgressHook)(nil).ReportError), arg0, arg1) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReportError", reflect.TypeOf((*MockJobProgressHook)(nil).ReportError), arg0, arg1)
} }
@@ -113,7 +113,7 @@ func (m *MockJobProgressHook) ReportUnit(arg0 JobProgressRef, arg1 SourceUnit) {
} }
// ReportUnit indicates an expected call of ReportUnit. // ReportUnit indicates an expected call of ReportUnit.
func (mr *MockJobProgressHookMockRecorder) ReportUnit(arg0, arg1 interface{}) *gomock.Call { func (mr *MockJobProgressHookMockRecorder) ReportUnit(arg0, arg1 any) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReportUnit", reflect.TypeOf((*MockJobProgressHook)(nil).ReportUnit), arg0, arg1) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReportUnit", reflect.TypeOf((*MockJobProgressHook)(nil).ReportUnit), arg0, arg1)
} }
@@ -125,7 +125,7 @@ func (m *MockJobProgressHook) Start(arg0 JobProgressRef, arg1 time.Time) {
} }
// Start indicates an expected call of Start. // Start indicates an expected call of Start.
func (mr *MockJobProgressHookMockRecorder) Start(arg0, arg1 interface{}) *gomock.Call { func (mr *MockJobProgressHookMockRecorder) Start(arg0, arg1 any) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Start", reflect.TypeOf((*MockJobProgressHook)(nil).Start), arg0, arg1) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Start", reflect.TypeOf((*MockJobProgressHook)(nil).Start), arg0, arg1)
} }
@@ -137,7 +137,7 @@ func (m *MockJobProgressHook) StartEnumerating(arg0 JobProgressRef, arg1 time.Ti
} }
// StartEnumerating indicates an expected call of StartEnumerating. // StartEnumerating indicates an expected call of StartEnumerating.
func (mr *MockJobProgressHookMockRecorder) StartEnumerating(arg0, arg1 interface{}) *gomock.Call { func (mr *MockJobProgressHookMockRecorder) StartEnumerating(arg0, arg1 any) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StartEnumerating", reflect.TypeOf((*MockJobProgressHook)(nil).StartEnumerating), arg0, arg1) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StartEnumerating", reflect.TypeOf((*MockJobProgressHook)(nil).StartEnumerating), arg0, arg1)
} }
@@ -149,7 +149,7 @@ func (m *MockJobProgressHook) StartUnitChunking(arg0 JobProgressRef, arg1 Source
} }
// StartUnitChunking indicates an expected call of StartUnitChunking. // StartUnitChunking indicates an expected call of StartUnitChunking.
func (mr *MockJobProgressHookMockRecorder) StartUnitChunking(arg0, arg1, arg2 interface{}) *gomock.Call { func (mr *MockJobProgressHookMockRecorder) StartUnitChunking(arg0, arg1, arg2 any) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StartUnitChunking", reflect.TypeOf((*MockJobProgressHook)(nil).StartUnitChunking), arg0, arg1, arg2) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StartUnitChunking", reflect.TypeOf((*MockJobProgressHook)(nil).StartUnitChunking), arg0, arg1, arg2)
} }