topfreegames/khan

View on GitHub

Showing 425 of 425 total issues

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

        It("Should not update clan if invalid payload", func() {
            route := GetGameRoute("game-id", fmt.Sprintf("/clans/%s", "random-id"))

            status, body := Put(app, route, "invalid")

Severity: Major
Found in api/clan_test.go and 1 other location - About 1 hr to fix
api/clan_test.go on lines 336..345

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 148.

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

        It("Should not update player if missing parameters", func() {
            route := GetGameRoute("game-id", "/players/player-id")
            status, body := PutJSON(a, route, map[string]interface{}{})

            Expect(status).To(Equal(http.StatusBadRequest))
Severity: Major
Found in api/player_test.go and 1 other location - About 1 hr to fix
api/player_test.go on lines 70..79

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 147.

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

        It("Should not create player if missing parameters", func() {
            route := GetGameRoute("game-id", "/players")
            status, body := PostJSON(a, route, map[string]interface{}{})

            Expect(status).To(Equal(http.StatusBadRequest))
Severity: Major
Found in api/player_test.go and 1 other location - About 1 hr to fix
api/player_test.go on lines 138..147

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 147.

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 easyjsonA8a797f8DecodeGithubComTopfreegamesKhanApi3 has 57 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func easyjsonA8a797f8DecodeGithubComTopfreegamesKhanApi3(in *jlexer.Lexer, out *UpdateClanPayload) {
    isTopLevel := in.IsStart()
    if in.IsNull() {
        if isTopLevel {
            in.Consumed()
Severity: Minor
Found in api/payload_easyjson.go - About 1 hr to fix

    Function LeaveClan has 13 return statements (exceeds 4 allowed).
    Open

    func LeaveClan(db DB, encryptionKey []byte, gameID, publicID string) (*Clan, *Player, *Player, error) {
        clan, err := GetClanByPublicID(db, gameID, publicID)
        if err != nil {
            return nil, nil, nil, err
        }
    Severity: Major
    Found in models/clan.go - About 1 hr to fix

      Function GetTestPlayerWithMemberships has 13 return statements (exceeds 4 allowed).
      Open

      func GetTestPlayerWithMemberships(db models.DB, gameID string, approvedMemberships, rejectedMemberships, bannedMemberships, pendingMemberships int) (*models.Player, *models.Player, error) {
          if gameID == "" {
              gameID = uuid.NewV4().String()
          }
          game := GameFactory.MustCreateWithOption(map[string]interface{}{
      Severity: Major
      Found in models/fixtures/fixtures.go - About 1 hr to fix

        Function TransferClanOwnership has 13 return statements (exceeds 4 allowed).
        Open

        func TransferClanOwnership(db DB, encryptionKey []byte, gameID, clanPublicID, playerPublicID string, levels map[string]interface{}, maxLevel int) (*Clan, *Player, *Player, error) {
            clan, err := GetClanByPublicID(db, gameID, clanPublicID)
            if err != nil {
                return nil, nil, nil, err
            }
        Severity: Major
        Found in models/clan.go - About 1 hr to fix

          Function easyjsonA8a797f8EncodeGithubComTopfreegamesKhanApi9 has 56 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func easyjsonA8a797f8EncodeGithubComTopfreegamesKhanApi9(out *jwriter.Writer, in CreateClanPayload) {
              out.RawByte('{')
              first := true
              _ = first
              {
          Severity: Minor
          Found in api/payload_easyjson.go - About 1 hr to fix

            Function validateMembership has 56 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func validateMembership(db DB, encryptionKey []byte, game *Game, membership *Membership, clan *Clan, playerPublicID, requestorPublicID string) (int64, bool, error) {
                playerID := int64(-1)
                previousMembership := false
                if membership != nil {
                    previousMembership = true
            Severity: Minor
            Found in models/membership.go - About 1 hr to fix

              Function createClanPlayers has 56 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func createClanPlayers(db models.DB, games []string, clans map[string][]clanData, playersPerClan int, approved, denied, banned bool, progress func() bool) {
                  for _, game := range games {
                      for _, clan := range clans[game] {
                          sql := `
                          WITH addedPlayers AS (
              Severity: Minor
              Found in perf/main.go - About 1 hr to fix

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

                        It("Should not approve membership application if missing parameters", func() {
                            status, body := PostJSON(a, CreateMembershipRoute("gameID", "clanPublicID", "application/approve"), map[string]interface{}{})
                
                            Expect(status).To(Equal(http.StatusBadRequest))
                            var result map[string]interface{}
                Severity: Major
                Found in api/membership_test.go and 5 other locations - About 1 hr to fix
                api/membership_test.go on lines 231..239
                api/membership_test.go on lines 422..430
                api/membership_test.go on lines 549..557
                api/membership_test.go on lines 781..789
                api/membership_test.go on lines 851..859

                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 143.

                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 6 locations. Consider refactoring.
                Open

                        It("Should not promote member if missing parameters", func() {
                            status, body := PostJSON(a, CreateMembershipRoute("gameID", "clanPublicID", "promote"), map[string]interface{}{})
                
                            Expect(status).To(Equal(http.StatusBadRequest))
                            var result map[string]interface{}
                Severity: Major
                Found in api/membership_test.go and 5 other locations - About 1 hr to fix
                api/membership_test.go on lines 231..239
                api/membership_test.go on lines 422..430
                api/membership_test.go on lines 549..557
                api/membership_test.go on lines 679..687
                api/membership_test.go on lines 851..859

                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 143.

                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 6 locations. Consider refactoring.
                Open

                        It("Should not create membership application if missing parameters", func() {
                            status, body := PostJSON(a, CreateMembershipRoute("gameID", "clanPublicID", "application"), map[string]interface{}{})
                
                            Expect(status).To(Equal(http.StatusBadRequest))
                            var result map[string]interface{}
                Severity: Major
                Found in api/membership_test.go and 5 other locations - About 1 hr to fix
                api/membership_test.go on lines 422..430
                api/membership_test.go on lines 549..557
                api/membership_test.go on lines 679..687
                api/membership_test.go on lines 781..789
                api/membership_test.go on lines 851..859

                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 143.

                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 6 locations. Consider refactoring.
                Open

                        It("Should not create membership invitation if missing parameters", func() {
                            status, body := PostJSON(a, CreateMembershipRoute("gameID", "clanPublicID", "invitation"), map[string]interface{}{})
                
                            Expect(status).To(Equal(http.StatusBadRequest))
                            var result map[string]interface{}
                Severity: Major
                Found in api/membership_test.go and 5 other locations - About 1 hr to fix
                api/membership_test.go on lines 231..239
                api/membership_test.go on lines 549..557
                api/membership_test.go on lines 679..687
                api/membership_test.go on lines 781..789
                api/membership_test.go on lines 851..859

                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 143.

                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 6 locations. Consider refactoring.
                Open

                        It("Should not approve membership invitation if missing parameters", func() {
                            status, body := PostJSON(a, CreateMembershipRoute("gameID", "clanPublicID", "invitation/approve"), map[string]interface{}{})
                
                            Expect(status).To(Equal(http.StatusBadRequest))
                            var result map[string]interface{}
                Severity: Major
                Found in api/membership_test.go and 5 other locations - About 1 hr to fix
                api/membership_test.go on lines 231..239
                api/membership_test.go on lines 422..430
                api/membership_test.go on lines 679..687
                api/membership_test.go on lines 781..789
                api/membership_test.go on lines 851..859

                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 143.

                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 6 locations. Consider refactoring.
                Open

                        It("Should not delete member if missing parameters", func() {
                            status, body := PostJSON(a, CreateMembershipRoute("gameID", "clanPublicID", "delete"), map[string]interface{}{})
                
                            Expect(status).To(Equal(http.StatusBadRequest))
                            var result map[string]interface{}
                Severity: Major
                Found in api/membership_test.go and 5 other locations - About 1 hr to fix
                api/membership_test.go on lines 231..239
                api/membership_test.go on lines 422..430
                api/membership_test.go on lines 549..557
                api/membership_test.go on lines 679..687
                api/membership_test.go on lines 781..789

                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 143.

                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

                        It("Should not update player if invalid payload", func() {
                            route := GetGameRoute("game-id", "/players/fake")
                            status, body := Put(a, route, "invalid")
                
                            Expect(status).To(Equal(http.StatusBadRequest))
                Severity: Major
                Found in api/player_test.go and 1 other location - About 1 hr to fix
                api/player_test.go on lines 81..90

                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 143.

                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

                        It("Should not create player if invalid payload", func() {
                            route := GetGameRoute("game-id", "/players")
                            status, body := Post(a, route, "invalid")
                
                            Expect(status).To(Equal(http.StatusBadRequest))
                Severity: Major
                Found in api/player_test.go and 1 other location - About 1 hr to fix
                api/player_test.go on lines 149..158

                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 143.

                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

                    if p.ApproverPublicID.Valid {
                        if p.DBApproverMetadata.Valid {
                            json.Unmarshal([]byte(nullOrString(p.DBApproverMetadata)), &p.ApproverMetadata)
                        } else {
                            p.ApproverMetadata = map[string]interface{}{}
                Severity: Major
                Found in models/DAO.go and 1 other location - About 1 hr to fix
                models/DAO.go on lines 212..225

                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 142.

                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

                    if p.DenierPublicID.Valid {
                        if p.DBDenierMetadata.Valid {
                            json.Unmarshal([]byte(nullOrString(p.DBDenierMetadata)), &p.DenierMetadata)
                        } else {
                            p.DenierMetadata = map[string]interface{}{}
                Severity: Major
                Found in models/DAO.go and 1 other location - About 1 hr to fix
                models/DAO.go on lines 197..210

                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 142.

                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

                Severity
                Category
                Status
                Source
                Language