Showing 76 of 96 total issues

Method Scope.getModelStruct has a Cognitive Complexity of 765 (exceeds 20 allowed). Consider refactoring.
Open

func (scope *Scope) getModelStruct(rootScope *Scope, allFields []*StructField) *ModelStruct {
    var modelStruct ModelStruct
    // Scope value can't be nil
    if scope.Value == nil {
        return &modelStruct
Severity: Minor
Found in model_struct.go - About 2 wks 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

File scope.go has 1189 lines of code (exceeds 500 allowed). Consider refactoring.
Open

package gorm

import (
    "bytes"
    "database/sql"
Severity: Major
Found in scope.go - About 2 days to fix

    Method Scope.getModelStruct has 392 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (scope *Scope) getModelStruct(rootScope *Scope, allFields []*StructField) *ModelStruct {
        var modelStruct ModelStruct
        // Scope value can't be nil
        if scope.Value == nil {
            return &modelStruct
    Severity: Major
    Found in model_struct.go - About 1 day to fix

      Function saveAfterAssociationsCallback has a Cognitive Complexity of 106 (exceeds 20 allowed). Consider refactoring.
      Open

      func saveAfterAssociationsCallback(scope *Scope) {
          for _, field := range scope.Fields() {
              autoUpdate, autoCreate, saveReference, relationship := saveAssociationCheck(scope, field)
      
              if relationship != nil && (relationship.Kind == "has_one" || relationship.Kind == "has_many" || relationship.Kind == "many_to_many") {
      Severity: Minor
      Found in callback_save.go - About 1 day 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

      DB has 89 methods (exceeds 20 allowed). Consider refactoring.
      Open

      type DB struct {
          sync.RWMutex
          Value        interface{}
          Error        error
          RowsAffected int64
      Severity: Major
      Found in main.go - About 1 day to fix

        Scope has 78 methods (exceeds 20 allowed). Consider refactoring.
        Open

        type Scope struct {
            Search          *search
            Value           interface{}
            SQL             string
            SQLVars         []interface{}
        Severity: Major
        Found in scope.go - About 1 day to fix

          Function createCallback has a Cognitive Complexity of 84 (exceeds 20 allowed). Consider refactoring.
          Open

          func createCallback(scope *Scope) {
              if !scope.HasError() {
                  defer scope.trace(NowFunc())
          
                  var (
          Severity: Minor
          Found in callback_create.go - About 1 day 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

          Method Scope.buildCondition has a Cognitive Complexity of 79 (exceeds 20 allowed). Consider refactoring.
          Open

          func (scope *Scope) buildCondition(clause map[string]interface{}, include bool) (str string) {
              var (
                  quotedTableName  = scope.QuotedTableName()
                  quotedPrimaryKey = scope.Quote(scope.PrimaryKey())
                  equalSQL         = "="
          Severity: Minor
          Found in scope.go - About 1 day 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

          Method mysql.DataTypeOf has a Cognitive Complexity of 60 (exceeds 20 allowed). Consider refactoring.
          Open

          func (s *mysql) DataTypeOf(field *StructField) string {
              var dataValue, sqlType, size, additionalType = ParseFieldStructForDialect(field, s)
          
              // MySQL allows only one auto increment column per table, and it must
              // be a KEY column.
          Severity: Minor
          Found in dialect_mysql.go - About 6 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

          Method Association.Delete has a Cognitive Complexity of 56 (exceeds 20 allowed). Consider refactoring.
          Open

          func (association *Association) Delete(values ...interface{}) *Association {
              if association.Error != nil {
                  return association
              }
          
          
          Severity: Minor
          Found in association.go - About 6 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

          Method Association.Replace has a Cognitive Complexity of 53 (exceeds 20 allowed). Consider refactoring.
          Open

          func (association *Association) Replace(values ...interface{}) *Association {
              if association.Error != nil {
                  return association
              }
          
          
          Severity: Minor
          Found in association.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 updateCallback has a Cognitive Complexity of 51 (exceeds 20 allowed). Consider refactoring.
          Open

          func updateCallback(scope *Scope) {
              if !scope.HasError() {
                  var sqls []string
          
                  if updateAttrs, ok := scope.InstanceGet("gorm:update_attrs"); ok {
          Severity: Minor
          Found in callback_update.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

          File main.go has 618 lines of code (exceeds 500 allowed). Consider refactoring.
          Open

          package gorm
          
          import (
              "context"
              "database/sql"
          Severity: Minor
          Found in main.go - About 4 hrs to fix

            Function preloadCallback has a Cognitive Complexity of 46 (exceeds 20 allowed). Consider refactoring.
            Open

            func preloadCallback(scope *Scope) {
                if _, skip := scope.InstanceGet("gorm:skip_query_callback"); skip {
                    return
                }
            
            
            Severity: Minor
            Found in callback_query_preload.go - About 4 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

            Method Scope.buildCondition has 124 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (scope *Scope) buildCondition(clause map[string]interface{}, include bool) (str string) {
                var (
                    quotedTableName  = scope.QuotedTableName()
                    quotedPrimaryKey = scope.Quote(scope.PrimaryKey())
                    equalSQL         = "="
            Severity: Major
            Found in scope.go - About 3 hrs to fix

              Method Scope.related has a Cognitive Complexity of 42 (exceeds 20 allowed). Consider refactoring.
              Open

              func (scope *Scope) related(value interface{}, foreignKeys ...string) *Scope {
                  toScope := scope.db.NewScope(value)
                  tx := scope.db.Set("gorm:association:source", scope.Value)
              
                  for _, foreignKey := range append(foreignKeys, toScope.typeName()+"Id", scope.typeName()+"Id") {
              Severity: Minor
              Found in scope.go - About 3 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

              Method Scope.getColumnAsArray has a Cognitive Complexity of 41 (exceeds 20 allowed). Consider refactoring.
              Open

              func (scope *Scope) getColumnAsArray(columns []string, values ...interface{}) (results [][]interface{}) {
                  resultMap := make(map[string][]interface{})
                  for _, value := range values {
                      indirectValue := indirect(reflect.ValueOf(value))
              
              
              Severity: Minor
              Found in scope.go - About 3 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

              Method postgres.DataTypeOf has a Cognitive Complexity of 38 (exceeds 20 allowed). Consider refactoring.
              Open

              func (s *postgres) DataTypeOf(field *StructField) string {
                  var dataValue, sqlType, size, additionalType = ParseFieldStructForDialect(field, s)
              
                  if sqlType == "" {
                      switch dataValue.Kind() {
              Severity: Minor
              Found in dialect_postgres.go - About 3 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 createCallback has 103 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func createCallback(scope *Scope) {
                  if !scope.HasError() {
                      defer scope.trace(NowFunc())
              
                      var (
              Severity: Major
              Found in callback_create.go - About 3 hrs to fix

                Function queryCallback has a Cognitive Complexity of 37 (exceeds 20 allowed). Consider refactoring.
                Open

                func queryCallback(scope *Scope) {
                    if _, skip := scope.InstanceGet("gorm:skip_query_callback"); skip {
                        return
                    }
                
                
                Severity: Minor
                Found in callback_query.go - About 3 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

                Severity
                Category
                Status
                Source
                Language