KazW/RintCore

View on GitHub
lib/rint_core/g_code/object.rb

Summary

Maintainability
D
2 days
Test Coverage

Method set_current_position has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

      def set_current_position(line)
        if @relative
          @current_x += to_mm(line.x) unless line.x.nil?
          @current_y += to_mm(line.y) unless line.y.nil?
          @current_z += to_mm(line.z) unless line.z.nil?
Severity: Minor
Found in lib/rint_core/g_code/object.rb - About 3 hrs 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

Method set_limits has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

      def set_limits(line)
        if line.extrusion_move?
          unless line.x.nil?
            @x_min = @current_x if @current_x < @x_min
            @x_max = @current_x if @current_x > @x_max
Severity: Minor
Found in lib/rint_core/g_code/object.rb - About 3 hrs 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

Class Object has 28 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Object
      include RintCore::GCode::Codes
      include RintCore::PrettyOutput

      # An array of the raw Gcode with each line as an element.
Severity: Minor
Found in lib/rint_core/g_code/object.rb - About 3 hrs to fix

    Method measure_travel has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

          def measure_travel(line)
            if @relative
              @x_travel += to_mm(line.x).abs unless line.x.nil?
              @y_travel += to_mm(line.y).abs unless line.y.nil?
              @z_travel += to_mm(line.z).abs unless line.z.nil?
    Severity: Minor
    Found in lib/rint_core/g_code/object.rb - About 2 hrs 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

    File object.rb has 266 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'rint_core/g_code/codes'
    require 'rint_core/g_code/line'
    require 'rint_core/pretty_output'
    
    module RintCore
    Severity: Minor
    Found in lib/rint_core/g_code/object.rb - About 2 hrs to fix

      Method initialize has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

            def initialize(data = nil, default_speed = 2400, auto_process = true, acceleration = 1500)
              return false if positive_number?(default_speed)
              return false if positive_number?(acceleration)
              if data.class == String && self.class.is_file?(data)
                data = self.class.get_file(data)
      Severity: Minor
      Found in lib/rint_core/g_code/object.rb - 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

      Method process has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def process
              set_processing_variables
      
              @lines.each do |line|
                case line.command
      Severity: Minor
      Found in lib/rint_core/g_code/object.rb - About 1 hr to fix

        Method set_processing_variables has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def set_processing_variables
                @x_travel = 0
                @y_travel = 0
                @z_travel = 0
                @current_x = 0
        Severity: Minor
        Found in lib/rint_core/g_code/object.rb - About 1 hr to fix

          Method set_positions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

                def set_positions(line)
                  @current_x = to_mm(line.x) unless line.x.nil?
                  @current_y = to_mm(line.y) unless line.y.nil?
                  @current_z = to_mm(line.z) unless line.z.nil?
                  unless line.e.nil?
          Severity: Minor
          Found in lib/rint_core/g_code/object.rb - 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

          Method set_line_properties has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                def set_line_properties(line)
                  return false unless line
                  return line if line.command.nil?
                  @tool_number = line.tool_number unless line.tool_number.nil?
                  line.tool_number = @tool_number if line.tool_number.nil?
          Severity: Minor
          Found in lib/rint_core/g_code/object.rb - About 55 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

          Method hypot3d has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                def hypot3d(x1, y1, z1, x2 = 0.0, y2 = 0.0, z2 = 0.0)
          Severity: Minor
          Found in lib/rint_core/g_code/object.rb - About 45 mins to fix

            Method process has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                  def process
                    set_processing_variables
            
                    @lines.each do |line|
                      case line.command
            Severity: Minor
            Found in lib/rint_core/g_code/object.rb - About 25 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

            There are no issues that match your filters.

            Category
            Status