Showing 425 of 425 total issues
Avoid deeply nested control flow statements. Open
Open
if m, ok := v1.(easyjson.Unmarshaler); ok {
m.UnmarshalEasyJSON(in)
} else if m, ok := v1.(json.Unmarshaler); ok {
_ = m.UnmarshalJSON(in.Raw())
} else {
Avoid deeply nested control flow statements. Open
Open
if m, ok := v3.(easyjson.Unmarshaler); ok {
m.UnmarshalEasyJSON(in)
} else if m, ok := v3.(json.Unmarshaler); ok {
_ = m.UnmarshalJSON(in.Raw())
} else {
Function GetApp
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func GetApp(host string, port int, configPath string, debug bool, logger zap.Logger, fast, test bool) *App {
Function GetTestClient
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func GetTestClient(host string, port int, index string, sniff bool, logger zap.Logger, debug bool) *Client {
Function GetClanDetails
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func GetClanDetails(db DB, encryptionKey []byte, gameID string, clan *Clan, maxClansPerPlayer int, options *GetClanDetailsOptions) (map[string]interface{}, error) {
Function dispatchApproveDenyMembershipHookByID
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func dispatchApproveDenyMembershipHookByID(app *App, db models.DB, hookType int, gameID string, clanID, playerID, requestorID, creatorID int64, message, membershipLevel string) error {
Avoid deeply nested control flow statements. Open
Open
if err != nil {
logger.Error("Failed to delete clan from Elastic Search.", zap.Error(err))
}
Avoid deeply nested control flow statements. Open
Open
if cd != 0 {
timeToBeReady := cd - int(nowInMilliseconds-membership.UpdatedAt)/1000
if timeToBeReady > 0 {
return -1, false, &MustWaitMembershipCooldownError{timeToBeReady, playerPublicID, clan.PublicID}
}
Function GetDB
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func GetDB(host string, user string, port int, sslmode string, dbName string, password string) (interfaces.Database, error) {
Method UpdateGamePayload.Validate
has 7 return statements (exceeds 4 allowed). Open
Open
func (p *UpdateGamePayload) Validate() []string {
v := NewValidation()
var minMembershipLevel int
Function dispatchMembershipHookByID
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func dispatchMembershipHookByID(app *App, db models.DB, hookType int, gameID string, clanID, playerID, requestorID int64, message, membershipLevel string) error {
Function GetClient
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func GetClient(host string, port int, index string, sniff bool, logger zap.Logger, debug bool) *Client {
Function CreateClan
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func CreateClan(db DB, encryptionKey []byte, gameID, publicID, name, ownerPublicID string, metadata map[string]interface{}, allowApplication, autoJoin bool, maxClansPerPlayer int) (*Clan, error) {
Avoid deeply nested control flow statements. Open
Open
if m, ok := v7.(easyjson.Unmarshaler); ok {
m.UnmarshalEasyJSON(in)
} else if m, ok := v7.(json.Unmarshaler); ok {
_ = m.UnmarshalJSON(in.Raw())
} else {
Avoid deeply nested control flow statements. Open
Open
if m, ok := v15.(easyjson.Unmarshaler); ok {
m.UnmarshalEasyJSON(in)
} else if m, ok := v15.(json.Unmarshaler); ok {
_ = m.UnmarshalJSON(in.Raw())
} else {
Function updatePreviousMembershipHelper
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func updatePreviousMembershipHelper(db DB, membership *Membership, level string, requestorID int64, message string, approved bool) (*Membership, error) {
Function ApproveOrDenyMembershipInvitation
has 7 return statements (exceeds 4 allowed). Open
Open
func ApproveOrDenyMembershipInvitation(db DB, encryptionKey []byte, game *Game, gameID, playerPublicID, clanPublicID, action string) (*Membership, error) {
membership, err := GetValidMembershipByClanAndPlayerPublicID(db, gameID, clanPublicID, playerPublicID)
if err != nil {
return nil, err
}
Function testLogMessage
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
Open
func testLogMessage(logger *MockLogger, level zap.Level, message string, fields ...interface{}) bool {
for _, msg := range logger.Messages {
if msg["type"] != "log" {
continue
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid deeply nested control flow statements. Open
Open
if m, ok := v12.(easyjson.Unmarshaler); ok {
m.UnmarshalEasyJSON(in)
} else if m, ok := v12.(json.Unmarshaler); ok {
_ = m.UnmarshalJSON(in.Raw())
} else {
Function UpdateGame
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
db DB, publicID, name string, levels, metadata map[string]interface{},
minLevelAccept, minLevelCreate, minLevelRemove, minOffsetRemove, minOffsetPromote,
minOffsetDemote, maxMembers, maxClans, cooldownAfterDeny, cooldownAfterDelete,
cooldownBeforeApply, cooldownBeforeInvite, maxPendingInvites int,
clanUpdateMetadataFieldsHookTriggerWhitelist string,