Skip to content

Commit

Permalink
Merge pull request #209 from adamdecaf/standard-linting
Browse files Browse the repository at this point in the history
build: enable standard linting script
  • Loading branch information
adamdecaf authored Nov 26, 2021
2 parents 7f503e8 + b8a6ebe commit 15de640
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 30 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
5 changes: 3 additions & 2 deletions cashLetter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -196,7 +198,6 @@ func (cl *CashLetter) build() error {
rdAddendumDRecordNumber = 1
}
}
rdSequenceNumber++

cashLetterItemsCount = cashLetterItemsCount + 1
cashLetterTotalAmount = cashLetterTotalAmount + rd.ItemAmount
Expand Down
3 changes: 1 addition & 2 deletions cmd/webui/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
5 changes: 5 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down
12 changes: 9 additions & 3 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -96,4 +102,4 @@ AUTHORS:

.PHONY: tagged-release
tagged-release:
@./tagged-release.sh $(VERSION)
@./tagged-release.sh $(VERSION)
2 changes: 1 addition & 1 deletion reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
61 changes: 39 additions & 22 deletions writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
}
Expand All @@ -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
}
}
Expand Down

0 comments on commit 15de640

Please sign in to comment.