manyfold3d/mittsu-gltf

View on GitHub

Showing 3 of 3 total issues

Method add_mesh has 58 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def add_mesh(mesh, mode:)
      # Pack faces into an array
      pack_string = (mesh.geometry.faces.count > (2**16)) ? "L<*" : "S<*"
      faces = mesh.geometry.faces.map { |x| [x.a, x.b, x.c] }
      data = faces.flatten.pack(pack_string)
Severity: Major
Found in lib/mittsu/gltf/exporter.rb - About 2 hrs to fix

    Method export has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def export(object, filename, mode: :ascii)
          initialize
          object.traverse do |obj|
            @node_indexes << add_mesh(obj, mode: mode) if obj.is_a? Mittsu::Mesh
          end
    Severity: Minor
    Found in lib/mittsu/gltf/exporter.rb - About 1 hr to fix

      Method add_mesh has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def add_mesh(mesh, mode:)
            # Pack faces into an array
            pack_string = (mesh.geometry.faces.count > (2**16)) ? "L<*" : "S<*"
            faces = mesh.geometry.faces.map { |x| [x.a, x.b, x.c] }
            data = faces.flatten.pack(pack_string)
      Severity: Minor
      Found in lib/mittsu/gltf/exporter.rb - About 35 mins 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