rubocop:disable Metrics/LineLength
547094
def secure
    insecure_settings = to_settings.insecure.to_flattened_name_hash
    secure_settings   = to_settings.insecure.secure.to_flattened_name_hash
    file_contents     = read

    insecure_settings.each_pair do |name_pieces, value|
      secure_value  = secure_settings[name_pieces]

      escaped_name  = Regexp.escape(name_pieces.last)
      escaped_value = Regexp.escape(value)

      file_contents.
        sub!(
          /^(\s*)#{secure_prefix_pattern}#{escaped_name}(\s*):(\s*)['"]?#{escaped_value}['"]?$/,
          "\\1#{secure_prefix}#{name_pieces.last}\\2:\\3#{secure_value}",
      )

      file_contents.
        sub!(
          /^(\s*)#{secure_prefix_pattern}#{escaped_name}(\s*):(\s*)\|((?:\n\1\s{2}.*)+)/,
          "\\1#{secure_prefix}#{name_pieces.last}\\2:\\3#{secure_value}",
      )
    end

    write(file_contents)
  end
1336028
def syntax_error!(message)
      raise SyntaxError.new(message, options[:file], @orig_line, @lineno,
                            @orig_line && @line ? @orig_line.size - @line.size : 0)
    rescue SyntaxError => ex
      # HACK: Manipulate stacktrace for Rails and other frameworks
      # to find the right file.
      ex.backtrace.unshift "#{options[:file]}:#{@lineno}"
      raise
    end
1123323
private function _checkLargeLine() {
		$checkHTMLLines = $this->_config->getTestProperty('lineLength', 'checkHTMLLines');

		// If the current token is HTML we don't check the line size
		if ($checkHTMLLines === "true" || !$this->tokenizer->checkNextValidToken(T_INLINE_HTML)) {
			$maxLength = $this->_config->getTestProperty('lineLength', 'maxLineLength');
			$lineString = ""; // String assembled from tokens
			$currentTokenIndex = $this->tokenizer->getCurrentPosition();
			$currentToken = $this->tokenizer->getCurrentToken($currentTokenIndex);

			do {
				$currentTokenString = $currentToken->text;
				$lineString .= $currentTokenString;

				$currentTokenIndex += 1;
				$currentToken = $this->tokenizer->peekTokenAt($currentTokenIndex);

				$isNull = ($currentToken === null);
				$isNewLine = !$isNull && $this->tokenizer->checkToken($currentToken, T_NEW_LINE);
			} while (!($isNull || $isNewLine));

			$lineLength = strlen($lineString);

			// Reporting the error if the line length exceeds the defined maximum.
			if ($lineLength > $maxLength) {
				// Does not report if the line is a multiline comment - i.e. has /* in it)
				if (strpos($lineString, "/*")) {
					return;
				}
				$msg = $this->_getMessage('LONG_LINE', $lineLength, $maxLength);
				$this->_writeError('lineLength', $msg);
			}
		}
	}
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
957907
def ReadLines(self, file_object):
    
    lines_size = len(self.lines)
    if lines_size < self._buffer_size:
      lines_size = self._buffer_size - lines_size
      while lines_size > 0:
        line = self._ReadLine(file_object)
        if not line:
          break

        self.lines = ''.join([self.lines, line])
        lines_size -= len(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
207646
def ruby_lines(text):
    
    if isinstance(text, basestring):
        text = text.splitlines()
    elif not isinstance(text, list):
        raise TypeError("text should be a list or a string, not %s"
                        % type(text))
    return [l.strip() for l in text if l.strip() and not
            l.strip().startswith('#')]
496686
def shorten_line(tokens, source, indentation, indent_word, max_line_length,
                 aggressive=False, experimental=False, previous_line=''):
    
    for candidate in _shorten_line(tokens=tokens,
                                   source=source,
                                   indentation=indentation,
                                   indent_word=indent_word,
                                   aggressive=aggressive,
                                   previous_line=previous_line):
        yield candidate

    if aggressive:
        for key_token_strings in SHORTEN_OPERATOR_GROUPS:
            shortened = _shorten_line_at_tokens(
                tokens=tokens,
                source=source,
                indentation=indentation,
                indent_word=indent_word,
                key_token_strings=key_token_strings,
                aggressive=aggressive)

            if shortened is not None and shortened != source:
                yield shortened

    if experimental:
        for shortened in _shorten_line_at_tokens_new(
                tokens=tokens,
                source=source,
                indentation=indentation,
                max_line_length=max_line_length):

            yield shortened
243828
def recv_line(self, max_size=None, timeout='default', ending=None):
        
        if ending is None:
            ending = self.LINE_ENDING
        return self.recv_until(ending, max_size, timeout)
1297291
def syntax_error(message)
      column = @orig_line && @line ? @orig_line.size - @line.size : 0
      raise SyntaxError.new(message, file_path, @orig_line, @lineno, column)
    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
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
1359324
def fix_long_line_physically(self, result):
        """"""
        line_index = result['line'] - 1
        target = self.source[line_index]

        previous_line = get_item(self.source, line_index - 1, default='')
        next_line = get_item(self.source, line_index + 1, default='')

        try:
            fixed = self.fix_long_line(
                target=target,
                previous_line=previous_line,
                next_line=next_line,
                original=target)
        except (SyntaxError, tokenize.TokenError):
            return []

        if fixed:
            self.source[line_index] = fixed
            return [line_index + 1]
        else:
            return []
1326206
def text
      content = source_code
      indent = content[/^ */]

      content.gsub(/^#{indent}/, '')
             .gsub(/^-#/, '')
             .gsub(/^  /, '')
             .rstrip
    end
45508
def error(msg, line = nil)
      error = ::Opal::SyntaxError.new(msg)
      error.location = Opal::OpalBacktraceLocation.new(file, line)
      raise error
    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;
}
585575
def line_to_tuple line
      line = line.chomp.split('=', 2)

      if line.size == 2 and not line.include? "#"
        attr = get_hash_attr_from_rc line[0]
        return [ attr.to_sym, line[1] ]
      else
        return nil
      end
    end