rubocop:disable Metrics/LineLength
512197
def init_handler(flow, phase, handler, version)
      Distribot.publish!(
        "distribot.flow.handler.#{handler}.#{version}.enumerate",
        flow_id: flow.id,
        phase: phase.name,
        task_queue: "distribot.flow.handler.#{handler}.#{version}.tasks",
        task_counter: "distribot.flow.#{flow.id}.#{phase.name}.#{handler}.finished",
        finished_queue: 'distribot.flow.task.finished'
      )
    end
1292638
def readline(options = {})
      suppress_warnings
      initialize_parms(options)
      MiniTerm.raw { @edit.edit_process }
    ensure
      restore_warnings
      puts
    end
315175
def parse_line
      s0 = @current_pos
      s1 = match_regexp(/^[▲△]/)
      if s1 != :failed
        s1 = if s1 == "▲"
               { "color" => 0 }
             else
               { "color" => 1 }
             end
        s2 = parse_fugou
        if s2 != :failed
          s3 = []
          s4 = parse_nl
          s4 = match_space if s4 == :failed
          while s4 != :failed
            s3 << s4
            s4 = parse_nl
            s4 = match_space if s4 == :failed
          end
          @reported_pos = s0
          s0 = s2.merge(s1)
        else
          @current_pos = s0
          s0 = :failed
        end
      else
        @current_pos = s0
        s0 = :failed
      end
      s0
    end
434092
def backspace!
      if @col > 0
        left, cursor, right = abbrev_segments
        @abbrev = left.chop! + cursor + right
        @col -= 1
        redraw
      end
    end
232162
def width
      string = to_s
      max_width = 0
      string.each_line do |line|
        max_width = [max_width, line.uncolored.chomp.size].max
      end
      max_width
    end
836953
def method_array
      @parser = nil
      @caller_lines.each do |kaller|
        code   = Ripper.sexp(kaller.contents)
        code  ||= Ripper.sexp(kaller.contents.sub(/^\W*(if|unless)/, ''.freeze)) # if and unless "block" statements aren't valid one line ruby code
        code  ||= Ripper.sexp(kaller.contents.sub(/do \|.*\|$/, ''.freeze)) # remove trailing do |thing| to make valid code
        code  ||= Ripper.sexp(kaller.contents.sub(/(and|or)\W*$/, ''.freeze))# trailing and || or
        code  ||= Ripper.sexp(kaller.contents.sub(/:\W*$/, ''.freeze)) # multi line ternary statements
        code  ||= Ripper.sexp(kaller.contents.sub(/(^\W*)|({ \|?.*\|?)}/, ''.freeze)) # multi line blocks using {}

        puts "LetItGoFailed parse (#{kaller.file_name}:#{kaller.line_number}: \n  \033[0;31m"+ kaller.contents.strip + "\e[0m".freeze if ENV['LET_IT_GO_RECORD_FAILED_CODE'] && code.nil? && kaller.contents.match(/"|'/)

        parser = ::LetItGo::WTFParser.new(code, contents: kaller.contents)

        if parser.each_method.any? { |m| m.method_name == method_name }
          @line_number = kaller.line_number
          @file_name   = kaller.file_name

          @parser = parser
          parser.each_method.each(&:arg_types)
          break
        else
          next
        end
      end
      @parser || []
    end
562312
def cleanup_config_line(line)
        #remove comments, even those that happen inline
        line.gsub!(/^((".*?"|[^#"])*)#.*/) {|m| m=$1}

        #fix whitespace
        line.gsub!('=', ' = ')
        line.gsub!(/\s+/, ' ')
        line.strip
      end
519933
def tokenize(lines)
      @errors = []
      @data = {}
      lines.each do |line|
        case line
        when /^ADCO (\S{12}) ./
          @data[:adco] = $1
        when /^OPTARIF (....) ./
          @data[:optarif] = $1.sub(/\.+$/, '')
        when /^ISOUSC (\d{2}) ./
          @data[:isousc] = $1.to_i
        when /^BASE (\d{9}) ./ # BASE TARIF
          @data[:base] = $1.to_i
        when /^HCHC (\d{9}) ./ # HPHC TARIF
          @data[:hchc] = $1.to_i # HPHC TARIF
        when /^HCHP (\d{9}) ./ # HPHC TARIF
          @data[:hchp] = $1.to_i
        when /^PAPP (\d{5}) ./
          @data[:papp] = $1.to_i
        when /^PTEC (\S{4}) ./
          @data[:ptec] = $1.sub(/\.+$/, '')
        when /^IINST (\d{3}) ./
          @data[:iinst] = $1.to_i
        when /^IMAX (\d{3}) ./
          @data[:imax] = $1.to_i
        when /^HHPHC (\S{1})/ # HPHC TARIF
          @data[:hhphc] = $1
        when /^BBRHCJB (\d{9}) ./ # TEMPO Jour Bleu
          @data[:bbrhcjb] = $1.to_i
        when /^BBRHPJB (\d{9}) ./
          @data[:bbrhpjb] = $1.to_i # TEMPO Jour Bleu
        when /^BBRHCJW (\d{9}) ./
          @data[:bbrhcjw] = $1.to_i # TEMPO Jour Blanc
        when /^BBRHPJW (\d{9}) ./
          @data[:bbrhpjw] = $1.to_i # TEMPO Jour Blanc
        when /^BBRHCJR (\d{9}) ./
          @data[:bbrhcjr] = $1.to_i # TEMPO Jour rouge
        when /^BBRHPJR (\d{9}) ./
          @data[:bbrhpjr] = $1.to_i # TEMPO Jour rouge
        when /^DEMAIN (\S{4}) ./ # TEMPO lendemain
          @data[:bbrhpjr] = $1
        when /^ADPS (\d{3})/ # Alerte dépassement de seuil
          @data[:adps] = $1.to_i
        when /MOTDETAT/
          # always 00000…
        else
          @errors << "Can't parse: #{line}"
        end
      end
      @data.freeze
      @errors.freeze
    end
220922
def trim_and_retry(buf)
      *lines, last = buf

      # For inner Array or Hash or Arguments list.
      lines << last.gsub(/,\s*$/, "")
      do_parse("a(#{lines.join})") # wrap dummy method
    rescue ::Parser::SyntaxError
    end
669462
def lines_to_display(full_trace)
      ActiveRecordQueryTrace.lines.zero? ? full_trace : full_trace.first(ActiveRecordQueryTrace.lines)
    end
130859
def _reflow_lines(parsed_tokens, indentation, max_line_length,
                  start_on_prefix_line):
    """"""

    if unicode(parsed_tokens[0]) == 'def':
        # A function definition gets indented a bit more.
        continued_indent = indentation + ' ' * 2 * DEFAULT_INDENT_SIZE
    else:
        continued_indent = indentation + ' ' * DEFAULT_INDENT_SIZE

    break_after_open_bracket = not start_on_prefix_line

    lines = ReformattedLines(max_line_length)
    lines.add_indent(len(indentation.lstrip('\r\n')))

    if not start_on_prefix_line:
        # If splitting after the opening bracket will cause the first element
        # to be aligned weirdly, don't try it.
        first_token = get_item(parsed_tokens, 0)
        second_token = get_item(parsed_tokens, 1)

        if (
            first_token and second_token and
            unicode(second_token)[0] == '(' and
            len(indentation) + len(first_token) + 1 == len(continued_indent)
        ):
            return None

    for item in parsed_tokens:
        lines.add_space_if_needed(unicode(item), equal=True)

        save_continued_indent = continued_indent
        if start_on_prefix_line and isinstance(item, Container):
            start_on_prefix_line = False
            continued_indent = ' ' * (lines.current_size() + 1)

        item.reflow(lines, continued_indent, break_after_open_bracket)
        continued_indent = save_continued_indent

    return lines.emit()
264080
def yamline_delete!(lines = nil)
      lines = file_lines unless lines
      return unless lines
      lines_readed = yamline_read(lines, false)
      lines_readed.each {|lr| lines.delete(lr) } if lines_readed
      save_file(lines)
    end
288127
def parse(path, contents = nil)
      print_known_info if verbose

      contents ||= File.open(path, "r:utf-8", &:read)

      # Work around for Rubinius incomplete encoding in 1.9 mode
      if contents.respond_to?(:encoding) && contents.encoding.name != "UTF-8"
        contents.encode!("UTF-8")
      end

      if contents.tr!("“”‘’‛", %(""'''))
        # Changes have been made
        ui.puts "Your #{path.basename} has had smart quotes sanitised. " \
          "To avoid issues in the future, you should not use " \
          "TextEdit for editing it. If you are not using TextEdit, " \
          "you should turn off smart quotes in your editor of choice.".red
      end

      if contents.include?("puts")
        ui.puts "You used `puts` in your Dangerfile. To print out text to GitHub use `message` instead"
      end

      self.defined_in_file = path
      instance_eval do
        # rubocop:disable Lint/RescueException
        begin
          eval_file(contents, path)
        rescue Exception => e
          message = "Invalid `#{path.basename}` file: #{e.message}"
          raise DSLError.new(message, path, e.backtrace, contents)
        end
        # rubocop:enable Lint/RescueException
      end
    end
1145061
def strip_units_from_lines(lines):
    
    for line in lines:
        for unit in ALL_UNITS:
            if line.endswith(" %s" % unit):
                line = line[:-1-len(unit)]
        yield line
802212
def check_commit_message_length(message)
      check_label = 'Commit message length'

      if message.length >= @min_length && message.length <= @max_length
        Status.report(check_label, true)
      else
        @errors.push "Commit messages should be between #{@min_length} "\
          "and #{@max_length} characters."
        Status.report(check_label, false)
      end
    end
153392
def fix_leader!(leader)

      if leader.length < 24
        # pad it to 24 bytes, leader is supposed to be 24 bytes
        leader.replace(  leader.ljust(24, ' ')  )
      elsif leader.length > 24
        # Also a problem, slice it
        leader.replace( leader.byteslice(0, 24))
      end
      # http://www.loc.gov/marc/bibliographic/ecbdldrd.html
      leader[10..11] = '22'
      leader[20..23] = '4500'

      if settings['horizon.destination_encoding'] == "UTF8"
        leader[9] = 'a'
      end

      # leader should only have ascii chars in it; invalid non-ascii
      # chars can cause ruby encoding problems down the line.
      # additionally, a force_encoding may be neccesary to
      # deal with apparent weird hard to isolate jruby bug prob same one
      # as at https://github.com/jruby/jruby/issues/886
      leader.force_encoding('ascii')

      unless leader.valid_encoding?
        # replace any non-ascii chars with a space.

        # Can't access leader.chars when it's not a valid encoding
        # without a weird index out of bounds exception, think it's
        # https://github.com/jruby/jruby/issues/886
        # Grr.

        #leader.replace( leader.chars.collect { |c| c.valid_encoding? ? c : ' ' }.join('') )
        leader.replace(leader.split('').collect { |c| c.valid_encoding? ? c : ' ' }.join(''))
      end



    end
476
function breakLines(tokens, maxWidth) {
    if (!maxWidth) {
        maxWidth = Infinity;
    }
    let i = 0;
    let lineLength = 0;
    let lastTokenWithSpace = -1;
    while (i < tokens.length) { /* take all text tokens, remove space, apply linebreaks */
        let token = tokens[i];
        if (token.type == TYPE_NEWLINE) { /* reset */
            lineLength = 0;
            lastTokenWithSpace = -1;
        }
        if (token.type != TYPE_TEXT) { /* skip non-text tokens */
            i++;
            continue;
        }
        /* remove spaces at the beginning of line */
        while (lineLength == 0 && token.value.charAt(0) == " ") {
            token.value = token.value.substring(1);
        }
        /* forced newline? insert two new tokens after this one */
        let index = token.value.indexOf("\n");
        if (index != -1) {
            token.value = breakInsideToken(tokens, i, index, true);
            /* if there are spaces at the end, we must remove them (we do not want the line too long) */
            let arr = token.value.split("");
            while (arr.length && arr[arr.length - 1] == " ") {
                arr.pop();
            }
            token.value = arr.join("");
        }
        /* token degenerated? */
        if (!token.value.length) {
            tokens.splice(i, 1);
            continue;
        }
        if (lineLength + token.value.length > maxWidth) { /* line too long, find a suitable breaking spot */
            /* is it possible to break within this token? */
            let index = -1;
            while (1) {
                let nextIndex = token.value.indexOf(" ", index + 1);
                if (nextIndex == -1) {
                    break;
                }
                if (lineLength + nextIndex > maxWidth) {
                    break;
                }
                index = nextIndex;
            }
            if (index != -1) { /* break at space within this one */
                token.value = breakInsideToken(tokens, i, index, true);
            }
            else if (lastTokenWithSpace != -1) { /* is there a previous token where a break can occur? */
                let token = tokens[lastTokenWithSpace];
                let breakIndex = token.value.lastIndexOf(" ");
                token.value = breakInsideToken(tokens, lastTokenWithSpace, breakIndex, true);
                i = lastTokenWithSpace;
            }
            else { /* force break in this token */
                token.value = breakInsideToken(tokens, i, maxWidth - lineLength, false);
            }
        }
        else { /* line not long, continue */
            lineLength += token.value.length;
            if (token.value.indexOf(" ") != -1) {
                lastTokenWithSpace = i;
            }
        }
        i++; /* advance to next token */
    }
    tokens.push({ type: TYPE_NEWLINE }); /* insert fake newline to fix the last text line */
    /* remove trailing space from text tokens before newlines */
    let lastTextToken = null;
    for (let i = 0; i < tokens.length; i++) {
        let token = tokens[i];
        switch (token.type) {
            case TYPE_TEXT:
                lastTextToken = token;
                break;
            case TYPE_NEWLINE:
                if (lastTextToken) { /* remove trailing space */
                    let arr = lastTextToken.value.split("");
                    while (arr.length && arr[arr.length - 1] == " ") {
                        arr.pop();
                    }
                    lastTextToken.value = arr.join("");
                }
                lastTextToken = null;
                break;
        }
    }
    tokens.pop(); /* remove fake token */
    return tokens;
}