Showing 42 of 93 total issues

Function HandleVersioningBelongsTo has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

func HandleVersioningBelongsTo(context *qor.Context, record reflect.Value, field reflect.Value, relationship *gorm.Relationship, primaryKeys []string, fieldHasVersion bool) {
Severity: Minor
Found in resource/meta.go - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if metaValue.Value == nil {
                                primaryKeys = []string{}
                            }
    Severity: Major
    Found in resource/meta.go - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          } else if (relationship.Kind == "has_one" || relationship.Kind == "belongs_to") && context.GetDB().NewScope(f.Field.Interface()).PrimaryKeyZero() {
                              if f.Field.Kind() == reflect.Ptr && f.Field.IsNil() {
                                  f.Field.Set(reflect.New(f.Field.Type().Elem()))
                              }
      
      
      Severity: Major
      Found in resource/meta.go - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if fmt.Sprint(destroy.Value) != "0" && res.HasPermission(roles.Delete, context) {
                                context.GetDB().Delete(result, append([]interface{}{primaryQuerySQL}, primaryParams...)...)
                                return ErrProcessorSkipLeft
                            }
        Severity: Major
        Found in resource/crud.go - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                          if isPtr {
                              field.Set(reflect.Append(field, value))
                          } else {
                              field.Set(reflect.Append(field, value.Elem()))
                          }
          Severity: Major
          Found in resource/meta_value.go - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if len(relationship.ForeignFieldNames) == 2 {
                                        HandleVersioningBelongsTo(context, recordAsValue, field, relationship, primaryKeys, fieldHasVersion)
                                    }
            Severity: Major
            Found in resource/meta.go - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                      } else if _, ok := field.Addr().Interface().(*time.Time); ok {
                          meta.Setter = commonSetter(func(field reflect.Value, metaValue *MetaValue, context *qor.Context, record interface{}) {
                              if str := utils.ToString(metaValue.Value); str != "" {
                                  if newTime, err := utils.ParseTime(str, context); err == nil {
                                      field.Set(reflect.ValueOf(newTime))
              Severity: Major
              Found in resource/meta.go - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if metaor != nil {
                                        metaors = metaor.GetMetas()
                                    }
                Severity: Major
                Found in resource/schema.go - About 45 mins to fix

                  Function ParamsMatch has 7 return statements (exceeds 4 allowed).
                  Open

                  func ParamsMatch(source string, pth string) (url.Values, string, bool) {
                      var (
                          i, j int
                          p    = make(url.Values)
                          ext  = path.Ext(pth)
                  Severity: Major
                  Found in utils/params.go - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if err := scanner.Scan(utils.ToString(metaValue.Value)); err != nil {
                                                context.AddError(err)
                                                return
                                            }
                    Severity: Major
                    Found in resource/meta.go - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          if children, err := ConvertFormToMetaValues(request, metaors, prefix+name+"."); err == nil {
                                              nestedName := prefix + matches[2]
                                              if _, ok := nestedStructIndex[nestedName]; ok {
                                                  nestedStructIndex[nestedName]++
                                              } else {
                      Severity: Major
                      Found in resource/schema.go - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                        } else if source[len(source)-1] == ']' {
                                            index = len(source) - j - 1
                                        }
                        Severity: Major
                        Found in utils/params.go - About 45 mins to fix

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

                          func setupSetter(meta *Meta, fieldName string, record interface{}) {
                              nestedField := strings.Contains(fieldName, ".")
                          
                              // Setup nested fields
                              if nestedField {
                          Severity: Major
                          Found in resource/meta.go - About 40 mins to fix

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

                            func ToString(value interface{}) string {
                                if v, ok := value.([]string); ok {
                                    for _, s := range v {
                                        if s != "" {
                                            return s
                            Severity: Major
                            Found in utils/meta.go - About 40 mins to fix

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

                              func switchRecordToNewVersionIfNeeded(context *qor.Context, record interface{}) interface{} {
                                  if context.Request == nil {
                                      return record
                                  }
                              
                              
                              Severity: Major
                              Found in resource/meta.go - About 40 mins to fix

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

                                func Stringify(object interface{}) string {
                                    if obj, ok := object.(interface {
                                        Stringify() string
                                    }); ok {
                                        return obj.Stringify()
                                Severity: Major
                                Found in utils/utils.go - About 40 mins to fix

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

                                  func HandleBelongsTo(context *qor.Context, record reflect.Value, field reflect.Value, relationship *gorm.Relationship, primaryKeys []string) {
                                  Severity: Minor
                                  Found in resource/meta.go - About 35 mins to fix

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

                                    func HandleNormalManyToMany(context *qor.Context, field reflect.Value, metaValue *MetaValue, fieldHasVersion bool, compositePKeyConvertErr error) {
                                    Severity: Minor
                                    Found in resource/meta.go - About 35 mins 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

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

                                        func SortFormKeys(strs []string) {
                                            sort.Slice(strs, func(i, j int) bool { // true for first
                                                str1 := strs[i]
                                                str2 := strs[j]
                                                matched1 := replaceIdxRegexp.FindAllStringIndex(str1, -1)
                                        Severity: Major
                                        Found in utils/utils.go - About 35 mins to fix
                                          Severity
                                          Category
                                          Status
                                          Source
                                          Language