Improve Quality Scripts and Fix nilaway issues.
This commit is contained in:
parent
9e3fc6123b
commit
6321f09aad
|
@ -258,7 +258,7 @@ func mapArgs(argsTypes []string) (string, string, string, string) {
|
|||
goSpec = append(goSpec, c3)
|
||||
// because of java/kotlin/android/gomobile inability to recognize unsigned integers
|
||||
// we need to pretent this is a signed interface...so do the final cast here...
|
||||
// this will cause bad behavior if a negative number is passed through the java
|
||||
// this will cause bad behavior if a negative number is passed through the java
|
||||
// interface...so...don't do that...
|
||||
gUse = append(gUse, fmt.Sprintf("uint(%s)", c4))
|
||||
case "string":
|
||||
|
|
|
@ -6,7 +6,8 @@ echo ""
|
|||
echo ""
|
||||
echo "Running staticcheck..."
|
||||
|
||||
staticcheck ./...
|
||||
staticcheck lib.go
|
||||
staticcheck ./utils/*
|
||||
|
||||
# In the future we should remove include-pkgs. However, there are a few false positives in the overall go stdlib that make this
|
||||
# too noisy right now, specifically assigning nil to initialize slices (safe), and using go internal context channels assigned
|
||||
|
@ -14,10 +15,11 @@ staticcheck ./...
|
|||
# We also have one file infinite_channel.go written in a way that static analysis cannot reason about easily. So it is explictly
|
||||
# ignored.
|
||||
echo "Running nilaway..."
|
||||
nilaway -include-pkgs="cwtch.im/cwtch,cwtch.im/tapir,git.openprivacy.ca/openprivacy/connectivity" -exclude-file-docstrings="nolint:nilaway" ./...
|
||||
nilaway -include-pkgs="git.openprivacy.ca/cwtch.im/cwtch-autobindings,cwtch.im/cwtch,cwtch.im/tapir,git.openprivacy.ca/openprivacy/connectivity" -exclude-errors-in-files="./templates/lib_template.go" -exclude-file-docstrings="nolint:nilaway" lib.go
|
||||
nilaway -include-pkgs="git.openprivacy.ca/cwtch.im/cwtch-autobindings,cwtch.im/cwtch,cwtch.im/tapir,git.openprivacy.ca/openprivacy/connectivity" -exclude-errors-in-files="./templates/lib_template.go" -exclude-file-docstrings="nolint:nilaway" ./utils/
|
||||
|
||||
echo "Time to format"
|
||||
gofmt -l -s -w .
|
||||
gofmt -l -s -w ./utils/*
|
||||
|
||||
# ineffassign (https://github.com/gordonklaus/ineffassign)
|
||||
# echo "Checking for ineffectual assignment of errors (unchecked errors...)"
|
||||
|
|
|
@ -441,7 +441,6 @@ const (
|
|||
|
||||
func buildACN(globalSettings settings.GlobalSettings, torPath string, appDir string) (connectivity.ACN, settings.GlobalSettings, error) {
|
||||
|
||||
mrand.Seed(int64(time.Now().Nanosecond()))
|
||||
socksPort := mrand.Intn(1000) + 9600
|
||||
controlPort := socksPort + 1
|
||||
|
||||
|
|
|
@ -200,7 +200,7 @@ func (eh *EventHandler) handleAppBusEvent(e *event.Event) string {
|
|||
if conversationInfo.IsServer() {
|
||||
groupHandler := servers.FunctionalityGate()
|
||||
if err == nil {
|
||||
serverInfo, _ := groupHandler.GetServerInfo(profile, conversationInfo.Handle);
|
||||
serverInfo, _ := groupHandler.GetServerInfo(profile, conversationInfo.Handle)
|
||||
knownServers = append(knownServers, serverInfo)
|
||||
}
|
||||
continue
|
||||
|
@ -357,6 +357,10 @@ func (eh *EventHandler) handleProfileEvent(ev *EventProfileEnvelope) string {
|
|||
log.Errorf("eh.app == nil in handleProfileEvent... this shouldnt happen?")
|
||||
} else {
|
||||
profile := eh.app.GetPeer(ev.Profile)
|
||||
if profile == nil {
|
||||
log.Errorf("something has gone very wrong. profile is nil in handleProfileEvent")
|
||||
return ""
|
||||
}
|
||||
log.Debugf("New Profile Event to Handle: %v", ev)
|
||||
switch ev.Event.EventType {
|
||||
case event.NewMessageFromPeer: //event.TimestampReceived, event.RemotePeer, event.Data
|
||||
|
@ -401,7 +405,11 @@ func (eh *EventHandler) handleProfileEvent(ev *EventProfileEnvelope) string {
|
|||
conversationID, _ := strconv.Atoi(ev.Event.Data[event.ConversationID])
|
||||
profile.SetConversationAttribute(conversationID, attr.LocalScope.ConstructScopedZonedPath(attr.ProfileZone.ConstructZonedPath(constants2.Archived)), event.False)
|
||||
|
||||
gci, _ := profile.GetConversationInfo(conversationID)
|
||||
gci, err := profile.GetConversationInfo(conversationID)
|
||||
if err != nil {
|
||||
log.Errorf("new message from non-existant group: %v", err)
|
||||
break
|
||||
}
|
||||
groupServer := gci.Attributes[attr.LocalScope.ConstructScopedZonedPath(attr.LegacyGroupZone.ConstructZonedPath(constants.GroupServer)).ToString()]
|
||||
state := profile.GetPeerState(groupServer)
|
||||
// if syncing, don't flood with notifications
|
||||
|
@ -420,11 +428,13 @@ func (eh *EventHandler) handleProfileEvent(ev *EventProfileEnvelope) string {
|
|||
count, err := profile.GetChannelMessageCount(conversationID, 0)
|
||||
if err != nil {
|
||||
log.Errorf("error fetching channel message count %v %v", conversationID, err)
|
||||
break
|
||||
}
|
||||
|
||||
conversationInfo, err := profile.GetConversationInfo(conversationID)
|
||||
if err != nil {
|
||||
log.Errorf("error fetching conversation info for %v %v", conversationID, err)
|
||||
break
|
||||
}
|
||||
|
||||
blocked := constants.False
|
||||
|
@ -437,7 +447,11 @@ func (eh *EventHandler) handleProfileEvent(ev *EventProfileEnvelope) string {
|
|||
accepted = constants.True
|
||||
}
|
||||
|
||||
acl, _ := json.Marshal(conversationInfo.ACL)
|
||||
acl, err := json.Marshal(conversationInfo.ACL)
|
||||
if err != nil {
|
||||
log.Errorf("received invalid ACL in conversation: %v", err)
|
||||
break
|
||||
}
|
||||
|
||||
lastMessage, _ := profile.GetMostRecentMessages(conversationID, 0, 0, 1)
|
||||
ev.Event.Data["unread"] = strconv.Itoa(count) // if this is a new contact with messages attached then by-definition these are unread...
|
||||
|
@ -457,8 +471,16 @@ func (eh *EventHandler) handleProfileEvent(ev *EventProfileEnvelope) string {
|
|||
groupPic := RandomGroupImage(ev.Event.Data[event.GroupID])
|
||||
ev.Event.Data[constants2.Picture] = groupPic
|
||||
|
||||
conversationID, _ := strconv.Atoi(ev.Event.Data[event.ConversationID])
|
||||
conversationInfo, _ := profile.GetConversationInfo(conversationID)
|
||||
conversationID, err := strconv.Atoi(ev.Event.Data[event.ConversationID])
|
||||
if err != nil {
|
||||
log.Errorf("invalid conversation id recieved %v", err)
|
||||
break
|
||||
}
|
||||
conversationInfo, err := profile.GetConversationInfo(conversationID)
|
||||
if err != nil {
|
||||
log.Errorf("error fetching conversation info for %v %v", conversationID, err)
|
||||
break
|
||||
}
|
||||
acl, _ := json.Marshal(conversationInfo.ACL)
|
||||
ev.Event.Data["accessControlList"] = string(acl)
|
||||
case event.NewGroup:
|
||||
|
@ -469,10 +491,22 @@ func (eh *EventHandler) handleProfileEvent(ev *EventProfileEnvelope) string {
|
|||
groupPic := RandomGroupImage(invite.GroupID)
|
||||
ev.Event.Data[constants2.Picture] = groupPic
|
||||
|
||||
conversationID, _ := strconv.Atoi(ev.Event.Data[event.ConversationID])
|
||||
conversationInfo, _ := profile.GetConversationInfo(conversationID)
|
||||
acl, _ := json.Marshal(conversationInfo.ACL)
|
||||
conversationID, err := strconv.Atoi(ev.Event.Data[event.ConversationID])
|
||||
if err != nil {
|
||||
log.Errorf("invalid conversation id recieved %v", err)
|
||||
break
|
||||
}
|
||||
conversationInfo, err := profile.GetConversationInfo(conversationID)
|
||||
if err != nil {
|
||||
log.Errorf("error fetching conversation info for %v %v", conversationID, err)
|
||||
break
|
||||
}
|
||||
acl, err := json.Marshal(conversationInfo.ACL)
|
||||
ev.Event.Data["accessControlList"] = string(acl)
|
||||
if err != nil {
|
||||
log.Errorf("received invalid ACL in conversation: %v", err)
|
||||
break
|
||||
}
|
||||
} else {
|
||||
log.Errorf("received a new group event which contained an invalid invite %v. this should never happen and likely means there is a bug in cwtch. Please file a ticket @ https://git.openprivacy.ca/cwtch.im/cwtch", err)
|
||||
return ""
|
||||
|
@ -530,6 +564,10 @@ func unwrap(original *EventProfileEnvelope) *event.Event {
|
|||
|
||||
func (eh *EventHandler) startHandlingPeer(onion string) {
|
||||
eventBus := eh.app.GetEventBus(onion)
|
||||
if eventBus == nil {
|
||||
log.Errorf("could not start handling peer events .. event bus is nil")
|
||||
return
|
||||
}
|
||||
q := event.NewQueue()
|
||||
|
||||
eventBus.Subscribe(event.NetworkStatus, q)
|
||||
|
|
Loading…
Reference in New Issue