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

gitlab.com/gitlab-org/gitlab-docs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Read <eread@gitlab.com>2022-05-19 06:40:15 +0300
committerEvan Read <eread@gitlab.com>2022-05-19 06:40:15 +0300
commit4adda6d5020d9299c06c8f360c14da7db390ab72 (patch)
treefd18d1d9f6dbf0e40e52f0f8d1a02e84145c24c7
parent2e1563b0cf3d1302c704d34a14db35080a33541a (diff)
Fix Style/IfUnlessModifier Rubocop offenseseread/fix-if_unless-modifier-rubocop-offenses
-rw-r--r--Rakefile17
-rw-r--r--lib/filters/gitlab_kramdown.rb4
-rw-r--r--lib/filters/introduced_in.rb10
-rw-r--r--lib/helpers/child_parent_better.rb8
-rw-r--r--lib/helpers/reading_time.rb4
5 files changed, 25 insertions, 18 deletions
diff --git a/Rakefile b/Rakefile
index cdb5820a..76a7a35d 100644
--- a/Rakefile
+++ b/Rakefile
@@ -24,7 +24,9 @@ task :clone_repositories do
# check if the pipeline was triggered via the API (multi-project pipeline)
# to exclude the case where we create a branch right off the gitlab-docs
# project.
- next if ENV["CI_COMMIT_REF_NAME"] != ENV['CI_DEFAULT_BRANCH'] && branch == ENV['CI_DEFAULT_BRANCH'] && ENV["CI_PIPELINE_SOURCE"] == 'pipeline'
+ next if ENV["CI_COMMIT_REF_NAME"] != ENV['CI_DEFAULT_BRANCH'] \
+ && branch == ENV['CI_DEFAULT_BRANCH'] \
+ && ENV["CI_PIPELINE_SOURCE"] == 'pipeline'
puts "\n=> Cloning #{product['repo']} into #{product['project_dir']}\n"
@@ -76,7 +78,8 @@ namespace :release do
raise 'You need to specify a version, like 10.1' unless version.match?(/\A\d+\.\d+\z/)
# Check if local branch exists
- abort("Rake aborted! The branch already exists. Delete it with `git branch -D #{version}` and rerun the task.") if local_branch_exist?(version)
+ abort("Rake aborted! The branch already exists. Delete it with `git branch -D #{version}` and rerun the task.") \
+ if local_branch_exist?(version)
# Stash modified and untracked files so we have "clean" environment
# without accidentally deleting data
@@ -224,7 +227,9 @@ task :symlink_readmes do
# check if the pipeline was triggered via the API (multi-project pipeline)
# to exclude the case where we create a branch right off the gitlab-docs
# project.
- next if ENV["CI_COMMIT_REF_NAME"] != ENV['CI_DEFAULT_BRANCH'] && branch == ENV['CI_DEFAULT_BRANCH'] && ENV["CI_PIPELINE_SOURCE"] == 'pipeline'
+ next if ENV["CI_COMMIT_REF_NAME"] != ENV['CI_DEFAULT_BRANCH'] \
+ && branch == ENV['CI_DEFAULT_BRANCH'] \
+ && ENV["CI_PIPELINE_SOURCE"] == 'pipeline'
next if readmes.key?(product['slug']) == false
@@ -398,7 +403,8 @@ namespace :docs do
puts "=> (#{slug}): Committing and pushing to create a merge request"
system("git add .")
system("git commit --quiet -m 'Update docs redirects #{today}'")
- `git push --set-upstream origin #{redirects_branch} -o merge_request.create -o merge_request.remove_source_branch -o merge_request.title="#{mr_title}" -o merge_request.description="#{mr_description}" -o merge_request.label="Technical Writing" -o merge_request.label="documentation" -o merge_request.label="docs::improvement"` if ENV['SKIP_MR'].nil?
+ `git push --set-upstream origin #{redirects_branch} -o merge_request.create -o merge_request.remove_source_branch -o merge_request.title="#{mr_title}" -o merge_request.description="#{mr_description}" -o merge_request.label="Technical Writing" -o merge_request.label="documentation" -o merge_request.label="docs::improvement"` \
+ if ENV['SKIP_MR'].nil?
Dir.chdir(source_dir)
puts
end
@@ -415,6 +421,7 @@ namespace :docs do
puts "=> (gitlab-docs): Committing and pushing to create a merge request"
system("git add #{redirects_yaml}")
system("git commit --quiet -m 'Update docs redirects #{today}'")
- `git push --set-upstream origin #{redirects_branch} -o merge_request.create -o merge_request.remove_source_branch -o merge_request.title="#{mr_title}" -o merge_request.description="#{mr_description}" -o merge_request.label="Technical Writing" -o merge_request.label="redirects" -o merge_request.label="Category:Docs Site"` if ENV['SKIP_MR'].nil?
+ `git push --set-upstream origin #{redirects_branch} -o merge_request.create -o merge_request.remove_source_branch -o merge_request.title="#{mr_title}" -o merge_request.description="#{mr_description}" -o merge_request.label="Technical Writing" -o merge_request.label="redirects" -o merge_request.label="Category:Docs Site"` \
+ if ENV['SKIP_MR'].nil?
end
end
diff --git a/lib/filters/gitlab_kramdown.rb b/lib/filters/gitlab_kramdown.rb
index a849f70e..281adfcf 100644
--- a/lib/filters/gitlab_kramdown.rb
+++ b/lib/filters/gitlab_kramdown.rb
@@ -76,9 +76,7 @@ module Nanoc::Filters
elements.each do |e|
results.push(e) if type == e.type
- unless e.children.empty?
- results.concat(find_type_elements(type, e.children))
- end
+ e.children.empty? unless results.concat(find_type_elements(type, e.children))
end
results
diff --git a/lib/filters/introduced_in.rb b/lib/filters/introduced_in.rb
index 57fca380..3aec9b1e 100644
--- a/lib/filters/introduced_in.rb
+++ b/lib/filters/introduced_in.rb
@@ -21,7 +21,15 @@ class IntroducedInFilter < Nanoc::Filter
# - "changed <optional text> in"
# - "enabled <optional text> in"
# ...followed by "GitLab"
- next if content !~ /(<a href="[^"]+">)?(introduced|enabled|(re)?moved|changed|deprecated|renamed|recommended)(<\/a>)?(.*)? (in|to).*GitLab/mi
+ next if content !~ /(<a href="[^"]+">)?(
+ introduced|
+ enabled|
+ (re)?moved|
+ changed|
+ deprecated|
+ renamed|
+ recommended
+ )(<\/a>)?(.*)? (in|to).*GitLab/xmi
new_content = generate(content)
blockquote.replace(new_content)
diff --git a/lib/helpers/child_parent_better.rb b/lib/helpers/child_parent_better.rb
index ec34e65d..c8427e40 100644
--- a/lib/helpers/child_parent_better.rb
+++ b/lib/helpers/child_parent_better.rb
@@ -4,9 +4,7 @@ module Nanoc::Helpers
module ChildParentBetter
# Returns an array of ancestor pages for the given page.
def ancestor_path_array(item)
- if @config[:debug]
- puts item
- end
+ puts item if @config[:debug]
parent_array = []
current_item = item
@@ -27,9 +25,7 @@ module Nanoc::Helpers
# A recursive function which returns the nearest parent item for the
# given path.
def get_nearest_parent(item_identifier)
- if @config[:debug]
- puts item_identifier
- end
+ puts item_identifier if @config[:debug]
if (item_identifier.nil? || (item_identifier.to_s.end_with?('README.md', 'index.md') && item_identifier.to_s.split('/').length == 3))
return
diff --git a/lib/helpers/reading_time.rb b/lib/helpers/reading_time.rb
index c336dec7..424b4dac 100644
--- a/lib/helpers/reading_time.rb
+++ b/lib/helpers/reading_time.rb
@@ -24,9 +24,7 @@ module Nanoc::Helpers
minutes = (words / WPM).ceil
seconds = (words % WPM / (WPM / 60)).floor
- if seconds.positive?
- minutes += 1
- end
+ minutes += 1 if seconds.positive?
(minutes <= 1 ? 'about a minute' : "~#{minutes} minutes")
end