Showing 34 of 45 total issues

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

            if assocs.Type() == rel.HasMany {
                var (
                    col, loaded = assocs.Collection()
                )

Severity: Minor
Found in reltest/preload.go and 1 other location - About 50 mins to fix
repository.go on lines 932..955

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

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 (q Query) SortAsc(fields ...string) Query {
    var (
        offset = len(q.SortQuery)
    )

Severity: Minor
Found in query.go and 1 other location - About 50 mins to fix
query.go on lines 228..239

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

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 (q Query) SortDesc(fields ...string) Query {
    var (
        offset = len(q.SortQuery)
    )

Severity: Minor
Found in query.go and 1 other location - About 50 mins to fix
query.go on lines 214..225

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

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

func (r repository) update(cw contextWrapper, doc *Document, mutation Mutation, filter FilterQuery) error {
    if mutation.Cascade {
        if err := r.saveBelongsTo(cw, doc, &mutation); err != nil {
            return err
        }
Severity: Major
Found in repository.go - About 45 mins to fix

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

    func (d Document) PrimaryFields() []string {
        if p, ok := d.v.(primary); ok {
            return p.PrimaryFields()
        }
    
    
    Severity: Minor
    Found in document.go and 1 other location - About 45 mins to fix
    collection.go on lines 61..71

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

    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 (c Collection) PrimaryFields() []string {
        if p, ok := c.v.(primary); ok {
            return p.PrimaryFields()
        }
    
    
    Severity: Minor
    Found in collection.go and 1 other location - About 45 mins to fix
    document.go on lines 91..101

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

    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 repository.insert has 6 return statements (exceeds 4 allowed).
    Open

    func (r repository) insert(cw contextWrapper, doc *Document, mutation Mutation) error {
        var (
            pField   string
            pFields  = doc.PrimaryFields()
            queriers = Build(doc.Table())
    Severity: Major
    Found in repository.go - About 40 mins to fix

      Method repository.saveHasMany has 6 return statements (exceeds 4 allowed).
      Open

      func (r repository) saveHasMany(cw contextWrapper, doc *Document, mutation *Mutation, insertion bool) error {
          for _, field := range doc.HasMany() {
              assocMuts, changed := mutation.Assoc[field]
              if !changed {
                  continue
      Severity: Major
      Found in repository.go - About 40 mins to fix

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

        func isDeepZero(rv reflect.Value, depth int) bool {
            if depth < 0 {
                return true
            }
        
        
        Severity: Major
        Found in util.go - About 40 mins to fix

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

          func QueriesConditionAdvancedAlias(ctx context.Context, repo rel.Repository) error {
              /// [condition-advanced-alias]
              var books []Book
              err := repo.FindAll(ctx, &books, where.Eq("available", true).And(where.Gte("price", 100).OrEq("discount", true)))
              /// [condition-advanced-alias]
          Severity: Minor
          Found in examples/queries.go and 1 other location - About 40 mins to fix
          examples/queries.go on lines 74..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 109.

          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 QueriesConditionAdvancedChain(ctx context.Context, repo rel.Repository) error {
              /// [condition-advanced-chain]
              var books []Book
              err := repo.FindAll(ctx, &books, rel.Eq("available", true).And(rel.Gte("price", 100).OrEq("discount", true)))
              /// [condition-advanced-chain]
          Severity: Minor
          Found in examples/queries.go and 1 other location - About 40 mins to fix
          examples/queries.go on lines 84..91

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

          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

          Function QuickExample has 5 return statements (exceeds 4 allowed).
          Open

          func QuickExample(ctx context.Context, repo rel.Repository) error {
              /// [quick-example]
              book := Book{Title: "REL for Dummies"}
          
              // Insert a Book.
          Severity: Major
          Found in examples/example.go - About 35 mins to fix

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

            func (r *Repository) Find(ctx context.Context, record interface{}, queriers ...rel.Querier) error {
                r.repo.Find(ctx, record, queriers...)
                return r.mock.Called(fetchContext(ctx), record, queriers).Error(0)
            }
            Severity: Minor
            Found in reltest/repository.go and 1 other location - About 35 mins to fix
            reltest/repository.go on lines 104..107

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

            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 (r *Repository) FindAll(ctx context.Context, records interface{}, queriers ...rel.Querier) error {
                r.repo.FindAll(ctx, records, queriers...)
                return r.mock.Called(fetchContext(ctx), records, queriers).Error(0)
            }
            Severity: Minor
            Found in reltest/repository.go and 1 other location - About 35 mins to fix
            reltest/repository.go on lines 88..91

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

            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

            Severity
            Category
            Status
            Source
            Language