Skip to content

Commit

Permalink
fix semgrep rules
Browse files Browse the repository at this point in the history
  • Loading branch information
ashishshinde-pubm committed Mar 25, 2024
1 parent 9bab81f commit 1c28d86
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
22 changes: 11 additions & 11 deletions adapters/ortbbidder/ortbbidder.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ import (
"github.com/prebid/prebid-server/openrtb_ext"
)

// oRTBAdapter implements adapters.Bidder interface
type oRTBAdapter struct {
oRTBAdapterInfo
// adapter implements adapters.Bidder interface
type adapter struct {
adapterInfo
}

const (
RequestModeSingle string = "single"
)

// oRTBAdapterInfo contains oRTB bidder specific info required in MakeRequests/MakeBids functions
type oRTBAdapterInfo struct {
// adapterInfo contains oRTB bidder specific info required in MakeRequests/MakeBids functions
type adapterInfo struct {
config.Adapter
requestMode string
}
Expand All @@ -30,7 +30,7 @@ type ExtraAdapterInfo struct {
}

// prepareRequestData generates the RequestData by marshalling the request and returns it
func (o oRTBAdapterInfo) prepareRequestData(request *openrtb2.BidRequest) (*adapters.RequestData, error) {
func (o adapterInfo) prepareRequestData(request *openrtb2.BidRequest) (*adapters.RequestData, error) {
if request == nil {
return nil, fmt.Errorf("found nil request")
}
Expand All @@ -54,17 +54,17 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server co
return nil, fmt.Errorf("Failed to parse extra_info for bidder:[%s] err:[%s]", bidderName, err.Error())
}
}
return &oRTBAdapter{
oRTBAdapterInfo: oRTBAdapterInfo{config, extraAdapterInfo.RequestMode},
return &adapter{
adapterInfo: adapterInfo{config, extraAdapterInfo.RequestMode},
}, nil
}

// MakeRequests prepares oRTB bidder-specific request information using which prebid server make call(s) to bidder.
func (o *oRTBAdapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) {
func (o *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) {
if request == nil || requestInfo == nil {
return nil, []error{fmt.Errorf("Found either nil request or nil requestInfo")}
}
adapterInfo := o.oRTBAdapterInfo
adapterInfo := o.adapterInfo
// bidder request supports single impression in single HTTP call.
if adapterInfo.requestMode == RequestModeSingle {
requestData := make([]*adapters.RequestData, 0, len(request.Imp))
Expand All @@ -88,7 +88,7 @@ func (o *oRTBAdapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *ad
}

// MakeBids prepares bidderResponse from the oRTB bidder server's http.Response
func (o *oRTBAdapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) {
func (o *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) {
if responseData == nil || adapters.IsResponseStatusCodeNoContent(responseData) {
return nil, nil
}
Expand Down
20 changes: 10 additions & 10 deletions adapters/ortbbidder/ortbbidder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestMakeRequests(t *testing.T) {
type args struct {
request *openrtb2.BidRequest
requestInfo *adapters.ExtraRequestInfo
adapterInfo oRTBAdapterInfo
adapterInfo adapterInfo
}
type want struct {
requestData []*adapters.RequestData
Expand Down Expand Up @@ -57,7 +57,7 @@ func TestMakeRequests(t *testing.T) {
requestInfo: &adapters.ExtraRequestInfo{
BidderCoreName: openrtb_ext.BidderName("ortb_test_multi_requestmode"),
},
adapterInfo: oRTBAdapterInfo{config.Adapter{Endpoint: "http://test_bidder.com"}, ""},
adapterInfo: adapterInfo{config.Adapter{Endpoint: "http://test_bidder.com"}, ""},
},
want: want{
requestData: []*adapters.RequestData{
Expand All @@ -82,7 +82,7 @@ func TestMakeRequests(t *testing.T) {
requestInfo: &adapters.ExtraRequestInfo{
BidderCoreName: openrtb_ext.BidderName("ortb_test_single_requestmode"),
},
adapterInfo: oRTBAdapterInfo{config.Adapter{Endpoint: "http://test_bidder.com"}, "single"},
adapterInfo: adapterInfo{config.Adapter{Endpoint: "http://test_bidder.com"}, "single"},
},
want: want{
requestData: []*adapters.RequestData{
Expand All @@ -102,7 +102,7 @@ func TestMakeRequests(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
adapter := &oRTBAdapter{oRTBAdapterInfo: tt.args.adapterInfo}
adapter := &adapter{adapterInfo: tt.args.adapterInfo}
requestData, errors := adapter.MakeRequests(tt.args.request, tt.args.requestInfo)
assert.Equalf(t, tt.want.requestData, requestData, "mismatched requestData")
assert.Equalf(t, tt.want.errors, errors, "mismatched errors")
Expand Down Expand Up @@ -205,7 +205,7 @@ func TestMakeBids(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
adapter := &oRTBAdapter{}
adapter := &adapter{}
response, errs := adapter.MakeBids(tt.args.request, tt.args.requestData, tt.args.responseData)
assert.Equalf(t, tt.want.response, response, "mismatched response")
assert.Equalf(t, tt.want.errors, errs, "mismatched errors")
Expand Down Expand Up @@ -404,7 +404,7 @@ func Test_oRTBAdapterInfo_prepareRequestData(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
o := oRTBAdapterInfo{
o := adapterInfo{
Adapter: tt.fields.Adapter,
requestMode: tt.fields.requestMode,
}
Expand Down Expand Up @@ -454,8 +454,8 @@ func TestBuilder(t *testing.T) {
server: config.Server{},
},
want: want{
bidder: &oRTBAdapter{
oRTBAdapterInfo: oRTBAdapterInfo{
bidder: &adapter{
adapterInfo: adapterInfo{
requestMode: "single",
Adapter: config.Adapter{
ExtraAdapterInfo: `{"requestMode":"single"}`,
Expand All @@ -475,8 +475,8 @@ func TestBuilder(t *testing.T) {
server: config.Server{},
},
want: want{
bidder: &oRTBAdapter{
oRTBAdapterInfo: oRTBAdapterInfo{
bidder: &adapter{
adapterInfo: adapterInfo{
Adapter: config.Adapter{
ExtraAdapterInfo: ``,
},
Expand Down

0 comments on commit 1c28d86

Please sign in to comment.