File clan.go
has 854 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
Function GetClanDetails
has 119 lines of code (exceeds 50 allowed). Consider refactoring. Open
func GetClanDetails(db DB, encryptionKey []byte, gameID string, clan *Clan, maxClansPerPlayer int, options *GetClanDetailsOptions) (map[string]interface{}, error) {
query := fmt.Sprintf(`
WITH memberships_pending AS (
SELECT *
FROM memberships im
Function TransferClanOwnership
has 73 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TransferClanOwnership(db DB, encryptionKey []byte, gameID, clanPublicID, playerPublicID string, levels map[string]interface{}, maxLevel int) (*Clan, *Player, *Player, error) {
clan, err := GetClanByPublicID(db, gameID, clanPublicID)
if err != nil {
return nil, nil, nil, err
}
Function LeaveClan
has 13 return statements (exceeds 4 allowed). Open
func LeaveClan(db DB, encryptionKey []byte, gameID, publicID string) (*Clan, *Player, *Player, error) {
clan, err := GetClanByPublicID(db, gameID, publicID)
if err != nil {
return nil, nil, nil, err
}
Function TransferClanOwnership
has 13 return statements (exceeds 4 allowed). Open
func TransferClanOwnership(db DB, encryptionKey []byte, gameID, clanPublicID, playerPublicID string, levels map[string]interface{}, maxLevel int) (*Clan, *Player, *Player, error) {
clan, err := GetClanByPublicID(db, gameID, clanPublicID)
if err != nil {
return nil, nil, nil, err
}
Function LeaveClan
has 54 lines of code (exceeds 50 allowed). Consider refactoring. Open
func LeaveClan(db DB, encryptionKey []byte, gameID, publicID string) (*Clan, *Player, *Player, error) {
clan, err := GetClanByPublicID(db, gameID, publicID)
if err != nil {
return nil, nil, nil, err
}
Function GetClanDetails
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
func GetClanDetails(db DB, encryptionKey []byte, gameID string, clan *Clan, maxClansPerPlayer int, options *GetClanDetailsOptions) (map[string]interface{}, error) {
Function CreateClan
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
func CreateClan(db DB, encryptionKey []byte, gameID, publicID, name, ownerPublicID string, metadata map[string]interface{}, allowApplication, autoJoin bool, maxClansPerPlayer int) (*Clan, error) {
Function UpdateClan
has 6 return statements (exceeds 4 allowed). Open
func UpdateClan(db DB, gameID, publicID, name, ownerPublicID string, metadata map[string]interface{}, allowApplication, autoJoin bool) (*Clan, error) {
clan, err := GetClanByPublicIDAndOwnerPublicID(db, gameID, publicID, ownerPublicID)
if err != nil {
return nil, err
}
Function UpdateClanMembershipCount
has 6 return statements (exceeds 4 allowed). Open
func UpdateClanMembershipCount(db DB, id int64) error {
query := `
UPDATE clans SET membership_count=membership.count+1
FROM (
SELECT COUNT(*) as count
Function GetClanByPublicIDAndOwnerPublicID
has 6 return statements (exceeds 4 allowed). Open
func GetClanByPublicIDAndOwnerPublicID(db DB, gameID, publicID, ownerPublicID string) (*Clan, error) {
var clans []*Clan
var players []*Player
_, err := db.Select(&clans, "SELECT * FROM clans WHERE game_id=$1 AND public_id=$2", gameID, publicID)
if err != nil {
Function TransferClanOwnership
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func TransferClanOwnership(db DB, encryptionKey []byte, gameID, clanPublicID, playerPublicID string, levels map[string]interface{}, maxLevel int) (*Clan, *Player, *Player, error) {
Function SearchClan
has 5 return statements (exceeds 4 allowed). Open
func SearchClan(
db DB, mongo interfaces.MongoDB, gameID, term string, pageSize int64,
) ([]Clan, error) {
if term == "" {
return nil, &EmptySearchTermError{}
Function CreateClan
has 5 return statements (exceeds 4 allowed). Open
func CreateClan(db DB, encryptionKey []byte, gameID, publicID, name, ownerPublicID string, metadata map[string]interface{}, allowApplication, autoJoin bool, maxClansPerPlayer int) (*Clan, error) {
player, err := GetPlayerByPublicID(db, encryptionKey, gameID, ownerPublicID)
if err != nil {
return nil, err
}
Similar blocks of code found in 3 locations. Consider refactoring. Open
func (c *Clan) IndexClanIntoElasticSearch() error {
es := es.GetConfiguredClient()
// TODO: fix it, boomforce is hardcoded for now
if es != nil && c.GameID == "boomforce" {
workers.Enqueue(queues.KhanESQueue, "Add", map[string]interface{}{
- Read upRead up
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 128.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
func (c *Clan) DeleteClanFromElasticSearch() error {
es := es.GetConfiguredClient()
// TODO: fix it, boomforce is hardcoded for now
if es != nil && c.GameID == "boomforce" {
workers.Enqueue(queues.KhanESQueue, "Add", map[string]interface{}{
- Read upRead up
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 128.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
func (c *Clan) UpdateClanIntoElasticSearch() error {
es := es.GetConfiguredClient()
// TODO: fix it, boomforce is hardcoded for now
if es != nil && c.GameID == "boomforce" {
workers.Enqueue(queues.KhanESQueue, "Add", map[string]interface{}{
- Read upRead up
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 128.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
func getClanLevelByLevelInt(levelInt int, levels map[string]interface{}) string {
for k, v := range levels {
switch v.(type) {
case float64:
if int(v.(float64)) == levelInt {
- Read upRead up
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 102.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Your code does not pass gofmt in 11 places. Go fmt your code! Open
// khan
- Exclude checks