resource/meta_test.go

Summary

Maintainability
F
3 days
Test Coverage

File meta_test.go has 911 lines of code (exceeds 500 allowed). Consider refactoring.
Open

package resource_test

import (
    "database/sql/driver"
    "fmt"
Severity: Major
Found in resource/meta_test.go - About 1 day to fix

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

    func checkMeta(record interface{}, meta *resource.Meta, value interface{}, t *testing.T, expectedValues ...string) {
    Severity: Minor
    Found in resource/meta_test.go - About 35 mins to fix

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

      func TestSwitchRecordToNewVersionIfNeeded_Uint64ID(t *testing.T) {
          db := testutils.GetTestDB()
          testutils.ResetDBTables(db, &CollectionWithVersionAndUint64PrimaryKey{})
          registerVersionNameCallback(db)
      
      
      Severity: Major
      Found in resource/meta_test.go and 2 other locations - About 2 hrs to fix
      resource/meta_test.go on lines 965..982
      resource/meta_test.go on lines 1029..1046

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

      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 TestSwitchRecordToNewVersionIfNeeded_WithNoAssignVersionMethod(t *testing.T) {
          db := testutils.GetTestDB()
          testutils.ResetDBTables(db, &Athlete{})
          registerVersionNameCallback(db)
      
      
      Severity: Major
      Found in resource/meta_test.go and 2 other locations - About 2 hrs to fix
      resource/meta_test.go on lines 965..982
      resource/meta_test.go on lines 984..1000

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

      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 TestSwitchRecordToNewVersionIfNeeded(t *testing.T) {
          db := testutils.GetTestDB()
          testutils.ResetDBTables(db, &CollectionWithVersion{})
          registerVersionNameCallback(db)
      
      
      Severity: Major
      Found in resource/meta_test.go and 2 other locations - About 2 hrs to fix
      resource/meta_test.go on lines 984..1000
      resource/meta_test.go on lines 1029..1046

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

      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 _, p := range associatedProducts {
              if p.ID == p1.ID && p.CompositePrimaryKey == fmt.Sprintf("%d%s%s", p1.ID, resource.CompositePrimaryKeySeparator, p1.GetVersionName()) {
                  i += 1
              }
      
      
      Severity: Major
      Found in resource/meta_test.go and 1 other location - About 1 hr to fix
      resource/meta_test.go on lines 525..533

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

      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 _, p := range associatedProducts {
              if p.ID == p1.ID && p.CompositePrimaryKey == fmt.Sprintf("%d%s%s", p1.ID, resource.CompositePrimaryKeySeparator, p1.GetVersionName()) {
                  i += 1
              }
      
      
      Severity: Major
      Found in resource/meta_test.go and 1 other location - About 1 hr to fix
      resource/meta_test.go on lines 625..633

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

      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 TestFloatMetaValuerAndSetter(t *testing.T) {
          user := &struct {
              Age  float64
              Age2 *float64
          }{}
      Severity: Minor
      Found in resource/meta_test.go and 1 other location - About 55 mins to fix
      resource/meta_test.go on lines 60..81

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

      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 TestStringMetaValuerAndSetter(t *testing.T) {
          user := &struct {
              Name  string
              Name2 *string
          }{}
      Severity: Minor
      Found in resource/meta_test.go and 1 other location - About 55 mins to fix
      resource/meta_test.go on lines 122..143

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

      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 (coll *CollectionWithVersionAndUint64PrimaryKey) AssignVersionName(db *gorm.DB) {
          var count int
          name := time.Now().Format("2006-01-02")
          db.Model(&CollectionWithVersionAndUint64PrimaryKey{}).Where("id = ? AND version_name like ?", coll.ID, name+"%").Count(&count)
          coll.VersionName = fmt.Sprintf("%s-v%v", name, count+1)
      Severity: Minor
      Found in resource/meta_test.go and 1 other location - About 55 mins to fix
      resource/meta_test.go on lines 315..320

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

      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 (coll *CollectionWithVersion) AssignVersionName(db *gorm.DB) {
          var count int
          name := time.Now().Format("2006-01-02")
          db.Model(&CollectionWithVersion{}).Where("id = ? AND version_name like ?", coll.ID, name+"%").Count(&count)
          coll.VersionName = fmt.Sprintf("%s-v%v", name, count+1)
      Severity: Minor
      Found in resource/meta_test.go and 1 other location - About 55 mins to fix
      resource/meta_test.go on lines 322..327

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

      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

      don't use underscores in Go names; var p2_v2 should be p2V2
      Open

          p2_v2 := ProductWithVersion{Name: "p2"}
      Severity: Minor
      Found in resource/meta_test.go by golint

      don't use underscores in Go names; var p2_v1 should be p2V1
      Open

          p2_v1 := ProductWithVersion{Name: "p2"}
      Severity: Minor
      Found in resource/meta_test.go by golint

      should replace i += 1 with i++
      Open

                  i += 1
      Severity: Minor
      Found in resource/meta_test.go by golint

      Your code does not pass gofmt in 1 place. Go fmt your code!
      Open

      package resource_test
      Severity: Minor
      Found in resource/meta_test.go by gofmt

      should replace i += 1 with i++
      Open

                  i += 1
      Severity: Minor
      Found in resource/meta_test.go by golint

      don't use underscores in Go names; var p2_v2 should be p2V2
      Open

          p2_v2 := ProductWithVersion{Name: "p2"}
      Severity: Minor
      Found in resource/meta_test.go by golint

      don't use underscores in Go names; var p2_v3 should be p2V3
      Open

          p2_v3 := ProductWithVersion{Name: "p3"}
      Severity: Minor
      Found in resource/meta_test.go by golint

      don't use underscores in Go names; var p2_v2 should be p2V2
      Open

          p2_v2 := ProductWithVersion{Name: "p2"}
      Severity: Minor
      Found in resource/meta_test.go by golint

      don't use underscores in Go names; var p2_v1 should be p2V1
      Open

          p2_v1 := ProductWithVersion{Name: "p2"}
      Severity: Minor
      Found in resource/meta_test.go by golint

      don't use underscores in Go names; var m1_v2 should be m1V2
      Open

          m1_v2 := m1
      Severity: Minor
      Found in resource/meta_test.go by golint

      don't use underscores in Go names; var p2_v1 should be p2V1
      Open

          p2_v1 := ProductWithVersion{Name: "p2"}
      Severity: Minor
      Found in resource/meta_test.go by golint

      don't use underscores in Go names; var p2_v1 should be p2V1
      Open

          p2_v1 := ProductWithVersion{Name: "p2"}
      Severity: Minor
      Found in resource/meta_test.go by golint

      don't use underscores in Go names; var p2_v1 should be p2V1
      Open

          p2_v1 := ProductWithVersion{Name: "p2"}
      Severity: Minor
      Found in resource/meta_test.go by golint

      should replace i += 1 with i++
      Open

                  i += 1
      Severity: Minor
      Found in resource/meta_test.go by golint

      don't use underscores in Go names; var p3_v1 should be p3V1
      Open

          p3_v1 := ProductWithVersion{Name: "p3"}
      Severity: Minor
      Found in resource/meta_test.go by golint

      should replace i += 1 with i++
      Open

                  i += 1
      Severity: Minor
      Found in resource/meta_test.go by golint

      don't use underscores in Go names; var p2_v2 should be p2V2
      Open

          p2_v2 := ProductWithVersion{Name: "p2"}
      Severity: Minor
      Found in resource/meta_test.go by golint

      There are no issues that match your filters.

      Category
      Status