diff --git a/.gitignore b/.gitignore index a3871519..eefd8184 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,10 @@ # Output of the go coverage tool, specifically when used with LiteIDE *.out +/lint-project.sh + # code coverage +coverage.txt coverage.html /bin/ diff --git a/cashLetter.go b/cashLetter.go index 257218c3..ee6b5e57 100644 --- a/cashLetter.go +++ b/cashLetter.go @@ -170,7 +170,9 @@ func (cl *CashLetter) build() error { for _, rd := range b.Returns { // Sequence Number - rdSequenceNumber := 1 + var rdSequenceNumber int + rdSequenceNumber++ + // Record Numbers rdAddendumARecordNumber := 1 rdAddendumDRecordNumber := 1 @@ -196,7 +198,6 @@ func (cl *CashLetter) build() error { rdAddendumDRecordNumber = 1 } } - rdSequenceNumber++ cashLetterItemsCount = cashLetterItemsCount + 1 cashLetterTotalAmount = cashLetterTotalAmount + rd.ItemAmount diff --git a/cmd/webui/main.go b/cmd/webui/main.go index 9498c8b5..090d60d1 100644 --- a/cmd/webui/main.go +++ b/cmd/webui/main.go @@ -27,8 +27,7 @@ var ( httpAddr = flag.String("http.addr", bind.HTTP("ICL"), "HTTP listen address") adminAddr = flag.String("admin.addr", bind.Admin("ICL"), "Admin HTTP listen address") - flagBasePath = flag.String("base-path", "/", "Base path to serve HTTP routes and webui from") - flagLogFormat = flag.String("log.format", "", "Format for log lines (Options: json, plain") + flagBasePath = flag.String("base-path", "/", "Base path to serve HTTP routes and webui from") ) func main() { diff --git a/go.sum b/go.sum index 85dabce5..0262bc56 100644 --- a/go.sum +++ b/go.sum @@ -386,6 +386,7 @@ github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ= github.com/google/go-github/v35 v35.2.0/go.mod h1:s0515YVTI+IMrDoy9Y4pHt9ShGpzHvHO8rZ7L7acgvs= @@ -418,6 +419,7 @@ github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.2.0 h1:qJYtXnJRWmpe7m/3XlyhrsLrEURqHRM2kxzoxXqyUDs= github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= @@ -591,6 +593,7 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/ktrysmt/go-bitbucket v0.6.4/go.mod h1:9u0v3hsd2rqCHRIpbir1oP7F58uo5dq19sBYvuMoyQ4= github.com/lib/pq v0.0.0-20180327071824-d34b9ff171c2/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= @@ -710,6 +713,7 @@ github.com/nats-io/nkeys v0.2.0/go.mod h1:XdZpAbhgyyODYqjTawOnIOI7VlbKSarI9Gfy1t github.com/nats-io/nkeys v0.3.0/go.mod h1:gvUNGjVcM2IPr5rCsRsC6Wb3Hr2CQAm08dsxtV6A5y4= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= github.com/neo4j/neo4j-go-driver v1.8.1-0.20200803113522-b626aa943eba/go.mod h1:ncO5VaFWh0Nrt+4KT4mOZboaczBZcLuHrG+/sUeP8gI= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= @@ -1510,6 +1514,7 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= diff --git a/makefile b/makefile index 612f14ed..de25b026 100644 --- a/makefile +++ b/makefile @@ -13,9 +13,15 @@ build-webui: GOOS=js GOARCH=wasm go build -o ./cmd/webui/assets/imagecashletter.wasm github.com/moov-io/imagecashletter/cmd/webui/icl/ CGO_ENABLED=0 go build -o ./bin/webui ./cmd/webui +.PHONY: check check: - go fmt ./... - @mkdir -p ./bin/ +ifeq ($(OS),Windows_NT) + @echo "Skipping checks on Windows, currently unsupported." +else + @wget -O lint-project.sh https://raw.githubusercontent.com/moov-io/infra/master/go/lint-project.sh + @chmod +x ./lint-project.sh + GOOS=js GOARCH=wasm COVER_THRESHOLD=90.0 ./lint-project.sh +endif .PHONY: client client: @@ -96,4 +102,4 @@ AUTHORS: .PHONY: tagged-release tagged-release: - @./tagged-release.sh $(VERSION) \ No newline at end of file + @./tagged-release.sh $(VERSION) diff --git a/reader.go b/reader.go index ab4b4b69..295fe89d 100644 --- a/reader.go +++ b/reader.go @@ -188,7 +188,7 @@ func (r *Reader) Read() (File, error) { return r.File, nil } -func (r *Reader) parseLine() error { +func (r *Reader) parseLine() error { //nolint:gocyclo switch r.line[:2] { case fileHeaderPos, fileHeaderEbcPos: if err := r.parseFileHeader(); err != nil { diff --git a/writer.go b/writer.go index 6d93e7db..23c9eacb 100644 --- a/writer.go +++ b/writer.go @@ -203,18 +203,23 @@ func (w *Writer) writeCheckDetail(b *Bundle) error { // writeCheckDetailAddendum writes a CheckDetailAddendum (A, B, C) to a CheckDetail func (w *Writer) writeCheckDetailAddendum(cd *CheckDetail) error { - for _, cdAddendumA := range cd.GetCheckDetailAddendumA() { - if err := w.writeLine(&cdAddendumA); err != nil { + addendumA := cd.GetCheckDetailAddendumA() + for i := range addendumA { + if err := w.writeLine(&addendumA[i]); err != nil { return err } } - for _, cdAddendumB := range cd.GetCheckDetailAddendumB() { - if err := w.writeLine(&cdAddendumB); err != nil { + + addendumB := cd.GetCheckDetailAddendumB() + for i := range addendumB { + if err := w.writeLine(&addendumB[i]); err != nil { return err } } - for _, cdAddendumC := range cd.GetCheckDetailAddendumC() { - if err := w.writeLine(&cdAddendumC); err != nil { + + addendumC := cd.GetCheckDetailAddendumC() + for i := range addendumC { + if err := w.writeLine(&addendumC[i]); err != nil { return err } } @@ -244,8 +249,8 @@ func (w *Writer) writeCheckImageView(cd *CheckDetail) error { } // FRB asks that imageViewDetail should immediately be followed by its corresponding data and analysis - for i, ivDetail := range ivDetailSlice { - if err := w.writeLine(&ivDetail); err != nil { + for i := range ivDetailSlice { + if err := w.writeLine(&ivDetailSlice[i]); err != nil { return err } if len(ivDataSlice) > 0 && len(ivDataSlice) >= i-1 { @@ -284,23 +289,30 @@ func (w *Writer) writeReturnDetail(b *Bundle) error { // writeReturnDetailAddendum writes a ReturnDetailAddendum (A, B, C, D) to a ReturnDetail func (w *Writer) writeReturnDetailAddendum(rd *ReturnDetail) error { - for _, rdAddendumA := range rd.GetReturnDetailAddendumA() { - if err := w.writeLine(&rdAddendumA); err != nil { + addendumA := rd.GetReturnDetailAddendumA() + for i := range addendumA { + if err := w.writeLine(&addendumA[i]); err != nil { return err } } - for _, rdAddendumB := range rd.GetReturnDetailAddendumB() { - if err := w.writeLine(&rdAddendumB); err != nil { + + addendumB := rd.GetReturnDetailAddendumB() + for i := range addendumB { + if err := w.writeLine(&addendumB[i]); err != nil { return err } } - for _, rdAddendumC := range rd.GetReturnDetailAddendumC() { - if err := w.writeLine(&rdAddendumC); err != nil { + + addendumC := rd.GetReturnDetailAddendumC() + for i := range addendumC { + if err := w.writeLine(&addendumC[i]); err != nil { return err } } - for _, rdAddendumD := range rd.GetReturnDetailAddendumD() { - if err := w.writeLine(&rdAddendumD); err != nil { + + addendumD := rd.GetReturnDetailAddendumD() + for i := range addendumD { + if err := w.writeLine(&addendumD[i]); err != nil { return err } } @@ -309,18 +321,23 @@ func (w *Writer) writeReturnDetailAddendum(rd *ReturnDetail) error { // writeReturnImageView writes ImageViews (Detail, Data, Analysis) to a ReturnDetail func (w *Writer) writeReturnImageView(rd *ReturnDetail) error { - for _, ivDetail := range rd.GetImageViewDetail() { - if err := w.writeLine(&ivDetail); err != nil { + ivDetail := rd.GetImageViewDetail() + for i := range ivDetail { + if err := w.writeLine(&ivDetail[i]); err != nil { return err } } - for _, ivData := range rd.GetImageViewData() { - if err := w.writeLine(&ivData); err != nil { + + ivData := rd.GetImageViewData() + for i := range ivData { + if err := w.writeLine(&ivData[i]); err != nil { return err } } - for _, ivAnalysis := range rd.GetImageViewAnalysis() { - if err := w.writeLine(&ivAnalysis); err != nil { + + ivAnalysis := rd.GetImageViewAnalysis() + for i := range ivAnalysis { + if err := w.writeLine(&ivAnalysis[i]); err != nil { return err } }