def flag_all_marks
      raise IOError, "There's a invalid or missing file" if @file.nil?

      @original_file.dup.tap do |file|
        begin
          Timeout.timeout(@config.scan_timeout) do
            detect_groups unless @groups_detected
          end
        rescue Timeout::Error
          raise_watcher :timed_out_watcher
          return file
        end

        @groups.each_pair do |_label, group|
          dr = Magick::Draw.new
          dr.stroke_width = 5
          dr.stroke(COLORS[3])
          dr.line(*group.expected_coordinates.values_at(:x1, :y1, :x2, :y1))
          dr.line(*group.expected_coordinates.values_at(:x2, :y1, :x2, :y2))
          dr.line(*group.expected_coordinates.values_at(:x2, :y2, :x1, :y2))
          dr.line(*group.expected_coordinates.values_at(:x1, :y2, :x1, :y1))
          dr.draw(file)

          next unless group.coordinates

          dr = Magick::Draw.new
          dr.stroke_width = 5
          dr.stroke(COLORS[5])
          dr.line(*group.coordinates.values_at(:x1, :y1, :x2, :y1))
          dr.line(*group.coordinates.values_at(:x2, :y1, :x2, :y2))
          dr.line(*group.coordinates.values_at(:x2, :y2, :x1, :y2))
          dr.line(*group.coordinates.values_at(:x1, :y2, :x1, :y1))
          dr.draw(file)
        end
      end
    end
def flag_all_marks
      raise IOError, "There's a invalid or missing file" if @file.nil?

      @original_file.dup.tap do |file|
        begin
          Timeout.timeout(@config.scan_timeout) do
            detect_groups unless @groups_detected
          end
        rescue Timeout::Error
          raise_watcher :timed_out_watcher
          return file
        end

        @groups.each_pair do |_label, group|
          dr = Magick::Draw.new
          dr.stroke_width = 5
          dr.stroke(COLORS[3])
          dr.line(*group.expected_coordinates.values_at(:x1, :y1, :x2, :y1))
          dr.line(*group.expected_coordinates.values_at(:x2, :y1, :x2, :y2))
          dr.line(*group.expected_coordinates.values_at(:x2, :y2, :x1, :y2))
          dr.line(*group.expected_coordinates.values_at(:x1, :y2, :x1, :y1))
          dr.draw(file)

          next unless group.coordinates

          dr = Magick::Draw.new
          dr.stroke_width = 5
          dr.stroke(COLORS[5])
          dr.line(*group.coordinates.values_at(:x1, :y1, :x2, :y1))
          dr.line(*group.coordinates.values_at(:x2, :y1, :x2, :y2))
          dr.line(*group.coordinates.values_at(:x2, :y2, :x1, :y2))
          dr.line(*group.coordinates.values_at(:x1, :y2, :x1, :y1))
          dr.draw(file)
        end
      end
    end
rubocop:disable Metrics/MethodLength