topfreegames/khan

View on GitHub

Showing 425 of 425 total issues

Method ESWorker.PerformUpdateES has 63 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (w *ESWorker) PerformUpdateES(m *workers.Msg) {
    tags := opentracing.Tags{"component": "go-workers"}
    span := opentracing.StartSpan("PerformUpdateES", tags)
    defer span.Finish()
    defer tracing.LogPanic(span)
Severity: Minor
Found in models/es_worker.go - About 1 hr to fix

    Method App.getUpdateSharedClanScoreOperation has 63 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (app *App) getUpdateSharedClanScoreOperation() operation {
        operationKey := "updateSharedClanScore"
        app.setOperationProbabilityConfigDefault(operationKey, 1)
        return operation{
            probability: app.getOperationProbabilityConfig(operationKey),
    Severity: Minor
    Found in loadtest/clan.go - About 1 hr to fix

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

              It("Should not create membership application if invalid payload", func() {
                  gameID := "gameID"
                  clanPublicID := randomdata.FullName(randomdata.RandomGender)
      
                  status, body := Post(a, CreateMembershipRoute(gameID, clanPublicID, "application"), "invalid")
      Severity: Major
      Found in api/membership_test.go and 5 other locations - About 1 hr to fix
      api/membership_test.go on lines 432..443
      api/membership_test.go on lines 559..570
      api/membership_test.go on lines 689..700
      api/membership_test.go on lines 791..802
      api/membership_test.go on lines 861..872

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

      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 invalid payload", func() {
                  gameID := "gameID"
                  clanPublicID := randomdata.FullName(randomdata.RandomGender)
      
                  status, body := Post(a, CreateMembershipRoute(gameID, clanPublicID, "invitation/approve"), "invalid")
      Severity: Major
      Found in api/membership_test.go and 5 other locations - About 1 hr to fix
      api/membership_test.go on lines 241..252
      api/membership_test.go on lines 432..443
      api/membership_test.go on lines 689..700
      api/membership_test.go on lines 791..802
      api/membership_test.go on lines 861..872

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

      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 application if invalid payload", func() {
                  gameID := "gameID"
                  clanPublicID := randomdata.FullName(randomdata.RandomGender)
      
                  status, body := Post(a, CreateMembershipRoute(gameID, clanPublicID, "application/approve"), "invalid")
      Severity: Major
      Found in api/membership_test.go and 5 other locations - About 1 hr to fix
      api/membership_test.go on lines 241..252
      api/membership_test.go on lines 432..443
      api/membership_test.go on lines 559..570
      api/membership_test.go on lines 791..802
      api/membership_test.go on lines 861..872

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

      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 invalid payload", func() {
                  gameID := "gameID"
                  clanPublicID := randomdata.FullName(randomdata.RandomGender)
      
                  status, body := Post(a, CreateMembershipRoute(gameID, clanPublicID, "promote"), "invalid")
      Severity: Major
      Found in api/membership_test.go and 5 other locations - About 1 hr to fix
      api/membership_test.go on lines 241..252
      api/membership_test.go on lines 432..443
      api/membership_test.go on lines 559..570
      api/membership_test.go on lines 689..700
      api/membership_test.go on lines 861..872

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

      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 invalid payload", func() {
                  gameID := "gameID"
                  clanPublicID := randomdata.FullName(randomdata.RandomGender)
      
                  status, body := Post(a, CreateMembershipRoute(gameID, clanPublicID, "invitation"), "invalid")
      Severity: Major
      Found in api/membership_test.go and 5 other locations - About 1 hr to fix
      api/membership_test.go on lines 241..252
      api/membership_test.go on lines 559..570
      api/membership_test.go on lines 689..700
      api/membership_test.go on lines 791..802
      api/membership_test.go on lines 861..872

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

      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 invalid payload", func() {
                  gameID := "gameID"
                  clanPublicID := randomdata.FullName(randomdata.RandomGender)
      
                  status, body := Post(a, CreateMembershipRoute(gameID, clanPublicID, "delete"), "invalid")
      Severity: Major
      Found in api/membership_test.go and 5 other locations - About 1 hr to fix
      api/membership_test.go on lines 241..252
      api/membership_test.go on lines 432..443
      api/membership_test.go on lines 559..570
      api/membership_test.go on lines 689..700
      api/membership_test.go on lines 791..802

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

      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 transfer a clan ownership if missing parameters", func() {
                  route := GetGameRoute("game-id", fmt.Sprintf("clans/%s/transfer-ownership", "public-id"))
                  status, body := PostJSON(app, route, map[string]interface{}{})
      
                  Expect(status).To(Equal(http.StatusBadRequest))
      Severity: Major
      Found in api/clan_test.go and 1 other location - About 1 hr to fix
      api/clan_test.go on lines 511..520

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

      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 clan if missing parameters", func() {
                  route := GetGameRoute("gameID", fmt.Sprintf("/clans/%s", "publicID"))
                  status, body := PutJSON(app, route, map[string]interface{}{})
      
                  Expect(status).To(Equal(http.StatusBadRequest))
      Severity: Major
      Found in api/clan_test.go and 1 other location - About 1 hr to fix
      api/clan_test.go on lines 324..334

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

      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 GetTestPlayerWithMemberships has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring.
      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: Minor
      Found in models/fixtures/fixtures.go - About 1 hr 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

      Function ApproveOrDenyMembershipApplicationHandler has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring.
      Open

      func ApproveOrDenyMembershipApplicationHandler(app *App) func(c echo.Context) error {
          return func(c echo.Context) error {
              c.Set("route", "ApproverOrDenyApplication")
              start := time.Now()
              action := c.Param("action")
      Severity: Minor
      Found in api/membership.go - About 1 hr 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

      Function createClans has 60 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func createClans(db models.DB, games []string, clans int, progress func() bool) map[string][]clanData {
          for _, game := range games {
              sql := `
              WITH owner AS (
                  INSERT INTO players(
      Severity: Minor
      Found in perf/main.go - About 1 hr to fix

        Function easyjsonA8a797f8DecodeGithubComTopfreegamesKhanApi9 has 59 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

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

          Function RetrieveClansSummariesHandler has 59 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func RetrieveClansSummariesHandler(app *App) func(c echo.Context) error {
              return func(c echo.Context) error {
                  c.Set("route", "RetrieveClansSummaries")
                  start := time.Now()
                  gameID := c.Param("gameID")
          Severity: Minor
          Found in api/clan.go - About 1 hr to fix

            Method App.configureApplication has 58 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (app *App) configureApplication() {
                app.Engine = standard.New(fmt.Sprintf("%s:%d", app.Host, app.Port))
                if app.Fast {
                    engine := fasthttp.New(fmt.Sprintf("%s:%d", app.Host, app.Port))
                    engine.ReadBufferSize = app.ReadBufferSize
            Severity: Minor
            Found in api/app.go - About 1 hr to fix

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

              func easyjsonA8a797f8EncodeGithubComTopfreegamesKhanApi10(out *jwriter.Writer, in BasePayloadWithRequestorAndPlayerPublicIDs) {
                  out.RawByte('{')
                  first := true
                  _ = first
                  {
              Severity: Major
              Found in api/payload_easyjson.go and 2 other locations - About 1 hr to fix
              api/payload_easyjson.go on lines 659..674
              api/payload_easyjson.go on lines 1293..1308

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

              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

              func easyjsonA8a797f8EncodeGithubComTopfreegamesKhanApi12(out *jwriter.Writer, in ApplyForMembershipPayload) {
                  out.RawByte('{')
                  first := true
                  _ = first
                  {
              Severity: Major
              Found in api/payload_easyjson.go and 2 other locations - About 1 hr to fix
              api/payload_easyjson.go on lines 659..674
              api/payload_easyjson.go on lines 1182..1197

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

              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

              func easyjsonA8a797f8EncodeGithubComTopfreegamesKhanApi6(out *jwriter.Writer, in HookPayload) {
                  out.RawByte('{')
                  first := true
                  _ = first
                  {
              Severity: Major
              Found in api/payload_easyjson.go and 2 other locations - About 1 hr to fix
              api/payload_easyjson.go on lines 1182..1197
              api/payload_easyjson.go on lines 1293..1308

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

              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 transfer a clan ownership if invalid payload", func() {
                          route := GetGameRoute("game-id", fmt.Sprintf("clans/%s/transfer-ownership", "random-id"))
                          status, body := Post(app, route, "invalid")
              
                          Expect(status).To(Equal(http.StatusBadRequest))
              Severity: Major
              Found in api/clan_test.go and 1 other location - About 1 hr to fix
              api/clan_test.go on lines 522..532

              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

              Severity
              Category
              Status
              Source
              Language