Skip to content
代码片段 群组 项目
未验证 提交 4d3414e0 编辑于 作者: Paul Gascou-Vaillancourt's avatar Paul Gascou-Vaillancourt 提交者: GitLab
浏览文件

Correct docs links offenses in `SecretsCheck`

Call `help_page_path` directly with string literal arguments, add `.md`
extension to the path.
上级 93b83628
No related branches found
No related tags found
无相关合并请求
显示
26 个添加47 个删除
---
# Cop supports --autocorrect.
Gitlab/DocumentationLinks/Link:
Exclude:
- 'ee/lib/ee/gitlab/namespace_storage_size_error_message.rb'
- 'ee/lib/gitlab/checks/secrets_check.rb'
- 'ee/spec/support/shared_contexts/secrets_check_shared_contexts.rb'
- 'lib/backup/tasks/database.rb'
- 'lib/system_check/helpers.rb'
......@@ -17,14 +17,14 @@ def commit_error
_(
"Your action has been rejected because the namespace storage limit has been reached. " \
"For more information, visit %{doc_url}.") % {
doc_url: help_page_url('user/storage_usage_quotas.md')
doc_url: ::Gitlab::Routing.url_helpers.help_page_url('user/storage_usage_quotas.md')
}
end
def merge_error
manage_storage_url = link_to(
'',
help_page_path('user/storage_usage_quotas.md'),
::Gitlab::Routing.url_helpers.help_page_path('user/storage_usage_quotas.md'),
target: '_blank',
rel: 'noopener noreferrer'
)
......@@ -88,8 +88,10 @@ def above_size_limit_message
def push_message_params
{
namespace_name: message_params[:namespace_name],
manage_storage_url: help_page_url('user/storage_usage_quotas.md', 'manage-storage-usage'),
restricted_actions_url: help_page_url('user/read_only_namespaces.md', 'restricted-actions'),
manage_storage_url: ::Gitlab::Routing.url_helpers.help_page_url('user/storage_usage_quotas.md',
anchor: 'manage-storage-usage'),
restricted_actions_url: ::Gitlab::Routing.url_helpers.help_page_url('user/read_only_namespaces.md',
anchor: 'restricted-actions'),
current_size: formatted(current_size),
size_limit: formatted(limit),
usage_percentage: usage_percentage
......@@ -107,14 +109,6 @@ def usage_percentage
def link_to(text, url, options)
ActionController::Base.helpers.link_to(text, url, options)
end
def help_page_path(path)
::Gitlab::Routing.url_helpers.help_page_path(path)
end
def help_page_url(path, anchor = nil)
::Gitlab::Routing.url_helpers.help_page_url(path, anchor: anchor)
end
end
end
end
......@@ -42,8 +42,6 @@ class SecretsCheck < ::Gitlab::Checks::BaseBulkChecker
PAYLOAD_BYTES_LIMIT = 1.megabyte # https://handbook.gitlab.com/handbook/engineering/architecture/design-documents/secret_detection/#target-types
SPECIAL_COMMIT_FLAG = /\[skip secret push protection\]/i
DOCUMENTATION_PATH = 'user/application_security/secret_detection/secret_push_protection/_index.html'
DOCUMENTATION_PATH_ANCHOR = 'resolve-a-blocked-push'
EXCLUSION_TYPE_MAP = {
rule: ::Gitlab::SecretDetection::GRPC::ExclusionType::EXCLUSION_TYPE_RULE,
path: ::Gitlab::SecretDetection::GRPC::ExclusionType::EXCLUSION_TYPE_PATH,
......@@ -581,8 +579,8 @@ def build_secrets_found_message(results, with_errors: false)
LOG_MESSAGES[:found_secrets_docs_link],
{
path: Rails.application.routes.url_helpers.help_page_url(
DOCUMENTATION_PATH,
anchor: DOCUMENTATION_PATH_ANCHOR
'user/application_security/secret_detection/secret_push_protection/_index.md',
anchor: 'resolve-a-blocked-push'
)
}
)
......
......@@ -51,7 +51,8 @@ def show_ntp_connection_error
end
def help_replication_check
construct_help_page_url('administration/geo/replication/troubleshooting.md', anchor: 'health-check-rake-task')
Rails.application.routes.url_helpers.help_page_url('administration/geo/replication/troubleshooting/_index.md',
anchor: 'health-check-rake-task')
end
private
......
......@@ -21,7 +21,7 @@ def show_error
'Follow Geo setup instructions to configure primary and secondary nodes for replication'
)
docs_link = construct_help_page_url('administration/geo/setup/database')
docs_link = Rails.application.routes.url_helpers.help_page_url('administration/geo/setup/database.md')
for_more_information(docs_link)
end
......
......@@ -19,7 +19,7 @@ def show_error
'Follow Geo setup instructions to configure primary and secondary nodes for replication'
)
help_page = construct_help_page_url('administration/geo/setup/database')
help_page = Rails.application.routes.url_helpers.help_page_url('administration/geo/setup/database.md')
for_more_information(help_page)
end
......
......@@ -56,11 +56,11 @@ def multi_check
end
def database_docs
construct_help_page_url('administration/geo/setup/database.md')
Rails.application.routes.url_helpers.help_page_url('administration/geo/setup/database.md')
end
def troubleshooting_docs
construct_help_page_url('administration/geo/replication/troubleshooting.md')
Rails.application.routes.url_helpers.help_page_url('administration/geo/replication/troubleshooting/_index.md')
end
private
......
......@@ -71,6 +71,15 @@
end
end
describe '#show_error' do
subject(:show_error) { database_replication_working_check.show_error }
it 'returns an error message' do
expect(show_error.count).to be 1
expect(show_error.first).to end_with "/help/administration/geo/setup/database.md"
end
end
describe '#skip_reason' do
context 'with geo_postgresql_replication_agnostic disabled' do
before do
......
......@@ -307,8 +307,8 @@
log_messages[:found_secrets_docs_link],
{
path: Rails.application.routes.url_helpers.help_page_url(
Gitlab::Checks::SecretsCheck::DOCUMENTATION_PATH,
anchor: Gitlab::Checks::SecretsCheck::DOCUMENTATION_PATH_ANCHOR
'user/application_security/secret_detection/secret_push_protection/_index.md',
anchor: 'resolve-a-blocked-push'
)
}
)
......
......@@ -18,7 +18,7 @@ def pre_restore_warning
Be sure to stop Puma, Sidekiq, and any other process that
connects to the database before proceeding. For Omnibus
installs, see the following link for more information:
#{help_page_url('administration/backup_restore/restore_gitlab.md', 'restore-for-linux-package-installations')}
#{::Gitlab::Routing.url_helpers.help_page_url('administration/backup_restore/restore_gitlab.md', anchor: 'restore-for-linux-package-installations')}
Before restoring the database, we will remove all existing
tables to avoid future upgrade problems. Be aware that if you have
......@@ -44,10 +44,6 @@ def post_restore_warning
def target
@target ||= ::Backup::Targets::Database.new(progress, options: options)
end
def help_page_url(path, anchor = nil)
::Gitlab::Routing.url_helpers.help_page_url(path, anchor: anchor)
end
end
end
end
......@@ -20,16 +20,6 @@ def for_more_information(*sources)
end
end
# Construct a help page based on the instance's external_url
#
# @param <String> path of the documentation page
# @param <String> anchor to the specific docs heading
#
# @return <String> URL of the help page
def construct_help_page_url(path, anchor = nil)
Rails.application.routes.url_helpers.help_page_url(path, anchor)
end
def see_installation_guide_section(section)
"doc/install/installation.md in section \"#{section}\""
end
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册