From a203213139ac511bef263901ec1f1452d9cd3e95 Mon Sep 17 00:00:00 2001 From: Michael Ackley Date: Wed, 17 Apr 2024 21:22:52 -0500 Subject: [PATCH] Statify updated linter rules --- .github/workflows/ci.yaml | 96 ++++++++++++++++---------------- .golangci.yml | 1 + Makefile | 2 +- datadictionary/datadictionary.go | 2 +- logon_state.go | 2 +- logout_state.go | 2 +- memorystore.go | 2 +- message.go | 28 +++++----- null_log.go | 10 ++-- quickfix_test.go | 14 ++--- session_factory_test.go | 2 +- store/sql/sqlstore.go | 6 +- validation.go | 6 +- 13 files changed, 87 insertions(+), 86 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c42e674b0..4d58289a2 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -30,51 +30,51 @@ jobs: with: version: v1.57.2 - # build: - # name: build - # runs-on: ubuntu-latest - # strategy: - # matrix: - # go: [1.21] - # store-type: - # - - # - memory - # - file - # - mongo - # fix-version: - # - - # - fix40 - # - fix41 - # - fix42 - # - fix43 - # - fix44 - # - fix50 - # - fix50sp1 - # - fix50sp2 - # steps: - # - name: Setup - # uses: actions/setup-go@v2 - # with: - # go-version: ${{ matrix.go }} - # - name: Check out source - # uses: actions/checkout@v2 - # - name: Start MongoDB - # uses: supercharge/mongodb-github-action@1.8.0 - # with: - # mongodb-replica-set: replicaset - # - name: Install ruby - # uses: ruby/setup-ruby@v1 - # with: - # ruby-version: '3.0' - # - name: Unit test - # env: - # FIX_TEST: ${{ matrix.fix-version }} - # STORE_TYPE: ${{ matrix.store-type }} - # run: if [ -z $FIX_TEST ] && [ -z $STORE_TYPE ]; then make build-src && make test-ci; fi - # - name: Acceptance test - # env: - # GO111MODULE: on - # MONGODB_TEST_CXN: mongodb://localhost:27017 - # FIX_TEST: ${{ matrix.fix-version }} - # STORE_TYPE: ${{ matrix.store-type }} - # run: if [ $FIX_TEST ] && [ $STORE_TYPE ]; then make generate-ci && make build && make $FIX_TEST; fi + build: + name: build + runs-on: ubuntu-latest + strategy: + matrix: + go: [1.21] + store-type: + - + - memory + - file + - mongo + fix-version: + - + - fix40 + - fix41 + - fix42 + - fix43 + - fix44 + - fix50 + - fix50sp1 + - fix50sp2 + steps: + - name: Setup + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go }} + - name: Check out source + uses: actions/checkout@v2 + - name: Start MongoDB + uses: supercharge/mongodb-github-action@1.8.0 + with: + mongodb-replica-set: replicaset + - name: Install ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.0' + - name: Unit test + env: + FIX_TEST: ${{ matrix.fix-version }} + STORE_TYPE: ${{ matrix.store-type }} + run: if [ -z $FIX_TEST ] && [ -z $STORE_TYPE ]; then make build-src && make test-ci; fi + - name: Acceptance test + env: + GO111MODULE: on + MONGODB_TEST_CXN: mongodb://localhost:27017 + FIX_TEST: ${{ matrix.fix-version }} + STORE_TYPE: ${{ matrix.store-type }} + run: if [ $FIX_TEST ] && [ $STORE_TYPE ]; then make generate-ci && make build && make $FIX_TEST; fi diff --git a/.golangci.yml b/.golangci.yml index 4d61e0126..b0bd0347b 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,5 +1,6 @@ run: timeout: 10m + # deprecated config - # skip-dirs: # - gen # - vendor diff --git a/Makefile b/Makefile index 9d2f26817..b05c5d72f 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ test: linters-install: @golangci-lint --version >/dev/null 2>&1 || { \ echo "installing linting tools..."; \ - curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s v1.50.1; \ + curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s v1.57.2; \ } lint: linters-install diff --git a/datadictionary/datadictionary.go b/datadictionary/datadictionary.go index b032d078e..218439497 100644 --- a/datadictionary/datadictionary.go +++ b/datadictionary/datadictionary.go @@ -315,7 +315,7 @@ func Parse(path string) (*DataDictionary, error) { func ParseSrc(xmlSrc io.Reader) (*DataDictionary, error) { doc := new(XMLDoc) decoder := xml.NewDecoder(xmlSrc) - decoder.CharsetReader = func(encoding string, input io.Reader) (io.Reader, error) { + decoder.CharsetReader = func(_ string, input io.Reader) (io.Reader, error) { return input, nil } diff --git a/logon_state.go b/logon_state.go index 05c970838..7ad8b6602 100644 --- a/logon_state.go +++ b/logon_state.go @@ -68,7 +68,7 @@ func (s logonState) Timeout(session *session, e internal.Event) (nextState sessi return s } -func (s logonState) Stop(session *session) (nextState sessionState) { +func (s logonState) Stop(_ *session) (nextState sessionState) { return latentState{} } diff --git a/logout_state.go b/logout_state.go index cee8e9bd8..04defce54 100644 --- a/logout_state.go +++ b/logout_state.go @@ -40,6 +40,6 @@ func (state logoutState) Timeout(session *session, event internal.Event) (nextSt return state } -func (state logoutState) Stop(session *session) (nextstate sessionState) { +func (state logoutState) Stop(_ *session) (nextstate sessionState) { return state } diff --git a/memorystore.go b/memorystore.go index 5773f09b5..2379016e2 100644 --- a/memorystore.go +++ b/memorystore.go @@ -109,7 +109,7 @@ func (store *memoryStore) GetMessages(beginSeqNum, endSeqNum int) ([][]byte, err type memoryStoreFactory struct{} -func (f memoryStoreFactory) Create(sessionID SessionID) (MessageStore, error) { +func (f memoryStoreFactory) Create(_ SessionID) (MessageStore, error) { m := new(memoryStore) if err := m.Reset(); err != nil { return m, errors.Wrap(err, "reset") diff --git a/message.go b/message.go index 566b48eb7..73da79169 100644 --- a/message.go +++ b/message.go @@ -152,7 +152,7 @@ func ParseMessageWithDataDictionary( msg *Message, rawMessage *bytes.Buffer, transportDataDictionary *datadictionary.DataDictionary, - applicationDataDictionary *datadictionary.DataDictionary, + _ *datadictionary.DataDictionary, ) (err error) { msg.Header.Clear() msg.Body.Clear() @@ -322,7 +322,7 @@ func (m *Message) IsMsgTypeOf(msgType string) bool { func (m *Message) reverseRoute() *Message { reverseMsg := NewMessage() - copy := func(src Tag, dest Tag) { + copyFunc := func(src Tag, dest Tag) { var field FIXString if m.Header.GetField(src, &field) == nil { if len(field) != 0 { @@ -331,25 +331,25 @@ func (m *Message) reverseRoute() *Message { } } - copy(tagSenderCompID, tagTargetCompID) - copy(tagSenderSubID, tagTargetSubID) - copy(tagSenderLocationID, tagTargetLocationID) + copyFunc(tagSenderCompID, tagTargetCompID) + copyFunc(tagSenderSubID, tagTargetSubID) + copyFunc(tagSenderLocationID, tagTargetLocationID) - copy(tagTargetCompID, tagSenderCompID) - copy(tagTargetSubID, tagSenderSubID) - copy(tagTargetLocationID, tagSenderLocationID) + copyFunc(tagTargetCompID, tagSenderCompID) + copyFunc(tagTargetSubID, tagSenderSubID) + copyFunc(tagTargetLocationID, tagSenderLocationID) - copy(tagOnBehalfOfCompID, tagDeliverToCompID) - copy(tagOnBehalfOfSubID, tagDeliverToSubID) - copy(tagDeliverToCompID, tagOnBehalfOfCompID) - copy(tagDeliverToSubID, tagOnBehalfOfSubID) + copyFunc(tagOnBehalfOfCompID, tagDeliverToCompID) + copyFunc(tagOnBehalfOfSubID, tagDeliverToSubID) + copyFunc(tagDeliverToCompID, tagOnBehalfOfCompID) + copyFunc(tagDeliverToSubID, tagOnBehalfOfSubID) // Tags added in 4.1. var beginString FIXString if m.Header.GetField(tagBeginString, &beginString) == nil { if string(beginString) != BeginStringFIX40 { - copy(tagOnBehalfOfLocationID, tagDeliverToLocationID) - copy(tagDeliverToLocationID, tagOnBehalfOfLocationID) + copyFunc(tagOnBehalfOfLocationID, tagDeliverToLocationID) + copyFunc(tagDeliverToLocationID, tagOnBehalfOfLocationID) } } diff --git a/null_log.go b/null_log.go index 106dcae42..c6c0e4327 100644 --- a/null_log.go +++ b/null_log.go @@ -17,17 +17,17 @@ package quickfix type nullLog struct{} -func (l nullLog) OnIncoming([]byte) {} -func (l nullLog) OnOutgoing([]byte) {} -func (l nullLog) OnEvent(string) {} -func (l nullLog) OnEventf(format string, a ...interface{}) {} +func (l nullLog) OnIncoming([]byte) {} +func (l nullLog) OnOutgoing([]byte) {} +func (l nullLog) OnEvent(string) {} +func (l nullLog) OnEventf(_ string, _ ...interface{}) {} type nullLogFactory struct{} func (nullLogFactory) Create() (Log, error) { return nullLog{}, nil } -func (nullLogFactory) CreateSessionLog(sessionID SessionID) (Log, error) { +func (nullLogFactory) CreateSessionLog(_ SessionID) (Log, error) { return nullLog{}, nil } diff --git a/quickfix_test.go b/quickfix_test.go index beb8792bc..db308b48e 100644 --- a/quickfix_test.go +++ b/quickfix_test.go @@ -85,18 +85,18 @@ type MockApp struct { lastToApp *Message } -func (e *MockApp) OnCreate(sessionID SessionID) { +func (e *MockApp) OnCreate(_ SessionID) { } -func (e *MockApp) OnLogon(sessionID SessionID) { +func (e *MockApp) OnLogon(_ SessionID) { e.Called() } -func (e *MockApp) OnLogout(sessionID SessionID) { +func (e *MockApp) OnLogout(_ SessionID) { e.Called() } -func (e *MockApp) FromAdmin(msg *Message, sessionID SessionID) (reject MessageRejectError) { +func (e *MockApp) FromAdmin(_ *Message, _ SessionID) (reject MessageRejectError) { if err, ok := e.Called().Get(0).(MessageRejectError); ok { return err } @@ -104,7 +104,7 @@ func (e *MockApp) FromAdmin(msg *Message, sessionID SessionID) (reject MessageRe return nil } -func (e *MockApp) ToAdmin(msg *Message, sessionID SessionID) { +func (e *MockApp) ToAdmin(msg *Message, _ SessionID) { e.Called() if e.decorateToAdmin != nil { @@ -114,12 +114,12 @@ func (e *MockApp) ToAdmin(msg *Message, sessionID SessionID) { e.lastToAdmin = msg } -func (e *MockApp) ToApp(msg *Message, sessionID SessionID) (err error) { +func (e *MockApp) ToApp(msg *Message, _ SessionID) (err error) { e.lastToApp = msg return e.Called().Error(0) } -func (e *MockApp) FromApp(msg *Message, sessionID SessionID) (reject MessageRejectError) { +func (e *MockApp) FromApp(_ *Message, _ SessionID) (reject MessageRejectError) { if err, ok := e.Called().Get(0).(MessageRejectError); ok { return err } diff --git a/session_factory_test.go b/session_factory_test.go index ada14350c..d14c5b221 100644 --- a/session_factory_test.go +++ b/session_factory_test.go @@ -373,7 +373,7 @@ func (s *SessionFactorySuite) TestInvalidWeekdays() { } for _, testcase := range testcases { - s.T().Run(testcase.label, func(t *testing.T) { + s.T().Run(testcase.label, func(_ *testing.T) { s.SessionSettings.Set(config.Weekdays, testcase.input) _, err := s.newSession(s.SessionID, s.MessageStoreFactory, s.SessionSettings, s.LogFactory, s.App) diff --git a/store/sql/sqlstore.go b/store/sql/sqlstore.go index c54ac517f..7550e3012 100644 --- a/store/sql/sqlstore.go +++ b/store/sql/sqlstore.go @@ -50,10 +50,10 @@ func sqlString(raw string, placeholder placeholderFunc) string { return raw } idx := 0 - return rePlaceholder.ReplaceAllStringFunc(raw, func(s string) string { - new := placeholder(idx) + return rePlaceholder.ReplaceAllStringFunc(raw, func(_ string) string { + p := placeholder(idx) idx++ - return new + return p }) } diff --git a/validation.go b/validation.go index 72bb06628..3dddbf00f 100644 --- a/validation.go +++ b/validation.go @@ -149,7 +149,7 @@ func validateFIXT(transportDD, appDD *datadictionary.DataDictionary, settings Va return nil } -func validateMsgType(d *datadictionary.DataDictionary, msgType string, msg *Message) MessageRejectError { +func validateMsgType(d *datadictionary.DataDictionary, msgType string, _ *Message) MessageRejectError { if _, validMsgType := d.Messages[msgType]; !validMsgType { return InvalidMessageType() } @@ -296,7 +296,7 @@ func validateRequired(transportDD *datadictionary.DataDictionary, appDD *datadic return nil } -func validateRequiredFieldMap(msg *Message, requiredTags map[int]struct{}, fieldMap FieldMap) MessageRejectError { +func validateRequiredFieldMap(_ *Message, requiredTags map[int]struct{}, fieldMap FieldMap) MessageRejectError { for required := range requiredTags { requiredTag := Tag(required) if !fieldMap.Has(requiredTag) { @@ -328,7 +328,7 @@ func validateFields(transportDD *datadictionary.DataDictionary, appDD *datadicti return nil } -func validateField(d *datadictionary.DataDictionary, validFields datadictionary.TagSet, field TagValue) MessageRejectError { +func validateField(d *datadictionary.DataDictionary, _ datadictionary.TagSet, field TagValue) MessageRejectError { if len(field.value) == 0 { return TagSpecifiedWithoutAValue(field.tag) }