topfreegames/khan

View on GitHub

Showing 425 of 425 total issues

Function UpdateClanMembershipCount has 6 return statements (exceeds 4 allowed).
Open

func UpdateClanMembershipCount(db DB, id int64) error {
    query := `
    UPDATE clans SET membership_count=membership.count+1
    FROM (
        SELECT COUNT(*) as count
Severity: Major
Found in models/clan.go - About 40 mins to fix

    Function GetClanByPublicIDAndOwnerPublicID has 6 return statements (exceeds 4 allowed).
    Open

    func GetClanByPublicIDAndOwnerPublicID(db DB, gameID, publicID, ownerPublicID string) (*Clan, error) {
        var clans []*Clan
        var players []*Player
        _, err := db.Select(&clans, "SELECT * FROM clans WHERE game_id=$1 AND public_id=$2", gameID, publicID)
        if err != nil {
    Severity: Major
    Found in models/clan.go - About 40 mins to fix

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

          log.I(logger, "Pruning stale data...", func(cm log.CM) {
              cm.Write(
                  zap.String("GameID", options.GameID),
                  zap.Int("PendingApplicationsExpiration", options.PendingApplicationsExpiration),
                  zap.Int("PendingInvitesExpiration", options.PendingInvitesExpiration),
      Severity: Major
      Found in models/prune.go and 2 other locations - About 40 mins to fix
      cmd/prune.go on lines 129..137
      models/prune.go on lines 152..160

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 110.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

              log.I(cmdL, "Stale data for game pruned successfully.", func(cm log.CM) {
                  cm.Write(
                      zap.Int("PendingApplicationsPruned", stats.PendingApplicationsPruned),
                      zap.Int("PendingInvitesPruned", stats.PendingInvitesPruned),
                      zap.Int("DeniedMembershipsPruned", stats.DeniedMembershipsPruned),
      Severity: Major
      Found in cmd/prune.go and 2 other locations - About 40 mins to fix
      models/prune.go on lines 103..111
      models/prune.go on lines 152..160

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 110.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

          log.I(logger, "Pruned stale data succesfully.", func(cm log.CM) {
              cm.Write(
                  zap.String("GameID", options.GameID),
                  zap.Int("PendingApplicationsPruned", stats.PendingApplicationsPruned),
                  zap.Int("PendingInvitesPruned", stats.PendingInvitesPruned),
      Severity: Major
      Found in models/prune.go and 2 other locations - About 40 mins to fix
      cmd/prune.go on lines 129..137
      models/prune.go on lines 103..111

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 110.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Function GetClanWithMemberships has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          db models.DB, approvedMemberships, deniedMemberships, bannedMemberships, pendingMemberships int, gameID string, clanPublicID string, options ...bool) (*models.Game, *models.Clan, *models.Player, []*models.Player, []*models.Membership, error) {
      Severity: Minor
      Found in models/fixtures/fixtures.go - About 35 mins to fix

        Function UpdatePlayer has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        func UpdatePlayer(db DB, logger zap.Logger, encryptionKey []byte, gameID, publicID, name string, metadata map[string]interface{}) (*Player, error) {
        Severity: Minor
        Found in models/player.go - About 35 mins to fix

          Function validateUpdatePlayerDispatch has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          func validateUpdatePlayerDispatch(game *models.Game, sourcePlayer *models.Player, player *models.Player, metadata map[string]interface{}, logger zap.Logger) bool {
          Severity: Minor
          Found in api/player_helpers.go - About 35 mins to fix

            Function validateUpdateClanDispatch has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            func validateUpdateClanDispatch(game *models.Game, sourceClan *models.Clan, clan *models.Clan, metadata map[string]interface{}, logger zap.Logger) bool {
            Severity: Minor
            Found in api/clan_helpers.go - About 35 mins to fix

              Method App.Rollback has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              func (app *App) Rollback(tx gorp.Transaction, msg string, c echo.Context, logger zap.Logger, err error) error {
              Severity: Minor
              Found in api/app.go - About 35 mins to fix

                Function dispatchClanOwnershipChangeHook has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                func dispatchClanOwnershipChangeHook(app *App, hookType int, clan *models.Clan, previousOwner *models.Player, newOwner *models.Player) error {
                Severity: Minor
                Found in api/clan_helpers.go - About 35 mins to fix

                  Function validateMembershipHookResponse has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  func validateMembershipHookResponse(apply map[string]interface{}, gameID string, clan *models.Clan, player *models.Player, requestor *models.Player) {
                  Severity: Minor
                  Found in api/helpers_test.go - About 35 mins to fix

                    Function CreatePlayer has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    func CreatePlayer(db DB, logger zap.Logger, encryptionKey []byte, gameID, publicID, name string, metadata map[string]interface{}) (*Player, error) {
                    Severity: Minor
                    Found in models/player.go - About 35 mins to fix

                      Method MongoWorker.updateClanIntoMongoDB has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          ctx context.Context, gameID string, op string, clan map[string]interface{}, clanID string,
                      Severity: Minor
                      Found in models/mongo_worker.go - About 35 mins to fix

                        Function TransferClanOwnership has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        func TransferClanOwnership(db DB, encryptionKey []byte, gameID, clanPublicID, playerPublicID string, levels map[string]interface{}, maxLevel int) (*Clan, *Player, *Player, error) {
                        Severity: Minor
                        Found in models/clan.go - About 35 mins to fix

                          Function createMembershipHelper has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

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

                            Similar blocks of code found in 2 locations. Consider refactoring.
                            Open

                            func easyjsonA8a797f8EncodeGithubComTopfreegamesKhanApi11(out *jwriter.Writer, in ApproveOrDenyMembershipInvitationPayload) {
                                out.RawByte('{')
                                first := true
                                _ = first
                                {
                            Severity: Minor
                            Found in api/payload_easyjson.go and 1 other location - About 35 mins to fix
                            api/payload_easyjson.go on lines 539..549

                            Duplicated Code

                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                            Tuning

                            This issue has a mass of 106.

                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                            Refactorings

                            Further Reading

                            Similar blocks of code found in 2 locations. Consider refactoring.
                            Open

                            func easyjsonA8a797f8EncodeGithubComTopfreegamesKhanApi4(out *jwriter.Writer, in TransferClanOwnershipPayload) {
                                out.RawByte('{')
                                first := true
                                _ = first
                                {
                            Severity: Minor
                            Found in api/payload_easyjson.go and 1 other location - About 35 mins to fix
                            api/payload_easyjson.go on lines 1239..1249

                            Duplicated Code

                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                            Tuning

                            This issue has a mass of 106.

                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                            Refactorings

                            Further Reading

                            Method Dispatcher.interpolateURL has 5 return statements (exceeds 4 allowed).
                            Open

                            func (d *Dispatcher) interpolateURL(sourceURL string, payload map[string]interface{}) (string, error) {
                                t, err := fasttemplate.NewTemplate(sourceURL, "{{", "}}")
                                if err != nil {
                                    return sourceURL, err
                                }
                            Severity: Major
                            Found in api/dispatcher.go - About 35 mins to fix

                              Function PruneStaleData has 5 return statements (exceeds 4 allowed).
                              Open

                              func PruneStaleData(options *PruneOptions, db DB, logger zap.Logger) (*PruneStats, error) {
                                  log.I(logger, "Pruning stale data...", func(cm log.CM) {
                                      cm.Write(
                                          zap.String("GameID", options.GameID),
                                          zap.Int("PendingApplicationsExpiration", options.PendingApplicationsExpiration),
                              Severity: Major
                              Found in models/prune.go - About 35 mins to fix
                                Severity
                                Category
                                Status
                                Source
                                Language