topfreegames/khan

View on GitHub
lib/lib.go

Summary

Maintainability
D
1 day
Test Coverage

Khan has 39 methods (exceeds 20 allowed). Consider refactoring.
Open

type Khan struct {
    httpClient *http.Client
    Config     *viper.Viper
    url        string
    user       string
Severity: Minor
Found in lib/lib.go - About 5 hrs to fix

    Method Khan.sendTo has 7 return statements (exceeds 4 allowed).
    Open

    func (k *Khan) sendTo(ctx context.Context, method, url string, payload interface{}) ([]byte, error) {
        payloadJSON, err := json.Marshal(payload)
        if err != nil {
            return nil, err
        }
    Severity: Major
    Found in lib/lib.go - About 45 mins to fix

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

      func getHTTPTransport(
          maxIdleConns, maxIdleConnsPerHost int,
      ) http.RoundTripper {
          if _, ok := http.DefaultTransport.(*http.Transport); !ok {
              return http.DefaultTransport // tests use a mock transport
      Severity: Major
      Found in lib/lib.go and 1 other location - About 1 hr to fix
      api/dispatcher.go on lines 56..80

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

      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 (k *Khan) UpdateClan(ctx context.Context, clan *ClanPayload) (*Result, error) {
          route := k.buildUpdateClanURL(clan.PublicID)
          body, err := k.sendTo(ctx, "PUT", route, clan)
          if err != nil {
              return nil, err
      Severity: Major
      Found in lib/lib.go and 1 other location - About 1 hr to fix
      lib/lib.go on lines 407..421

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

      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 (k *Khan) ApplyForMembership(
          ctx context.Context,
          payload *ApplicationPayload,
      ) (*ClanApplyResult, error) {
          route := k.buildApplyForMembershipURL(payload.ClanID)
      Severity: Major
      Found in lib/lib.go and 1 other location - About 1 hr to fix
      lib/lib.go on lines 335..345

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

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

      There are no issues that match your filters.

      Category
      Status