topfreegames/khan

View on GitHub

Showing 425 of 425 total issues

Function easyjsonA8a797f8DecodeGithubComTopfreegamesKhanApi7 has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
Open

func easyjsonA8a797f8DecodeGithubComTopfreegamesKhanApi7(in *jlexer.Lexer, out *CreatePlayerPayload) {
    isTopLevel := in.IsStart()
    if in.IsNull() {
        if isTopLevel {
            in.Consumed()
Severity: Minor
Found in api/payload_easyjson.go - About 55 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function easyjson91eb9988DecodeGithubComTopfreegamesKhanModels has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
Open

func easyjson91eb9988DecodeGithubComTopfreegamesKhanModels(in *jlexer.Lexer, out *Clan) {
    isTopLevel := in.IsStart()
    if in.IsNull() {
        if isTopLevel {
            in.Consumed()
Severity: Minor
Found in models/clan_easyjson.go - About 55 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function easyjsonA8a797f8DecodeGithubComTopfreegamesKhanApi3 has a Cognitive Complexity of 24 (exceeds 20 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 55 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function easyjsonA8a797f8DecodeGithubComTopfreegamesKhanApi9 has a Cognitive Complexity of 24 (exceeds 20 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 55 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method App.getUpdateSharedClanScoreOperation has a Cognitive Complexity of 24 (exceeds 20 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 55 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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

func (k *Khan) RetrieveClan(ctx context.Context, clanID string) (*Clan, error) {
    route := k.buildRetrieveClanURL(clanID)
    body, err := k.sendTo(ctx, "GET", route, nil)

    if err != nil {
Severity: Major
Found in lib/lib.go and 5 other locations - About 55 mins to fix
lib/lib.go on lines 307..318
lib/lib.go on lines 348..359
lib/lib.go on lines 362..373
lib/lib.go on lines 471..485
lib/lib.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 125.

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

func (k *Khan) RetrievePlayer(ctx context.Context, publicID string) (*Player, error) {
    route := k.buildRetrievePlayerURL(publicID)
    body, err := k.sendTo(ctx, "GET", route, nil)

    if err != nil {
Severity: Major
Found in lib/lib.go and 5 other locations - About 55 mins to fix
lib/lib.go on lines 348..359
lib/lib.go on lines 362..373
lib/lib.go on lines 393..404
lib/lib.go on lines 471..485
lib/lib.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 125.

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

func (k *Khan) SearchClans(ctx context.Context, clanName string) (*SearchClansResult, error) {
    route := k.buildSearchClansURL(clanName)
    body, err := k.sendTo(ctx, "GET", route, nil)
    if err != nil {
        return nil, err
Severity: Major
Found in lib/lib.go and 5 other locations - About 55 mins to fix
lib/lib.go on lines 307..318
lib/lib.go on lines 348..359
lib/lib.go on lines 362..373
lib/lib.go on lines 393..404
lib/lib.go on lines 471..485

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

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

func (k *Khan) LeaveClan(
    ctx context.Context,
    clanID string,
) (*LeaveClanResult, error) {
    route := k.buildLeaveClanURL(clanID)
Severity: Major
Found in lib/lib.go and 5 other locations - About 55 mins to fix
lib/lib.go on lines 307..318
lib/lib.go on lines 348..359
lib/lib.go on lines 362..373
lib/lib.go on lines 393..404
lib/lib.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 125.

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

func (k *Khan) RetrieveClanMembers(ctx context.Context, clanID string) (*ClanMembers, error) {
    route := k.buildRetrieveClanMembersURL(clanID)
    body, err := k.sendTo(ctx, "GET", route, nil)

    if err != nil {
Severity: Major
Found in lib/lib.go and 5 other locations - About 55 mins to fix
lib/lib.go on lines 307..318
lib/lib.go on lines 362..373
lib/lib.go on lines 393..404
lib/lib.go on lines 471..485
lib/lib.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 125.

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

func (k *Khan) RetrieveClanSummary(ctx context.Context, clanID string) (*ClanSummary, error) {
    route := k.buildRetrieveClanSummaryURL(clanID)
    body, err := k.sendTo(ctx, "GET", route, nil)

    if err != nil {
Severity: Major
Found in lib/lib.go and 5 other locations - About 55 mins to fix
lib/lib.go on lines 307..318
lib/lib.go on lines 348..359
lib/lib.go on lines 393..404
lib/lib.go on lines 471..485
lib/lib.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 125.

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

Your code does not pass gofmt in 11 places. Go fmt your code!
Open

// khan
Severity: Minor
Found in models/clan.go by gofmt

Function CreateGame has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

    db DB,
    publicID, name string,
    levels, metadata map[string]interface{},
    minLevelAccept, minLevelCreate, minLevelRemove,
    minOffsetRemove, minOffsetPromote, minOffsetDemote, maxMembers,
Severity: Major
Found in models/game.go - About 50 mins to fix

    Function PromoteOrDemoteMember has 8 return statements (exceeds 4 allowed).
    Open

    func PromoteOrDemoteMember(db DB, game *Game, gameID, playerPublicID, clanPublicID, requestorPublicID, action string) (*Membership, error) {
        demote := action == "demote"
        promote := action == "promote"
    
        levelOffset := game.MinLevelOffsetToDemoteMember
    Severity: Major
    Found in models/membership.go - About 50 mins to fix

      Function GetTestClanWithStaleData has 8 return statements (exceeds 4 allowed).
      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 50 mins to fix

        Function GetClanWithMemberships has 8 return statements (exceeds 4 allowed).
        Open

        func GetClanWithMemberships(
            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) {
            var game *models.Game
        
            pendingsAreInvites := true
        Severity: Major
        Found in models/fixtures/fixtures.go - About 50 mins to fix

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

          func (mr *MockKhanInterfaceMockRecorder) CreatePlayer(arg0, arg1, arg2, arg3 interface{}) *gomock.Call {
              mr.mock.ctrl.T.Helper()
              return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreatePlayer", reflect.TypeOf((*MockKhanInterface)(nil).CreatePlayer), arg0, arg1, arg2, arg3)
          }
          Severity: Minor
          Found in lib/mocks/khan.go and 1 other location - About 45 mins to fix
          lib/mocks/khan.go on lines 287..290

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

          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 (mr *MockKhanInterfaceMockRecorder) UpdatePlayer(arg0, arg1, arg2, arg3 interface{}) *gomock.Call {
              mr.mock.ctrl.T.Helper()
              return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdatePlayer", reflect.TypeOf((*MockKhanInterface)(nil).UpdatePlayer), arg0, arg1, arg2, arg3)
          }
          Severity: Minor
          Found in lib/mocks/khan.go and 1 other location - About 45 mins to fix
          lib/mocks/khan.go on lines 107..110

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

          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 CreateGamePayload.Validate has 7 return statements (exceeds 4 allowed).
          Open

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

            Function ApplySecurityChanges has 7 return statements (exceeds 4 allowed).
            Open

            func ApplySecurityChanges(db egorp.Database, encryptionKey []byte, players []*Player) error {
            
                trx, err := db.Begin()
                if err != nil {
                    return err
            Severity: Major
            Found in models/player.go - About 45 mins to fix
              Severity
              Category
              Status
              Source
              Language