topfreegames/khan

View on GitHub
models/fixtures/fixtures.go

Summary

Maintainability
F
4 days
Test Coverage

File fixtures.go has 738 lines of code (exceeds 500 allowed). Consider refactoring.
Open

// khan
// https://github.com/topfreegames/khan
//
// Licensed under the MIT license:
// http://www.opensource.org/licenses/mit-license
Severity: Minor
Found in models/fixtures/fixtures.go - About 7 hrs to fix

    Function GetClanWithMemberships has a Cognitive Complexity of 49 (exceeds 20 allowed). Consider refactoring.
    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: Minor
    Found in models/fixtures/fixtures.go - About 5 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

    Function GetClanWithMemberships has 143 lines of code (exceeds 50 allowed). Consider refactoring.
    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 4 hrs to fix

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

          func GetClanReachedMaxMemberships(db models.DB) (*models.Game, *models.Clan, *models.Player, []*models.Player, []*models.Membership, error) {
              gameID := uuid.NewV4().String()
              clanPublicID := uuid.NewV4().String()
          
              game := GameFactory.MustCreateWithOption(map[string]interface{}{
          Severity: Major
          Found in models/fixtures/fixtures.go - About 2 hrs to fix

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

                  Function GetTestClanWithStaleData has a Cognitive Complexity of 23 (exceeds 20 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: Minor
                  Found in models/fixtures/fixtures.go - About 45 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 GetClanReachedMaxMemberships has 7 return statements (exceeds 4 allowed).
                  Open

                  func GetClanReachedMaxMemberships(db models.DB) (*models.Game, *models.Clan, *models.Player, []*models.Player, []*models.Membership, error) {
                      gameID := uuid.NewV4().String()
                      clanPublicID := uuid.NewV4().String()
                  
                      game := GameFactory.MustCreateWithOption(map[string]interface{}{
                  Severity: Major
                  Found in models/fixtures/fixtures.go - About 45 mins to fix

                    Function CreateTestClans has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        db models.DB, mongoDB interfaces.MongoDB, gameID string, publicIDTemplate string, numberOfClans int, afterCreationHook AfterClanCreationHook,
                    Severity: Minor
                    Found in models/fixtures/fixtures.go - About 45 mins to fix

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

                      func CreateTestClans(
                          db models.DB, mongoDB interfaces.MongoDB, gameID string, publicIDTemplate string, numberOfClans int, afterCreationHook AfterClanCreationHook,
                      ) (*models.Player, []*models.Clan, error) {
                          if gameID == "" {
                              gameID = uuid.NewV4().String()
                      Severity: Major
                      Found in models/fixtures/fixtures.go - About 40 mins to fix

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

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

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

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

                          There are no issues that match your filters.

                          Category
                          Status