Skip to content
代码片段 群组 项目
未验证 提交 cdc29799 编辑于 作者: Peter Leitzen's avatar Peter Leitzen
浏览文件

Danger: Rename constants to avoid Ruby warnings

This commit resolves the following warnings:
  gitlab/danger/saas_feature/Dangerfile:3:
    warning: already initialized constant Danger::Dangerfile::SEE_DOC
  gitlab/danger/feature_flag/Dangerfile:3:
    warning: previous definition of SEE_DOC was here

Ideally, the code should go into danger plugins to side-step any
namespace issues.
上级 832759a0
No related branches found
No related tags found
无相关合并请求
# frozen_string_literal: true
SEE_DOC = "See the [feature flag documentation](https://docs.gitlab.com/ee/development/feature_flags#feature-flag-definition-and-validation)."
FF_SEE_DOC = "See the [feature flag documentation](https://docs.gitlab.com/ee/development/feature_flags#feature-flag-definition-and-validation)."
FEATURE_FLAG_LABEL = "feature flag"
FEATURE_FLAG_EXISTS_LABEL = "#{FEATURE_FLAG_LABEL}::exists"
FEATURE_FLAG_SKIPPED_LABEL = "#{FEATURE_FLAG_LABEL}::skipped"
DEVOPS_LABELS_REQUIRING_FEATURE_FLAG_REVIEW = ["devops::verify"]
SUGGEST_MR_COMMENT = <<~SUGGEST_COMMENT
FF_SUGGEST_MR_COMMENT = <<~SUGGEST_COMMENT
```suggestion
group: "%<group>s"
```
#{SEE_DOC}
#{FF_SEE_DOC}
SUGGEST_COMMENT
FEATURE_FLAG_ENFORCEMENT_WARNING = <<~WARNING_MESSAGE
......@@ -35,21 +35,21 @@ def check_feature_flag_yaml(feature_flag)
end
rescue Psych::Exception
# YAML could not be parsed, fail the build.
fail "#{helper.html_link(feature_flag.path)} isn't valid YAML! #{SEE_DOC}"
fail "#{helper.html_link(feature_flag.path)} isn't valid YAML! #{FF_SEE_DOC}"
rescue StandardError => e
warn "There was a problem trying to check the Feature Flag file. Exception: #{e.class.name} - #{e.message}"
end
def message_for_feature_flag_missing_group!(feature_flag:, mr_group_label:)
if mr_group_label.nil?
warn "Consider setting `group` in #{helper.html_link(feature_flag.path)}. #{SEE_DOC}"
warn "Consider setting `group` in #{helper.html_link(feature_flag.path)}. #{FF_SEE_DOC}"
else
mr_line = feature_flag.raw.lines.find_index("group:\n")
if mr_line
markdown(format(SUGGEST_MR_COMMENT, group: mr_group_label), file: feature_flag.path, line: mr_line.succ)
markdown(format(FF_SUGGEST_MR_COMMENT, group: mr_group_label), file: feature_flag.path, line: mr_line.succ)
else
warn %(Consider setting `group: "#{mr_group_label}"` in #{helper.html_link(feature_flag.path)}. #{SEE_DOC})
warn %(Consider setting `group: "#{mr_group_label}"` in #{helper.html_link(feature_flag.path)}. #{FF_SEE_DOC})
end
end
end
......
# frozen_string_literal: true
SEE_DOC = "see the [SaaS feature documentation](https://docs.gitlab.com/ee/development/ee_features.html#saas-only-feature)."
SF_SEE_DOC = "see the [SaaS feature documentation](https://docs.gitlab.com/ee/development/ee_features.html#saas-only-feature)."
SUGGEST_MR_COMMENT = <<~SUGGEST_COMMENT.freeze
SF_SUGGEST_MR_COMMENT = <<~SUGGEST_COMMENT.freeze
```suggestion
group: "%<group>s"
```
#{SEE_DOC.capitalize}
#{SF_SEE_DOC.capitalize}
SUGGEST_COMMENT
def check_yaml(saas_feature)
......@@ -20,7 +20,7 @@ def check_yaml(saas_feature)
end
rescue Psych::Exception
# YAML could not be parsed, fail the build.
fail "#{helper.html_link(saas_feature.path)} isn't valid YAML! #{SEE_DOC.capitalize}"
fail "#{helper.html_link(saas_feature.path)} isn't valid YAML! #{SF_SEE_DOC.capitalize}"
rescue StandardError => e
warn "There was a problem trying to check the SaaS feature file. Exception: #{e.class.name} - #{e.message}"
end
......@@ -31,13 +31,13 @@ def message_for_missing_group!(saas_feature:, mr_group_label:)
end
if mr_line
markdown(format(SUGGEST_MR_COMMENT, group: mr_group_label), file: saas_feature.path, line: mr_line.succ)
markdown(format(SF_SUGGEST_MR_COMMENT, group: mr_group_label), file: saas_feature.path, line: mr_line.succ)
elsif mr_group_label
warn %(
Consider setting `group: "#{mr_group_label}"` in #{helper.html_link(saas_feature.path)}. #{SEE_DOC.capitalize}
Consider setting `group: "#{mr_group_label}"` in #{helper.html_link(saas_feature.path)}. #{SF_SEE_DOC.capitalize}
)
else
warn "Consider setting `group` in #{helper.html_link(saas_feature.path)}. #{SEE_DOC.capitalize}"
warn "Consider setting `group` in #{helper.html_link(saas_feature.path)}. #{SF_SEE_DOC.capitalize}"
end
end
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册