qmuntal/gltf

View on GitHub

Showing 9 of 49 total issues

Function Type has 94 lines of code (exceeds 50 allowed). Consider refactoring.
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()))
    }
Severity: Major
Found in binary/slice.go - About 2 hrs to fix

    Function ReadColor has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring.
    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)
    Severity: Minor
    Found in modeler/read.go - About 1 hr 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 ReadColor64 has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring.
    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)
    Severity: Minor
    Found in modeler/read.go - About 1 hr 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 WriteAttributesInterleaved has 67 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func WriteAttributesInterleaved(doc *gltf.Document, v Attributes) (map[string]uint32, error) {
        type attrProps struct {
            Name       string
            Normalized bool
        }
    Severity: Minor
    Found in modeler/write.go - About 1 hr to fix

      Function ReadColor64 has 60 lines of code (exceeds 50 allowed). Consider refactoring.
      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)
      Severity: Minor
      Found in modeler/read.go - About 1 hr to fix

        Function ReadColor has 51 lines of code (exceeds 50 allowed). Consider refactoring.
        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)
        Severity: Minor
        Found in modeler/read.go - About 1 hr to fix

          Function ReadAccessor has 8 return statements (exceeds 4 allowed).
          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)
          Severity: Major
          Found in modeler/read.go - About 50 mins to fix

            Method Encoder.encodeBuffer has 5 return statements (exceeds 4 allowed).
            Open

            func (e *Encoder) encodeBuffer(buffer *Buffer) error {
                if err := validateBufferURI(buffer.URI); err != nil {
                    return err
                }
                if e.Fsys == nil {
            Severity: Major
            Found in encode.go - About 35 mins to fix

              Function MakeSliceBuffer has 5 return statements (exceeds 4 allowed).
              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)
              Severity: Major
              Found in binary/slice.go - About 35 mins to fix
                Severity
                Category
                Status
                Source
                Language