topfreegames/khan

View on GitHub

Showing 425 of 425 total issues

Avoid deeply nested control flow statements.
Open

                    if m, ok := v1.(easyjson.Unmarshaler); ok {
                        m.UnmarshalEasyJSON(in)
                    } else if m, ok := v1.(json.Unmarshaler); ok {
                        _ = m.UnmarshalJSON(in.Raw())
                    } else {
Severity: Major
Found in api/payload_easyjson.go - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if m, ok := v3.(easyjson.Unmarshaler); ok {
                            m.UnmarshalEasyJSON(in)
                        } else if m, ok := v3.(json.Unmarshaler); ok {
                            _ = m.UnmarshalJSON(in.Raw())
                        } else {
    Severity: Major
    Found in api/payload_easyjson.go - About 45 mins to fix

      Function GetApp has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      func GetApp(host string, port int, configPath string, debug bool, logger zap.Logger, fast, test bool) *App {
      Severity: Minor
      Found in api/app.go - About 45 mins to fix

        Function GetTestClient has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        func GetTestClient(host string, port int, index string, sniff bool, logger zap.Logger, debug bool) *Client {
        Severity: Minor
        Found in es/es_client.go - About 45 mins to fix

          Function GetClanDetails has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          func GetClanDetails(db DB, encryptionKey []byte, gameID string, clan *Clan, maxClansPerPlayer int, options *GetClanDetailsOptions) (map[string]interface{}, error) {
          Severity: Minor
          Found in models/clan.go - About 45 mins to fix

            Function dispatchApproveDenyMembershipHookByID has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            func dispatchApproveDenyMembershipHookByID(app *App, db models.DB, hookType int, gameID string, clanID, playerID, requestorID, creatorID int64, message, membershipLevel string) error {
            Severity: Minor
            Found in api/membership_helpers.go - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                          if err != nil {
                              logger.Error("Failed to delete clan from Elastic Search.", zap.Error(err))
                          }
              Severity: Major
              Found in models/es_worker.go - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                            if cd != 0 {
                                timeToBeReady := cd - int(nowInMilliseconds-membership.UpdatedAt)/1000
                                if timeToBeReady > 0 {
                                    return -1, false, &MustWaitMembershipCooldownError{timeToBeReady, playerPublicID, clan.PublicID}
                                }
                Severity: Major
                Found in models/membership.go - About 45 mins to fix

                  Function GetDB has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  func GetDB(host string, user string, port int, sslmode string, dbName string, password string) (interfaces.Database, error) {
                  Severity: Minor
                  Found in models/helpers.go - About 45 mins to fix

                    Method UpdateGamePayload.Validate has 7 return statements (exceeds 4 allowed).
                    Open

                    func (p *UpdateGamePayload) Validate() []string {
                        v := NewValidation()
                    
                        var minMembershipLevel int
                    
                    
                    Severity: Major
                    Found in api/payload.go - About 45 mins to fix

                      Function dispatchMembershipHookByID has 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      func dispatchMembershipHookByID(app *App, db models.DB, hookType int, gameID string, clanID, playerID, requestorID int64, message, membershipLevel string) error {
                      Severity: Minor
                      Found in api/membership_helpers.go - About 45 mins to fix

                        Function GetClient has 6 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        func GetClient(host string, port int, index string, sniff bool, logger zap.Logger, debug bool) *Client {
                        Severity: Minor
                        Found in es/es_client.go - About 45 mins to fix

                          Function CreateClan has 6 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                          func CreateClan(db DB, encryptionKey []byte, gameID, publicID, name, ownerPublicID string, metadata map[string]interface{}, allowApplication, autoJoin bool, maxClansPerPlayer int) (*Clan, error) {
                          Severity: Minor
                          Found in models/clan.go - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                if m, ok := v7.(easyjson.Unmarshaler); ok {
                                                    m.UnmarshalEasyJSON(in)
                                                } else if m, ok := v7.(json.Unmarshaler); ok {
                                                    _ = m.UnmarshalJSON(in.Raw())
                                                } else {
                            Severity: Major
                            Found in api/payload_easyjson.go - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                  if m, ok := v15.(easyjson.Unmarshaler); ok {
                                                      m.UnmarshalEasyJSON(in)
                                                  } else if m, ok := v15.(json.Unmarshaler); ok {
                                                      _ = m.UnmarshalJSON(in.Raw())
                                                  } else {
                              Severity: Major
                              Found in api/payload_easyjson.go - About 45 mins to fix

                                Function updatePreviousMembershipHelper has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                func updatePreviousMembershipHelper(db DB, membership *Membership, level string, requestorID int64, message string, approved bool) (*Membership, error) {
                                Severity: Minor
                                Found in models/membership.go - About 45 mins to fix

                                  Function ApproveOrDenyMembershipInvitation has 7 return statements (exceeds 4 allowed).
                                  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
                                      }
                                  Severity: Major
                                  Found in models/membership.go - About 45 mins to fix

                                    Function testLogMessage has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
                                    Open

                                    func testLogMessage(logger *MockLogger, level zap.Level, message string, fields ...interface{}) bool {
                                        for _, msg := range logger.Messages {
                                            if msg["type"] != "log" {
                                                continue
                                            }
                                    Severity: Minor
                                    Found in testing/logger.go - About 45 mins to fix

                                    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

                                                        if m, ok := v12.(easyjson.Unmarshaler); ok {
                                                            m.UnmarshalEasyJSON(in)
                                                        } else if m, ok := v12.(json.Unmarshaler); ok {
                                                            _ = m.UnmarshalJSON(in.Raw())
                                                        } else {
                                    Severity: Major
                                    Found in api/payload_easyjson.go - About 45 mins to fix

                                      Function UpdateGame has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                      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,
                                      Severity: Minor
                                      Found in models/game.go - About 45 mins to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language