Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
reduced Lint cognitive complexity
  • Loading branch information
Akshay2191 committed Oct 7, 2025
commit a5e6be4ffc2ff1283087a90e90cfd3fa6b6f7f28
25 changes: 15 additions & 10 deletions internal/datasource/config/nginx_config_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,6 @@ func validateAPIResponse(apiType string, bodyBytes []byte) error {
return nil
}

//nolint:revive //need to reduce cognitive complexity
func (ncp *NginxConfigParser) apiDetailsFromLocationDirective(
ctx context.Context, parent, current *crossplane.Directive,
locationDirectiveName string,
Expand All @@ -711,15 +710,7 @@ func (ncp *NginxConfigParser) apiDetailsFromLocationDirective(
addresses := ncp.parseAddressFromServerDirective(parent)
path := ncp.parsePathFromLocationDirective(current)

writeEnabled := false
if locChild.Directive == plusAPIDirective {
for _, arg := range locChild.Args {
if strings.EqualFold(arg, "write=on") {
writeEnabled = true
break
}
}
}
writeEnabled := ncp.isWriteEnabled(locChild)

if locChild.Directive == locationDirectiveName {
for _, address := range addresses {
Expand Down Expand Up @@ -922,6 +913,20 @@ func (ncp *NginxConfigParser) isDuplicateFile(nginxConfigContextFiles []*mpi.Fil
return false
}

func (ncp *NginxConfigParser) isWriteEnabled(locChild *crossplane.Directive) bool {
if locChild.Directive != plusAPIDirective {
return false
}

for _, arg := range locChild.Args {
if strings.EqualFold(arg, "write=on") {
return true
}
}

return false
}

func (ncp *NginxConfigParser) sortPlusAPIs(apis []*model.APIDetails) []*model.APIDetails {
slices.SortFunc(apis, func(a, b *model.APIDetails) int {
if a.WriteEnabled && !b.WriteEnabled {
Expand Down
Loading