Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MB-13510] Add gci linter to make go import order/grouping more consistent #9064

Merged
merged 5 commits into from
Aug 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 6 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
linters-settings:
gci:
sections:
- standard
- default
- prefix(github.com/transcom/mymove)
goimports:
# put imports beginning with prefix after 3rd-party packages;
# it's a comma-separated list of prefixes
Expand Down Expand Up @@ -32,6 +37,7 @@ linters:
enable:
- deadcode
- errcheck
- gci
- gofmt
- goimports
- gomodguard
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ repos:
types: [go]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
rev: v4.3.0
hooks:
- id: check-json
- id: check-merge-conflict
Expand Down Expand Up @@ -50,7 +50,7 @@ repos:
exclude: ^public/swagger-ui/

- repo: https://github.com/golangci/golangci-lint
rev: v1.46.2
rev: v1.49.0
hooks:
- id: golangci-lint
entry: bash -c 'exec golangci-lint run ${GOLANGCI_LINT_VERBOSE} -j=${GOLANGCI_LINT_CONCURRENCY:-1}' # custom bash so we can override concurrency for faster dev runs
Expand All @@ -74,7 +74,7 @@ repos:
language: script

- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.31.1
rev: v0.32.2
hooks:
- id: markdownlint
entry: markdownlint --ignore .github/*.md
Expand Down
20 changes: 10 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Contributing to MyMove

Anyone is welcome to contribute code changes and additions to this project. If you'd like your changes merged into the master branch, please read the following document before opening a [pull request](https://github.com/transcom/mymove/pulls).
Anyone is welcome to contribute code changes and additions to this project. If you'd like your changes merged into the master branch, please read the following document before opening a [pull request][pulls].

There are several ways in which you can help improve this project:

1. Fix an existing [issue](https://github.com/transcom/mymove/issues) and submit a [pull request](https://github.com/transcom/mymove/pulls).
1. Review open [pull requests](https://github.com/transcom/mymove/pulls).
1. Report a new [issue](https://github.com/transcom/mymove/issues). _Only do this after you've made sure the behavior or problem you're observing isn't already documented in an open issue._
1. Fix an existing [issue][issues] and submit a [pull request][pulls].
1. Review open [pull requests][pulls].
1. Report a new [issue][issues]. _Only do this after you've made sure the behavior or problem you're observing isn't already documented in an open issue._

## Table of Contents

Expand Down Expand Up @@ -37,17 +37,17 @@ We use a number of tools to evaluate the quality and security of this project's

## Code Style

Please review our [front end](https://github.com/transcom/mymove/blob/master/docs/frontend.md) and [back end](https://github.com/transcom/mymove/blob/master/docs/backend.md) coding guidelines and do your best to follow the conventions and choices described therein.
Please review our [front end](https://transcom.github.io/mymove-docs/docs/frontend) and [back end](https://transcom.github.io/mymove-docs/docs/backend) coding guidelines and do your best to follow the conventions and choices described therein.

Code formatting conventions are defined in the `.editorconfig` file which uses the [EditorConfig](http://editorconfig.org) syntax. There are [plugins for a variety of editors](http://editorconfig.org/#download) that utilize the settings in the `.editorconfig` file. It is recommended that you install the EditorConfig plugin for your editor of choice.

## Legalese

Before submitting a pull request to this repository for the first time, you'll need to sign a [Developer Certificate of Origin](https://developercertificate.org) (DCO). To read and agree to the DCO, you'll add your name and email address to [CONTRIBUTORS.md](https://github.com/transcom/mymove/blob/master/CONTRIBUTORS.md). At a high level, this tells us that you have the right to submit the work you're contributing in your pull request and says that you consent to us treating the contribution in a way consistent with the license associated with this software (as described in [LICENSE.md](https://github.com/transcom/mymove/blob/master/LICENSE.md)) and its documentation ("Project").
Before submitting a pull request to this repository for the first time, you'll need to sign a [Developer Certificate of Origin](https://developercertificate.org) (DCO). To read and agree to the DCO, you'll add your name and email address to [CONTRIBUTORS.md][contributors]. At a high level, this tells us that you have the right to submit the work you're contributing in your pull request and says that you consent to us treating the contribution in a way consistent with the license associated with this software (as described in [LICENSE.md][license]) and its documentation ("Project").

You may submit contributions anonymously or under a pseudonym if you'd like, but we need to be able to reach you at the email address you provide when agreeing to the DCO. Contributions you make to this public Department of Defense repository are completely voluntary. When you submit a pull request, you're offering your contribution without expectation of payment and you expressly waive any future pay claims against the U.S. Federal Government related to your contribution.

[contributors]: https://github.com/transcom/move.mil/blob/master/CONTRIBUTORS.md
[issues]: https://github.com/transcom/move.mil/issues
[license]: https://github.com/transcom/move.mil/blob/master/LICENSE.md
[pulls]: https://github.com/transcom/move.mil/pulls
[contributors]: https://github.com/transcom/mymove/blob/master/CONTRIBUTORS.md
[issues]: https://github.com/transcom/mymove/issues
[license]: https://github.com/transcom/mymove/blob/master/LICENSE.txt
[pulls]: https://github.com/transcom/mymove/pulls
Comment on lines +50 to +53
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example original linter issue (several in this file): MD053/link-image-reference-definitions Link and image reference definitions should be needed [Unused link or image reference definition: "contributors"] [Context: "[contributors]: https://github..."]

11 changes: 4 additions & 7 deletions cmd/generate-shipment-summary/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,20 @@ import (
"strings"
"time"

"github.com/gofrs/uuid"
"github.com/pkg/errors"
"github.com/spf13/pflag"
"github.com/spf13/viper"
"go.uber.org/zap"

"github.com/transcom/mymove/pkg/appcontext"
"github.com/transcom/mymove/pkg/auth"
"github.com/transcom/mymove/pkg/cli"
"github.com/transcom/mymove/pkg/logging"
"github.com/transcom/mymove/pkg/rateengine"
"github.com/transcom/mymove/pkg/route"

"github.com/transcom/mymove/pkg/auth"

"github.com/gofrs/uuid"

"github.com/transcom/mymove/pkg/models"
"github.com/transcom/mymove/pkg/paperwork"
"github.com/transcom/mymove/pkg/rateengine"
"github.com/transcom/mymove/pkg/route"
)

// hereRequestTimeout is how long to wait on HERE request before timing out (15 seconds).
Expand Down
3 changes: 1 addition & 2 deletions cmd/ghc-pricing-parser/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ import (
"github.com/pterm/pterm/putils"
"github.com/spf13/pflag"
"github.com/spf13/viper"
"go.uber.org/zap"

"github.com/tealeg/xlsx/v3"
"go.uber.org/zap"

"github.com/transcom/mymove/pkg/appcontext"
"github.com/transcom/mymove/pkg/cli"
Expand Down
3 changes: 1 addition & 2 deletions cmd/ghc-transit-time-parser/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ import (

"github.com/spf13/pflag"
"github.com/spf13/viper"
"go.uber.org/zap"

"github.com/tealeg/xlsx/v3"
"go.uber.org/zap"

"github.com/transcom/mymove/pkg/appcontext"
"github.com/transcom/mymove/pkg/cli"
Expand Down
1 change: 0 additions & 1 deletion cmd/milmove-tasks/post_file_to_gex.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/spf13/viper"

"go.uber.org/zap"

"github.com/transcom/mymove/pkg/certs"
Expand Down
5 changes: 2 additions & 3 deletions cmd/milmove-tasks/process_edis.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ import (
"strings"
"time"

"github.com/transcom/mymove/pkg/appcontext"
"github.com/transcom/mymove/pkg/certs"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/credentials/stscreds"
Expand All @@ -21,6 +18,8 @@ import (
"github.com/spf13/viper"
"go.uber.org/zap"

"github.com/transcom/mymove/pkg/appcontext"
"github.com/transcom/mymove/pkg/certs"
"github.com/transcom/mymove/pkg/cli"
"github.com/transcom/mymove/pkg/db/sequence"
ediinvoice "github.com/transcom/mymove/pkg/edi/invoice"
Expand Down
3 changes: 1 addition & 2 deletions cmd/milmove-tasks/send_payment_reminder_email.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ import (
"log"
"strings"

"github.com/spf13/cobra"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/credentials/stscreds"
awssession "github.com/aws/aws-sdk-go/aws/session"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/spf13/viper"
"go.uber.org/zap"
Expand Down
3 changes: 1 addition & 2 deletions cmd/milmove-tasks/send_post_move_survey_email.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ import (
"strings"
"time"

"github.com/spf13/cobra"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/credentials/stscreds"
awssession "github.com/aws/aws-sdk-go/aws/session"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/spf13/viper"
"go.uber.org/zap"
Expand Down
3 changes: 1 addition & 2 deletions cmd/milmove/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@ import (
"syscall"
"time"

"github.com/gobuffalo/pop/v6"

"github.com/alexedwards/scs/redisstore"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/credentials/stscreds"
awssession "github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/sts"
"github.com/gobuffalo/pop/v6"
"github.com/golang-jwt/jwt/v4"
"github.com/gomodule/redigo/redis"
"github.com/pkg/errors"
Expand Down
1 change: 0 additions & 1 deletion cmd/prime-api-client/prime/create_mto_service_item.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/spf13/viper"

"github.com/transcom/mymove/cmd/prime-api-client/utils"

mtoServiceItem "github.com/transcom/mymove/pkg/gen/primeclient/mto_service_item"
"github.com/transcom/mymove/pkg/gen/primemessages"
)
Expand Down
1 change: 0 additions & 1 deletion cmd/prime-api-client/prime/create_mto_shipment.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/spf13/viper"

"github.com/transcom/mymove/cmd/prime-api-client/utils"

mtoShipment "github.com/transcom/mymove/pkg/gen/primeclient/mto_shipment"
)

Expand Down
2 changes: 0 additions & 2 deletions cmd/prime-api-client/prime/get_move_task_order.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ import (
"time"

"github.com/gofrs/uuid"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/spf13/viper"

"github.com/transcom/mymove/cmd/prime-api-client/utils"

mto "github.com/transcom/mymove/pkg/gen/primeclient/move_task_order"
)

Expand Down
2 changes: 0 additions & 2 deletions cmd/prime-api-client/prime/list_moves.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ import (
"time"

"github.com/go-openapi/strfmt"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/spf13/viper"

"github.com/transcom/mymove/cmd/prime-api-client/utils"

mto "github.com/transcom/mymove/pkg/gen/primeclient/move_task_order"
"github.com/transcom/mymove/pkg/gen/primemessages"
)
Expand Down
1 change: 0 additions & 1 deletion cmd/prime-api-client/prime/update_mto_shipment.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/spf13/viper"

"github.com/transcom/mymove/cmd/prime-api-client/utils"

mtoShipment "github.com/transcom/mymove/pkg/gen/primeclient/mto_shipment"
)

Expand Down
1 change: 0 additions & 1 deletion cmd/prime-api-client/prime/update_mto_shipment_address.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/spf13/viper"

"github.com/transcom/mymove/cmd/prime-api-client/utils"

mtoShipment "github.com/transcom/mymove/pkg/gen/primeclient/mto_shipment"
)

Expand Down
1 change: 0 additions & 1 deletion cmd/prime-api-client/prime/update_mto_shipment_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/spf13/viper"

"github.com/transcom/mymove/cmd/prime-api-client/utils"

mtoShipment "github.com/transcom/mymove/pkg/gen/primeclient/mto_shipment"
)

Expand Down
1 change: 0 additions & 1 deletion cmd/prime-api-client/support/create_move_task_order.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/spf13/viper"

"github.com/transcom/mymove/cmd/prime-api-client/utils"

movetaskorderclient "github.com/transcom/mymove/pkg/gen/supportclient/move_task_order"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/spf13/viper"

"github.com/transcom/mymove/cmd/prime-api-client/utils"

webhookclient "github.com/transcom/mymove/pkg/gen/supportclient/webhook"
)

Expand Down
2 changes: 0 additions & 2 deletions cmd/prime-api-client/support/get_move_task_order.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ import (
"time"

"github.com/gofrs/uuid"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/spf13/viper"

"github.com/transcom/mymove/cmd/prime-api-client/utils"

mto "github.com/transcom/mymove/pkg/gen/supportclient/move_task_order"
)

Expand Down
1 change: 0 additions & 1 deletion cmd/prime-api-client/support/list_mto_payment_requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/spf13/viper"

"github.com/transcom/mymove/cmd/prime-api-client/utils"

paymentrequestclient "github.com/transcom/mymove/pkg/gen/supportclient/payment_request"
)

Expand Down
1 change: 0 additions & 1 deletion cmd/prime-api-client/support/list_mtos.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/spf13/viper"

"github.com/transcom/mymove/cmd/prime-api-client/utils"

mto "github.com/transcom/mymove/pkg/gen/supportclient/move_task_order"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/spf13/viper"

"github.com/transcom/mymove/cmd/prime-api-client/utils"

mto "github.com/transcom/mymove/pkg/gen/supportclient/move_task_order"
)

Expand Down
4 changes: 1 addition & 3 deletions cmd/prime-api-client/support/recalculate_payment_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ import (

"github.com/go-openapi/strfmt"
"github.com/gofrs/uuid"

paymentrequestclient "github.com/transcom/mymove/pkg/gen/supportclient/payment_request"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/spf13/viper"

"github.com/transcom/mymove/cmd/prime-api-client/utils"
paymentrequestclient "github.com/transcom/mymove/pkg/gen/supportclient/payment_request"
)

// InitRecalculatePaymentRequestFlags declares which flags are enabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/spf13/viper"

"github.com/transcom/mymove/cmd/prime-api-client/utils"

mtoserviceitem "github.com/transcom/mymove/pkg/gen/supportclient/mto_service_item"
)

Expand Down
1 change: 0 additions & 1 deletion cmd/prime-api-client/support/update_mto_shipment_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/spf13/viper"

"github.com/transcom/mymove/cmd/prime-api-client/utils"

mtoShipment "github.com/transcom/mymove/pkg/gen/supportclient/mto_shipment"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/spf13/viper"

"github.com/transcom/mymove/cmd/prime-api-client/utils"

paymentrequestclient "github.com/transcom/mymove/pkg/gen/supportclient/payment_request"
)

Expand Down
3 changes: 0 additions & 3 deletions cmd/prime-api-client/utils/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ func CreatePrimeClientWithCACStoreParam(v *viper.Viper, store *pksigner.Store) (
MinVersion: tls.VersionTLS12,
MaxVersion: tls.VersionTLS12,
}
tlsConfig.BuildNameToCertificate()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original linter issue (several of these): SA1019: tlsConfig.BuildNameToCertificate has been deprecated since Go 1.14: NameToCertificate only allows associating a single certificate with a given name. Leave that field nil to let the library select the first compatible chain from Certificates. (staticcheck)

transport := &http.Transport{
TLSClientConfig: tlsConfig,
}
Expand Down Expand Up @@ -134,7 +133,6 @@ func CreatePrimeClient(v *viper.Viper) (*primeClient.Mymove, *pksigner.Store, er
MinVersion: tls.VersionTLS12,
MaxVersion: tls.VersionTLS12,
}
tlsConfig.BuildNameToCertificate()
transport := &http.Transport{
TLSClientConfig: tlsConfig,
}
Expand Down Expand Up @@ -208,7 +206,6 @@ func CreateSupportClient(v *viper.Viper) (*supportClient.Mymove, *pksigner.Store
MinVersion: tls.VersionTLS12,
MaxVersion: tls.VersionTLS12,
}
tlsConfig.BuildNameToCertificate()
transport := &http.Transport{
TLSClientConfig: tlsConfig,
}
Expand Down
Loading