resource/schema.go
Function ConvertFormToMetaValues
has a Cognitive Complexity of 53 (exceeds 20 allowed). Consider refactoring. Open
Open
func ConvertFormToMetaValues(request *http.Request, metaors []Metaor, prefix string) (*MetaValues, error) {
metaValues := &MetaValues{}
metaorsMap := map[string]Metaor{}
convertedNextLevel := map[string]bool{}
nestedStructIndex := map[string]int{}
- Read upRead up
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 ConvertFormToMetaValues
has 68 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func ConvertFormToMetaValues(request *http.Request, metaors []Metaor, prefix string) (*MetaValues, error) {
metaValues := &MetaValues{}
metaorsMap := map[string]Metaor{}
convertedNextLevel := map[string]bool{}
nestedStructIndex := map[string]int{}
Function convertMapToMetaValues
has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring. Open
Open
func convertMapToMetaValues(values map[string]interface{}, metaors []Metaor) (*MetaValues, error) {
metaValues := &MetaValues{}
metaorMap := make(map[string]Metaor)
for _, metaor := range metaors {
metaorMap[metaor.GetName()] = metaor
- Read upRead up
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
Avoid deeply nested control flow statements. Open
Open
if metaor != nil {
metaors = metaor.GetMetas()
}
Avoid deeply nested control flow statements. Open
Open
if children, err := ConvertFormToMetaValues(request, metaors, prefix+name+"."); err == nil {
nestedName := prefix + matches[2]
if _, ok := nestedStructIndex[nestedName]; ok {
nestedStructIndex[nestedName]++
} else {