topfreegames/khan

View on GitHub

Showing 425 of 425 total issues

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

    {
        const prefix string = ",\"membershipLevels\":"
        out.RawString(prefix)
        if in.MembershipLevels == nil && (out.Flags&jwriter.NilMapAsEmpty) == 0 {
            out.RawString(`null`)
Severity: Major
Found in api/payload_easyjson.go and 8 other locations - About 3 hrs to fix
api/payload_easyjson.go on lines 127..153
api/payload_easyjson.go on lines 297..323
api/payload_easyjson.go on lines 459..485
api/payload_easyjson.go on lines 754..780
api/payload_easyjson.go on lines 904..930
api/payload_easyjson.go on lines 931..957
api/payload_easyjson.go on lines 1100..1126
models/clan_easyjson.go on lines 127..153

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

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 RetrieveClanHandler has a Cognitive Complexity of 37 (exceeds 20 allowed). Consider refactoring.
Open

func RetrieveClanHandler(app *App) func(c echo.Context) error {
    return func(c echo.Context) error {
        c.Set("route", "RetrieveClan")
        start := time.Now()
        gameID := c.Param("gameID")
Severity: Minor
Found in api/clan.go - About 3 hrs 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

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

func easyjsonA8a797f8DecodeGithubComTopfreegamesKhanApi12(in *jlexer.Lexer, out *ApplyForMembershipPayload) {
    isTopLevel := in.IsStart()
    if in.IsNull() {
        if isTopLevel {
            in.Consumed()
Severity: Major
Found in api/payload_easyjson.go and 2 other locations - About 3 hrs to fix
api/payload_easyjson.go on lines 626..658
api/payload_easyjson.go on lines 1149..1181

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

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 easyjsonA8a797f8DecodeGithubComTopfreegamesKhanApi10(in *jlexer.Lexer, out *BasePayloadWithRequestorAndPlayerPublicIDs) {
    isTopLevel := in.IsStart()
    if in.IsNull() {
        if isTopLevel {
            in.Consumed()
Severity: Major
Found in api/payload_easyjson.go and 2 other locations - About 3 hrs to fix
api/payload_easyjson.go on lines 626..658
api/payload_easyjson.go on lines 1260..1292

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

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 easyjsonA8a797f8DecodeGithubComTopfreegamesKhanApi6(in *jlexer.Lexer, out *HookPayload) {
    isTopLevel := in.IsStart()
    if in.IsNull() {
        if isTopLevel {
            in.Consumed()
Severity: Major
Found in api/payload_easyjson.go and 2 other locations - About 3 hrs to fix
api/payload_easyjson.go on lines 1149..1181
api/payload_easyjson.go on lines 1260..1292

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

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

    for _, field := range fields {
        oldVal, existsOld := sourceClan.Metadata[field]
        newVal, existsNew := metadata[field]
        log.D(logger, "Verifying field for change...", func(cm log.CM) {
            cm.Write(
Severity: Major
Found in api/clan_helpers.go and 1 other location - About 3 hrs to fix
api/player_helpers.go on lines 41..68

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

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

    for _, field := range fields {
        oldVal, existsOld := sourcePlayer.Metadata[field]
        newVal, existsNew := metadata[field]
        log.D(logger, "Verifying field for change...", func(cm log.CM) {
            cm.Write(
Severity: Major
Found in api/player_helpers.go and 1 other location - About 3 hrs to fix
api/clan_helpers.go on lines 107..133

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

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

var workerCmd = &cobra.Command{
    Use:   "worker",
    Short: "starts the khan hook dispatching worker",
    Long: `Starts khan hook dispatching worker with the specified arguments. You can use
environment variables to override configuration keys.`,
Severity: Major
Found in cmd/worker.go and 1 other location - About 3 hrs to fix
cmd/start.go on lines 24..65

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

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

var startCmd = &cobra.Command{
    Use:   "start",
    Short: "starts the khan API server",
    Long: `Starts khan server with the specified arguments. You can use
environment variables to override configuration keys.`,
Severity: Major
Found in cmd/start.go and 1 other location - About 3 hrs to fix
cmd/worker.go on lines 21..62

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

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

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

            for _, resultClan := range resultClans {
                resultClanMap := resultClan.(map[string]interface{})
                Expect(resultClanMap["membershipCount"] == nil).To(BeFalse())
                Expect(resultClanMap["publicID"] == nil).To(BeFalse())
                Expect(resultClanMap["metadata"] == nil).To(BeFalse())
Severity: Major
Found in api/clan_test.go and 1 other location - About 3 hrs to fix
api/clan_test.go on lines 1011..1029

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

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

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

            for _, resultClan := range resultClans {
                resultClanMap := resultClan.(map[string]interface{})
                Expect(resultClanMap["membershipCount"] == nil).To(BeFalse())
                Expect(resultClanMap["publicID"] == nil).To(BeFalse())
                Expect(resultClanMap["metadata"] == nil).To(BeFalse())
Severity: Major
Found in api/clan_test.go and 1 other location - About 3 hrs to fix
api/clan_test.go on lines 921..939

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

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

        It("Should not approve membership application if player does not exist", func() {
            playerPublicID := randomdata.FullName(randomdata.RandomGender)
            _, clan, owner, _, _, err := fixtures.GetClanWithMemberships(testDb, 0, 0, 0, 0, "", "")
            Expect(err).NotTo(HaveOccurred())

Severity: Major
Found in api/membership_test.go and 2 other locations - About 3 hrs to fix
api/membership_test.go on lines 804..824
api/membership_test.go on lines 874..894

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

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

        It("Should not delete member if player does not exist", func() {
            playerPublicID := randomdata.FullName(randomdata.RandomGender)
            _, clan, owner, _, _, err := fixtures.GetClanWithMemberships(testDb, 0, 0, 0, 0, "", "")
            Expect(err).NotTo(HaveOccurred())

Severity: Major
Found in api/membership_test.go and 2 other locations - About 3 hrs to fix
api/membership_test.go on lines 702..722
api/membership_test.go on lines 804..824

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

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

        It("Should not promote member if player does not exist", func() {
            playerPublicID := randomdata.FullName(randomdata.RandomGender)
            _, clan, owner, _, _, err := fixtures.GetClanWithMemberships(testDb, 0, 0, 0, 0, "", "")
            Expect(err).NotTo(HaveOccurred())

Severity: Major
Found in api/membership_test.go and 2 other locations - About 3 hrs to fix
api/membership_test.go on lines 702..722
api/membership_test.go on lines 874..894

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

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

func GetTestClanWithStaleData(db models.DB, staleApplications, staleInvites, staleDenies, staleDeletes int) (string, error) {
    gameID := uuid.NewV4().String()
    game := GameFactory.MustCreateWithOption(map[string]interface{}{
        "PublicID": gameID,
        "Metadata": map[string]interface{}{
Severity: Major
Found in models/fixtures/fixtures.go - About 2 hrs to fix

    Function GetTestPlayerWithMemberships has 98 lines of code (exceeds 50 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: Major
    Found in models/fixtures/fixtures.go - About 2 hrs to fix

      Function UpdateGameHandler has 98 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func UpdateGameHandler(app *App) func(c echo.Context) error {
          return func(c echo.Context) error {
              c.Set("route", "UpdateGame")
              start := time.Now()
              gameID := c.Param("gameID")
      Severity: Major
      Found in api/game.go - About 2 hrs to fix

        Function CreateClanHandler has 98 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func CreateClanHandler(app *App) func(c echo.Context) error {
            return func(c echo.Context) error {
                c.Set("route", "CreateClan")
                start := time.Now()
                gameID := c.Param("gameID")
        Severity: Major
        Found in api/clan.go - About 2 hrs to fix

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

          func BenchmarkPromoteMembership(b *testing.B) {
              db, err := models.GetPerfDB()
              if err != nil {
                  panic(err.Error())
              }
          Severity: Major
          Found in bench/membership_test.go and 1 other location - About 2 hrs to fix
          bench/membership_test.go on lines 188..213

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

          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 BenchmarkDeleteMembership(b *testing.B) {
              db, err := models.GetPerfDB()
              if err != nil {
                  panic(err.Error())
              }
          Severity: Major
          Found in bench/membership_test.go and 1 other location - About 2 hrs to fix
          bench/membership_test.go on lines 215..240

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

          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