Showing 9 of 49 total issues
Function Type
has 94 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func Type(data any) (c gltf.ComponentType, t gltf.AccessorType, count uint32) {
v := reflect.ValueOf(data)
if v.Kind() != reflect.Slice {
panic(fmt.Sprintf("go3mf: binary.Type expecting a slice but got %s", v.Kind()))
}
Function ReadColor
has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring. Open
Open
func ReadColor(doc *gltf.Document, acr *gltf.Accessor, buffer [][4]uint8) ([][4]uint8, error) {
switch acr.ComponentType {
case gltf.ComponentUbyte, gltf.ComponentUshort, gltf.ComponentFloat:
default:
return nil, errComponentType(acr.ComponentType)
- 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 ReadColor64
has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring. Open
Open
func ReadColor64(doc *gltf.Document, acr *gltf.Accessor, buffer [][4]uint16) ([][4]uint16, error) {
switch acr.ComponentType {
case gltf.ComponentUbyte, gltf.ComponentUshort, gltf.ComponentFloat:
default:
return nil, errComponentType(acr.ComponentType)
- 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 WriteAttributesInterleaved
has 67 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func WriteAttributesInterleaved(doc *gltf.Document, v Attributes) (map[string]uint32, error) {
type attrProps struct {
Name string
Normalized bool
}
Function ReadColor64
has 60 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func ReadColor64(doc *gltf.Document, acr *gltf.Accessor, buffer [][4]uint16) ([][4]uint16, error) {
switch acr.ComponentType {
case gltf.ComponentUbyte, gltf.ComponentUshort, gltf.ComponentFloat:
default:
return nil, errComponentType(acr.ComponentType)
Function ReadColor
has 51 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func ReadColor(doc *gltf.Document, acr *gltf.Accessor, buffer [][4]uint8) ([][4]uint8, error) {
switch acr.ComponentType {
case gltf.ComponentUbyte, gltf.ComponentUshort, gltf.ComponentFloat:
default:
return nil, errComponentType(acr.ComponentType)
Function ReadAccessor
has 8 return statements (exceeds 4 allowed). Open
Open
func ReadAccessor(doc *gltf.Document, acr *gltf.Accessor, buffer any) (any, error) {
if acr.BufferView == nil && acr.Sparse == nil {
return nil, nil
}
buffer = binary.MakeSliceBuffer(acr.ComponentType, acr.Type, acr.Count, buffer)
Method Encoder.encodeBuffer
has 5 return statements (exceeds 4 allowed). Open
Open
func (e *Encoder) encodeBuffer(buffer *Buffer) error {
if err := validateBufferURI(buffer.URI); err != nil {
return err
}
if e.Fsys == nil {
Function MakeSliceBuffer
has 5 return statements (exceeds 4 allowed). Open
Open
func MakeSliceBuffer(c gltf.ComponentType, t gltf.AccessorType, count uint32, buffer any) any {
if buffer == nil {
return MakeSlice(c, t, count)
}
c1, t1, count1 := Type(buffer)