KazW/RintCore

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

Summary

Maintainability
B
5 hrs
Test Coverage

Class Line has 25 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Line
      include RintCore::GCode::Codes

      # @!macro attr_accessor
      #   @!attribute [rw] $1
Severity: Minor
Found in lib/rint_core/g_code/line.rb - About 2 hrs to fix

    Method to_s has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

          def to_s(line_number = nil)
            return checksummed_line if line_number.nil? || !line_number.is_a?(Fixnum)
            return prefixed_line(line_number) if @extrusion_multiplier.nil? && @speed_multiplier.nil?
    
            new_f = multiplied_speed
    Severity: Minor
    Found in lib/rint_core/g_code/line.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

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

          def initialize(line)
            (line.nil? || line.empty?) ? @raw = '' : @raw = line
            @matches = @raw.match(GCODE_PATTERN)
            @f = @matches[:f_data].to_f unless @matches[:f_data].nil?
            @tool_number = command_number if !command_letter.nil? && command_letter == 'T'
    Severity: Minor
    Found in lib/rint_core/g_code/line.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

    There are no issues that match your filters.

    Category
    Status