Skip to content

Commit

Permalink
Apply unconvert findings
Browse files Browse the repository at this point in the history
  • Loading branch information
tobischo committed Mar 27, 2024
1 parent e8969e5 commit bdd5034
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ linters:
- nilnil
- gomnd
- errorlint
- unconvert
- gocritic
- gocognit
- dupl
Expand Down
4 changes: 2 additions & 2 deletions binary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ func TestBinaryKDBXv31CleanBinaries(t *testing.T) {
binaries := db.Content.Root.Groups[0].Entries[0].Binaries
for i := 0; i < count; i++ {
found := db.FindBinary(binaries[i].Value.ID)
if data, _ := found.GetContentString(); string(data) != expectedContent[i] {
if data, _ := found.GetContentString(); data != expectedContent[i] {
t.Fatalf(
"Binary content from FindBinary is incorrect. Should be `%s`, was '%s'",
expectedContent[i],
string(data),
data,
)
}
}
Expand Down
4 changes: 2 additions & 2 deletions crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func (cs *StreamManager) UnlockProtectedEntries(e []Entry) {
// UnlockProtectedEntry unlocks a protected entry
func (cs *StreamManager) UnlockProtectedEntry(e *Entry) {
for i := range e.Values {
if bool(e.Values[i].Value.Protected.Bool) {
if e.Values[i].Value.Protected.Bool {
e.Values[i].Value.Content = string(cs.Unpack(e.Values[i].Value.Content))
}
}
Expand Down Expand Up @@ -183,7 +183,7 @@ func (cs *StreamManager) LockProtectedEntries(es []Entry) {
// LockProtectedEntry locks an unprotected entry
func (cs *StreamManager) LockProtectedEntry(e *Entry) {
for i := range e.Values {
if bool(e.Values[i].Value.Protected.Bool) {
if e.Values[i].Value.Protected.Bool {
e.Values[i].Value.Content = cs.Pack([]byte(e.Values[i].Value.Content))
}
}
Expand Down
12 changes: 6 additions & 6 deletions wrappers/bool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func TestBoolWrapperUnmarshalXML(t *testing.T) {
if !errors.Is(err, c.expErr) {
t.Fatalf("Did not receive expected error %+v, received %+v", c.expErr, err)
}
if bool(x.Val.Bool) != c.expValue {
if x.Val.Bool != c.expValue {
t.Errorf("Did not receive expected value '%+v', received: '%+v'", c.expValue, x.Val.Bool)
}
})
Expand Down Expand Up @@ -174,7 +174,7 @@ func TestBoolWrapperUnmarshalXMLAttr(t *testing.T) {
if !errors.Is(err, c.expErr) {
t.Fatalf("Did not receive expected error %+v, received %+v", c.expErr, err)
}
if bool(x.Val.V.Bool) != c.expValue {
if x.Val.V.Bool != c.expValue {
t.Errorf("Did not receive expected value '%+v', received: '%+v'", c.expValue, x.Val.V.Bool)
}
})
Expand Down Expand Up @@ -271,10 +271,10 @@ func TestNullableBoolWrapperUnmarshalXML(t *testing.T) {
if !errors.Is(err, c.expErr) {
t.Fatalf("Did not receive expected error %+v, received %+v", c.expErr, err)
}
if bool(x.Val.Bool) != c.expValue {
if x.Val.Bool != c.expValue {
t.Errorf("Did not receive expected value '%+v', received: '%+v'", c.expValue, x.Val.Bool)
}
if bool(x.Val.Valid) != c.expValid {
if x.Val.Valid != c.expValid {
t.Errorf("Did not receive expected value '%+v', received: '%+v'", c.expValid, x.Val.Valid)
}
})
Expand Down Expand Up @@ -374,11 +374,11 @@ func TestNullableBoolWrapperUnmarshalXMLAttr(t *testing.T) {
if !errors.Is(err, c.expErr) {
t.Fatalf("Did not receive expected error %+v, received %+v", c.expErr, err)
}
if bool(x.Val.V.Bool) != c.expValue {
if x.Val.V.Bool != c.expValue {
t.Errorf("Did not receive expected value '%+v', received: '%+v'", c.expValue, x.Val.V.Bool)
}

if bool(x.Val.V.Valid) != c.expValid {
if x.Val.V.Valid != c.expValid {
t.Errorf("Did not receive expected value '%+v', received: '%+v'", c.expValid, x.Val.V.Valid)
}
})
Expand Down
2 changes: 1 addition & 1 deletion wrappers/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func Now(options ...TimeOption) TimeWrapper {
// On Kdbx v4 it calculates the timestamp subtracting seconds
// from the time date and encode it with base64
func (tw TimeWrapper) MarshalText() ([]byte, error) {
t := time.Time(tw.Time).In(time.UTC)
t := tw.Time.In(time.UTC)
if y := t.Year(); y < 0 || y >= 10000 {
return nil, ErrYearOutsideOfRange
}
Expand Down

0 comments on commit bdd5034

Please sign in to comment.