Skip to content

Commit

Permalink
getOriginLine, getOriginCol
Browse files Browse the repository at this point in the history
  • Loading branch information
reuvenharrison committed Nov 24, 2024
1 parent baa4893 commit 8195d3b
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions checker/api_change.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ type ApiChange struct {

func NewApiChange(id string, config *Config, args []any, comment string, operationsSources *diff.OperationsSourcesMap, operation *openapi3.Operation, method, path string) ApiChange {

line, col := getOrigin(operation)

return ApiChange{
Id: id,
Level: config.getLogLevel(id),
Expand All @@ -47,8 +45,8 @@ func NewApiChange(id string, config *Config, args []any, comment string, operati
CommonChange: CommonChange{
Attributes: getAttributes(config, operation),
},
SourceLine: line,
SourceColumn: col,
SourceLine: getOriginLine(operation),
SourceColumn: getOriginCol(operation),
}
}

Expand All @@ -57,15 +55,20 @@ func (c ApiChange) WithOrigin(origin *openapi3.Origin) ApiChange {
return c
}

func getOrigin(operation *openapi3.Operation) (int, int) {
func getOriginLine(operation *openapi3.Operation) int {
if operation == nil || operation.Origin == nil {
return 0, 0
return 0
}

line := operation.Origin.Key.Line
col := operation.Origin.Key.Column
return operation.Origin.Key.Line
}

func getOriginCol(operation *openapi3.Operation) int {
if operation == nil || operation.Origin == nil {
return 0
}

return line, col
return operation.Origin.Key.Column
}

func getAttributes(config *Config, operation *openapi3.Operation) map[string]any {
Expand Down

0 comments on commit 8195d3b

Please sign in to comment.