From f4649081e90dac96625dc9393d63fcee3392da30 Mon Sep 17 00:00:00 2001 From: Athitya Kumar Date: Thu, 27 Oct 2022 14:23:16 +0530 Subject: [PATCH] lint(483): makes linter happy --- lib/colorls/core.rb | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/colorls/core.rb b/lib/colorls/core.rb index e963f8b..7b669ad 100644 --- a/lib/colorls/core.rb +++ b/lib/colorls/core.rb @@ -46,15 +46,16 @@ module ColorLS @time_style = long_style_options.key?(:time_style) ? long_style_options[:time_style] : '' @indicator_style = indicator_style @hard_links_count = long_style_options.key?(:hard_links_count) ? long_style_options[:hard_links_count] : true - # how much characters an item occupies besides its name - @additional_chars_per_item = 12 + (@show_git ? 4 : 0) + (@show_inode ? 10 : 0) @icons = icons init_colors colors - init_icons end + def get_additional_chars_per_item + 12 + (@show_git ? 4 : 0) + (@show_inode ? 10 : 0) + end + def ls_dir(info) if @tree[:mode] print "\n" @@ -156,7 +157,7 @@ module ColorLS end def item_widths - @contents.map { |item| Unicode::DisplayWidth.of(item.show) + @additional_chars_per_item } + @contents.map { |item| Unicode::DisplayWidth.of(item.show) + get_additional_chars_per_item } end def filter_hidden_contents @@ -342,10 +343,7 @@ module ColorLS logo = value.gsub(/\\u[\da-f]{4}/i) { |m| [m[-4..].to_i(16)].pack('U') } name = @hyperlink ? make_link(content) : content.show name += content.directory? && @indicator_style != 'none' ? '/' : ' ' - entry = "#{out_encode(name)}" - if @icons - entry = "#{out_encode(logo)} #{out_encode(name)}" - end + entry = @icons ? "#{out_encode(logo)} #{out_encode(name)}" : out_encode(name).to_s entry = entry.bright if !content.directory? && content.executable? "#{inode(content)} #{long_info(content)} #{git_info(content)} #{entry.colorize(color)}#{symlink_info(content)}" @@ -358,7 +356,7 @@ module ColorLS entry = fetch_string(content, *options(content)) line << (' ' * padding) line << ' ' << entry.encode(Encoding.default_external, undef: :replace) - padding = widths[i] - Unicode::DisplayWidth.of(content.show) - @additional_chars_per_item + padding = widths[i] - Unicode::DisplayWidth.of(content.show) - get_additional_chars_per_item end print line << "\n" end