Skip to content

Commit

Permalink
Merge pull request #626 from ackleymi/main
Browse files Browse the repository at this point in the history
Update and satisfy code linter
  • Loading branch information
ackleymi authored Apr 18, 2024
2 parents 04786a1 + a203213 commit 9886e68
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 44 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@ jobs:
name: Linter
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.21'
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v4
with:
version: v1.51
version: v1.57.2

build:
name: build
Expand Down
8 changes: 7 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
run:
timeout: 10m
skip-dirs:
# deprecated config -
# skip-dirs:
# - gen
# - vendor

issues:
exclude-dirs:
- gen
- vendor

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion datadictionary/datadictionary.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion logon_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
}

Expand Down
2 changes: 1 addition & 1 deletion logout_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion memorystore.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
28 changes: 14 additions & 14 deletions message.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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 {
Expand All @@ -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)
}
}

Expand Down
10 changes: 5 additions & 5 deletions null_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
14 changes: 7 additions & 7 deletions quickfix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,26 +85,26 @@ 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
}

return nil
}

func (e *MockApp) ToAdmin(msg *Message, sessionID SessionID) {
func (e *MockApp) ToAdmin(msg *Message, _ SessionID) {
e.Called()

if e.decorateToAdmin != nil {
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion session_factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions store/sql/sqlstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
}

Expand Down
6 changes: 3 additions & 3 deletions validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 9886e68

Please sign in to comment.