Skip to content

Commit

Permalink
fixing some linting related issues flagged by 'make check'
Browse files Browse the repository at this point in the history
  • Loading branch information
Hillrunner2008 committed Dec 4, 2024
1 parent 9c764ff commit a6d7641
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 50 deletions.
2 changes: 1 addition & 1 deletion checkDetail.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ func (cd *CheckDetail) Validate() error {
if cd.DocumentationTypeIndicator != "" {
// Z is valid for CashLetter DocumentationTypeIndicator only
if cd.DocumentationTypeIndicator == "Z" {
msg := fmt.Sprint(msgDocumentationTypeIndicator)
msg := msgDocumentationTypeIndicator
return &FieldError{FieldName: "DocumentationTypeIndicator", Value: cd.DocumentationTypeIndicator, Msg: msg}
}
if err := cd.isDocumentationTypeIndicator(cd.DocumentationTypeIndicator); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
// TestMockBundleChecks creates a Bundle of checks
func TestFRBCompatibilityMode(t *testing.T) {
t.Setenv(FRBCompatibilityMode, "false")
assert.Equal(t, IsFRBCompatibilityModeEnabled(), false)
assert.False(t, IsFRBCompatibilityModeEnabled())
t.Setenv(FRBCompatibilityMode, "true")
assert.Equal(t, IsFRBCompatibilityModeEnabled(), true)
assert.True(t, IsFRBCompatibilityModeEnabled())
}
4 changes: 2 additions & 2 deletions creditItem.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,12 @@ func (ci *CreditItem) Validate() error {
if ci.DocumentationTypeIndicator != "" {
// Z is valid for CashLetter DocumentationTypeIndicator only
if ci.DocumentationTypeIndicator == "Z" {
msg := fmt.Sprint(msgDocumentationTypeIndicator)
msg := msgDocumentationTypeIndicator
return &FieldError{FieldName: "DocumentationTypeIndicator", Value: ci.DocumentationTypeIndicator, Msg: msg}
}
// M is not valid for CreditItem DocumentationTypeIndicator
if ci.DocumentationTypeIndicator == "M" {
msg := fmt.Sprint(msgDocumentationTypeIndicator)
msg := msgDocumentationTypeIndicator
return &FieldError{FieldName: "DocumentationTypeIndicator", Value: ci.DocumentationTypeIndicator, Msg: msg}
}
if err := ci.isDocumentationTypeIndicator(ci.DocumentationTypeIndicator); err != nil {
Expand Down
36 changes: 18 additions & 18 deletions issue125_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,22 @@ func TestIssue125(t *testing.T) {
}

// check each record count
assert.Equal(t, counts["01"], 1)
assert.Equal(t, counts["10"], 2)
assert.Equal(t, counts["20"], 4)
assert.Equal(t, counts["25"], 4)
assert.Equal(t, counts["26"], 4)
assert.Equal(t, counts["27"], 4)
assert.Equal(t, counts["28"], 4)
assert.Equal(t, counts["31"], 4)
assert.Equal(t, counts["32"], 4)
assert.Equal(t, counts["33"], 4)
assert.Equal(t, counts["34"], 4)
assert.Equal(t, counts["35"], 4)
assert.Equal(t, counts["50"], 8)
assert.Equal(t, counts["52"], 8)
assert.Equal(t, counts["54"], 8)
assert.Equal(t, counts["70"], 4)
assert.Equal(t, counts["90"], 2)
assert.Equal(t, counts["99"], 1)
assert.Equal(t, 1, counts["01"])
assert.Equal(t, 2, counts["10"])
assert.Equal(t, 4, counts["20"])
assert.Equal(t, 4, counts["25"])
assert.Equal(t, 4, counts["26"])
assert.Equal(t, 4, counts["27"])
assert.Equal(t, 4, counts["28"])
assert.Equal(t, 4, counts["31"])
assert.Equal(t, 4, counts["32"])
assert.Equal(t, 4, counts["33"])
assert.Equal(t, 4, counts["34"])
assert.Equal(t, 4, counts["35"])
assert.Equal(t, 8, counts["50"])
assert.Equal(t, 8, counts["52"])
assert.Equal(t, 8, counts["54"])
assert.Equal(t, 4, counts["70"])
assert.Equal(t, 2, counts["90"])
assert.Equal(t, 1, counts["99"])
}
20 changes: 10 additions & 10 deletions reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ func (r *Reader) parseCheckDetail() error {
func (r *Reader) parseCheckDetailAddendumA() error {
r.recordName = "CheckDetailAddendumA"
if r.currentCashLetter.currentBundle.GetChecks() == nil {
msg := fmt.Sprint(msgFileBundleOutside)
msg := msgFileBundleOutside
return r.error(&FileError{FieldName: "CheckDetailAddendumA", Msg: msg})
}
inputBytes := []byte(r.line)
Expand Down Expand Up @@ -466,7 +466,7 @@ func handleIBM1047Compatibility(input []byte) []byte {
func (r *Reader) parseCheckDetailAddendumB() error {
r.recordName = "CheckDetailAddendumB"
if r.currentCashLetter.currentBundle.GetChecks() == nil {
msg := fmt.Sprint(msgFileBundleOutside)
msg := msgFileBundleOutside
return r.error(&FileError{FieldName: "CheckDetailAddendumB", Msg: msg})
}
lineOut, err := r.decodeLine(r.line)
Expand All @@ -487,7 +487,7 @@ func (r *Reader) parseCheckDetailAddendumB() error {
func (r *Reader) parseCheckDetailAddendumC() error {
r.recordName = "CheckDetailAddendumC"
if r.currentCashLetter.currentBundle.GetChecks() == nil {
msg := fmt.Sprint(msgFileBundleOutside)
msg := msgFileBundleOutside
return r.error(&FileError{FieldName: "CheckDetailAddendumC", Msg: msg})
}
lineOut, err := r.decodeLine(r.line)
Expand Down Expand Up @@ -529,7 +529,7 @@ func (r *Reader) parseReturnDetail() error {
func (r *Reader) parseReturnDetailAddendumA() error {
r.recordName = "ReturnDetailAddendumA"
if r.currentCashLetter.currentBundle.GetReturns() == nil {
msg := fmt.Sprint(msgFileBundleOutside)
msg := msgFileBundleOutside
return r.error(&FileError{FieldName: "ReturnDetailAddendumA", Msg: msg})
}
lineOut, err := r.decodeLine(r.line)
Expand All @@ -551,7 +551,7 @@ func (r *Reader) parseReturnDetailAddendumA() error {
func (r *Reader) parseReturnDetailAddendumB() error {
r.recordName = "ReturnDetailAddendumB"
if r.currentCashLetter.currentBundle.GetReturns() == nil {
msg := fmt.Sprint(msgFileBundleOutside)
msg := msgFileBundleOutside
return r.error(&FileError{FieldName: "ReturnDetailAddendumB", Msg: msg})
}
lineOut, err := r.decodeLine(r.line)
Expand All @@ -572,7 +572,7 @@ func (r *Reader) parseReturnDetailAddendumB() error {
func (r *Reader) parseReturnDetailAddendumC() error {
r.recordName = "ReturnDetailAddendumC"
if r.currentCashLetter.currentBundle.GetReturns() == nil {
msg := fmt.Sprint(msgFileBundleOutside)
msg := msgFileBundleOutside
return r.error(&FileError{FieldName: "ReturnDetailAddendumC", Msg: msg})
}
lineOut, err := r.decodeLine(r.line)
Expand All @@ -594,7 +594,7 @@ func (r *Reader) parseReturnDetailAddendumD() error {
r.recordName = "ReturnDetailAddendumD"

if r.currentCashLetter.currentBundle.GetReturns() == nil {
msg := fmt.Sprint(msgFileBundleOutside)
msg := msgFileBundleOutside
return r.error(&FileError{FieldName: "ReturnDetailAddendumD", Msg: msg})
}
lineOut, err := r.decodeLine(r.line)
Expand Down Expand Up @@ -648,7 +648,7 @@ func (r *Reader) ImageViewDetail() error {
entryIndex := len(r.currentCashLetter.currentBundle.GetReturns()) - 1
r.currentCashLetter.currentBundle.Returns[entryIndex].AddImageViewDetail(ivDetail)
} else {
msg := fmt.Sprint(msgFileBundleOutside)
msg := msgFileBundleOutside
return r.error(&FileError{FieldName: "ImageViewDetail", Msg: msg})
}

Expand Down Expand Up @@ -684,7 +684,7 @@ func (r *Reader) ImageViewData() error {
entryIndex := len(r.currentCashLetter.currentBundle.GetReturns()) - 1
r.currentCashLetter.currentBundle.Returns[entryIndex].AddImageViewData(ivData)
} else {
msg := fmt.Sprint(msgFileBundleOutside)
msg := msgFileBundleOutside
return r.error(&FileError{FieldName: "ImageViewData", Msg: msg})
}

Expand Down Expand Up @@ -728,7 +728,7 @@ func (r *Reader) ImageViewAnalysis() error {
entryIndex := len(r.currentCashLetter.currentBundle.GetReturns()) - 1
r.currentCashLetter.currentBundle.Returns[entryIndex].AddImageViewAnalysis(ivAnalysis)
} else {
msg := fmt.Sprint(msgFileBundleOutside)
msg := msgFileBundleOutside
return r.error(&FileError{FieldName: "ImageViewAnalysis", Msg: msg})
}

Expand Down
10 changes: 5 additions & 5 deletions reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func TestICL_ReadVariableLineLengthOption(t *testing.T) {
expected, err := os.ReadFile(filepath.Join("test", "testdata", "valid-x937.json"))
require.NoError(t, err)

require.Equal(t, string(actual), string(expected))
require.Equal(t, string(expected), string(actual))
}

func TestICL_EBCDICEncodingOption(t *testing.T) {
Expand All @@ -96,7 +96,7 @@ func TestICL_EBCDICEncodingOption(t *testing.T) {
expected, err := os.ReadFile(filepath.Join("test", "testdata", "valid-x937.json"))
require.NoError(t, err)

require.Equal(t, string(actual), string(expected))
require.Equal(t, string(expected), string(actual))
}

func getFileError(t *testing.T, err error) *FileError {
Expand Down Expand Up @@ -801,8 +801,8 @@ func TestICLCreditRecord61File(t *testing.T) {

// ensure we have a validated file structure
require.NoError(t, iclFile.Validate())
require.Equal(t, 2, len(iclFile.CashLetters))
require.Equal(t, 1, len(iclFile.CashLetters[0].Credits))
require.Len(t, iclFile.CashLetters, 2)
require.Len(t, iclFile.CashLetters[0].Credits, 1)
}

func TestICLBase64ImageData(t *testing.T) {
Expand Down Expand Up @@ -874,5 +874,5 @@ func Test_DecodeEBCDIC(t *testing.T) {
require.NoError(t, err)
r, n := utf8.DecodeRuneInString(decoded)
require.Equal(t, 3, n)
require.Equal(t, r, utf8.RuneError)
require.Equal(t, utf8.RuneError, r)
}
4 changes: 2 additions & 2 deletions returnDetail.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ func (rd *ReturnDetail) Validate() error {
if rd.DocumentationTypeIndicator != "" {
// Z is valid for CashLetter DocumentationTypeIndicator only
if rd.DocumentationTypeIndicator == "Z" {
msg := fmt.Sprint(msgDocumentationTypeIndicator)
msg := msgDocumentationTypeIndicator
return &FieldError{FieldName: "DocumentationTypeIndicator", Value: rd.DocumentationTypeIndicator, Msg: msg}
}
if err := rd.isDocumentationTypeIndicator(rd.DocumentationTypeIndicator); err != nil {
Expand Down Expand Up @@ -308,7 +308,7 @@ func (rd *ReturnDetail) Validate() error {
_, arc := AdministrativeReturnCodeDict[rd.ReturnReason]
if !crc && !arc {
// Return msgReturnCode
msg := fmt.Sprint(msgReturnCode)
msg := msgReturnCode
return &FieldError{FieldName: "ReturnReason", Value: rd.ReturnReason, Msg: msg}
}
return nil
Expand Down
16 changes: 8 additions & 8 deletions returnDetailAddendumB_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func TestParseAddendumBJSONWith3339Date(t *testing.T) {
"payorAccountName": "",
"payorBankBusinessDate": "2021-01-21T00:00:00Z"
}`
assert.NoError(
require.NoError(
t,
json.Unmarshal([]byte(testBusinessDateJSON), &addB),
"Unable to unmarshal ReturnDetailAddendumB",
Expand All @@ -112,11 +112,11 @@ func TestParseAddendumBJSONWith3339Date(t *testing.T) {
time.RFC3339,
"2021-01-21T00:00:00Z",
)
assert.NoError(t, timeParseErr, "Unable to parse test time")
require.NoError(t, timeParseErr, "Unable to parse test time")
assert.True(t, addB.PayorBankBusinessDate.Equal(parsedTime), "PayorBankBusinessDate should match JSON")

marshalled, marshalErr := json.Marshal(addB)
assert.NoError(t, marshalErr, "Unable to marshal ReturnDetailAddendumB to JSON")
require.NoError(t, marshalErr, "Unable to marshal ReturnDetailAddendumB to JSON")
assert.Contains(
t,
string(marshalled),
Expand All @@ -136,7 +136,7 @@ func TestParseAddendumBJSONWithX9Date(t *testing.T) {
"payorAccountName": "",
"payorBankBusinessDate": "20210121"
}`
assert.NoError(
require.NoError(
t,
json.Unmarshal([]byte(testBusinessDateJSON), &addB),
"Unable to unmarshal ReturnDetailAddendumB",
Expand All @@ -151,11 +151,11 @@ func TestParseAddendumBJSONWithX9Date(t *testing.T) {
time.RFC3339,
"2021-01-21T00:00:00Z",
)
assert.NoError(t, timeParseErr, "Unable to parse test time")
require.NoError(t, timeParseErr, "Unable to parse test time")
assert.True(t, addB.PayorBankBusinessDate.Equal(parsedTime), "PayorBankBusinessDate should match JSON")

marshalled, marshalErr := json.Marshal(addB)
assert.NoError(t, marshalErr, "Unable to marshal ReturnDetailAddendumB to JSON")
require.NoError(t, marshalErr, "Unable to marshal ReturnDetailAddendumB to JSON")
assert.Contains(
t,
string(marshalled),
Expand All @@ -176,7 +176,7 @@ func TestParseAddendumBJSONWithEmptyDate(t *testing.T) {
"payorBankBusinessDate": ""
}`

assert.NoError(
require.NoError(
t,
json.Unmarshal([]byte(testNoBusinessDateJSON), &addB),
"Unable to unmarshal ReturnDetailAddendumB",
Expand All @@ -194,7 +194,7 @@ func TestParseAddendumBJSONWithEmptyDate(t *testing.T) {
)

marshalled, marshalErr := json.Marshal(addB)
assert.NoError(t, marshalErr, "Unable to marshal ReturnDetailAddendumB to JSON")
require.NoError(t, marshalErr, "Unable to marshal ReturnDetailAddendumB to JSON")
assert.NotContains(
t,
string(marshalled),
Expand Down
2 changes: 1 addition & 1 deletion userGeneral.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func (ug *UserGeneral) Validate() error {
return &FieldError{FieldName: "recordType", Value: ug.recordType, Msg: msg}
}
if ug.UserRecordFormatType == "001" {
msg := fmt.Sprint(msgInvalid)
msg := msgInvalid
return &FieldError{FieldName: "UserRecordFormatType", Value: ug.UserRecordFormatType, Msg: msg}
}
if err := ug.isOwnerIdentifierIndicator(ug.OwnerIdentifierIndicator); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion userPayeeEndorsement.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func (upe *UserPayeeEndorsement) Validate() error {
return &FieldError{FieldName: "recordType", Value: upe.recordType, Msg: msg}
}
if upe.UserRecordFormatType != "001" {
msg := fmt.Sprint(msgInvalid)
msg := msgInvalid
return &FieldError{FieldName: "UserRecordFormatType", Value: upe.UserRecordFormatType, Msg: msg}
}
if err := upe.isNumeric(upe.FormatTypeVersionLevel); err != nil {
Expand Down

0 comments on commit a6d7641

Please sign in to comment.