Sha256: 06a91872ad86df481d8cb5e3ad01d03966e1556462d9810c3dcfc63d80d17058
Contents?: true
Size: 805 Bytes
Versions: 11
Compression:
Stored size: 805 Bytes
Contents
require_relative '../cli/silencer' Reek::CLI::Silencer.silently do require 'unparser' end module Reek module AST # # Formats snippets of syntax tree back into Ruby source code. # class SexpFormatter # Formats the given sexp. # # @param [AST::Node, #to_s] sexp - The expression to format # # @return [String] a formatted string representation. # # :reek:DuplicateMethodCall { max_calls: 2 } is ok for lines.first def self.format(sexp) return sexp.to_s unless sexp.is_a? ::Parser::AST::Node lines = Unparser.unparse(sexp).split "\n" case lines.length when 1 then lines.first when 2 then lines.join('; ') else [lines.first, lines.last].join(' ... ') end end end end end
Version data entries
11 entries across 11 versions & 1 rubygems