Skip to content

Commit

Permalink
style: fix linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
wI2L committed Nov 12, 2023
1 parent 9f65129 commit 95e4faa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
12 changes: 8 additions & 4 deletions apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ func (p Patch) apply(src []byte, valid bool) ([]byte, error) {
// source value must be deleted.
if op.Type == OperationMove {
tgt, err = sjson.DeleteBytes(tgt, fp)
if err != nil {
break
}
}
case OperationTest:
r := gjson.GetBytes(tgt, dp)
Expand Down Expand Up @@ -131,7 +134,8 @@ func toDotPath(path string, src []byte) (string, error) {

for i, f := range fragments {
var key string
if len(f) != 0 && unicode.IsDigit(rune(f[0])) {
switch {
case len(f) != 0 && unicode.IsDigit(rune(f[0])):
// The fragment starts with a digit, which
// indicate that it might be a number.
if _, err := strconv.ParseInt(f, 10, 64); err == nil {
Expand All @@ -157,14 +161,14 @@ func toDotPath(path string, src []byte) (string, error) {
return "", fmt.Errorf("unexpected value type at path: %s", sb.String())
}
}
} else if f == "-" && i == len(fragments)-1 {
case f == "-" && i == len(fragments)-1:
// If the last fragment is the "-" character,
// it indicates that the value is a nonexistent
// element to append to the array.
key = "-1"
} else {
default:
key = rfc6901Unescaper.Replace(f)
key = strings.Replace(key, ".", `\.`, -1)
key = strings.ReplaceAll(key, ".", `\.`)
}
if i != 0 {
// Add separator character
Expand Down
19 changes: 9 additions & 10 deletions differ.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,15 @@ type (
)

type options struct {
ignores map[string]struct{}
marshal marshalFunc
unmarshal unmarshalFunc
hasIgnore bool
factorize bool
rationalize bool
invertible bool
equivalent bool
lcs bool
skipApplyTest bool // used by tests
ignores map[string]struct{}
marshal marshalFunc
unmarshal unmarshalFunc
hasIgnore bool
factorize bool
rationalize bool
invertible bool
equivalent bool
lcs bool
}

type jsonNode struct {
Expand Down

0 comments on commit 95e4faa

Please sign in to comment.