Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/git/git-scm.com.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2022-10-05 15:56:56 +0300
committerJeff King <peff@peff.net>2022-10-05 16:28:15 +0300
commit360faca8d7d67a3fa60bb7e02f21df5d98730ff0 (patch)
treeda958ead1476dac02ba54b498f092cd5501561cb
parent1c15dc2f88dc7620f3c79ab52e1bd413e0e7be84 (diff)
index: break up huge cmd_list construction
Rubocop complains about the chained blocks, which requires an extra variable. We can also break it up across multiple lines to make it a bit easier to read.
-rw-r--r--lib/tasks/index.rake12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/tasks/index.rake b/lib/tasks/index.rake
index 46765eda..3272ce68 100644
--- a/lib/tasks/index.rake
+++ b/lib/tasks/index.rake
@@ -208,9 +208,15 @@ def index_doc(filter_tags, doc_list, get_content)
generated = {}
cmd = tag_files.detect { |f| f.first =~ /command-list\.txt/ }
if cmd
- cmd_list = get_content.call(cmd.second).match(/(### command list.*|# command name.*)/m)[0].split("\n").reject do |l|
- l =~ /^#/
- end.each_with_object({}) do |cmd, list|
+ raw_list =
+ get_content
+ .call(cmd.second)
+ .match(/(### command list.*|# command name.*)/m)[0]
+ .split("\n")
+ .reject do |l|
+ l =~ /^#/
+ end
+ cmd_list = raw_list.each_with_object({}) do |cmd, list|
name, kind, attr = cmd.split(/\s+/)
list[kind] ||= []
list[kind] << [name, attr]