Class: Gitlab::Dangerfiles::Config
- Inherits:
-
Object
- Object
- Gitlab::Dangerfiles::Config
- Defined in:
- lib/gitlab/dangerfiles/config.rb
Constant Summary collapse
- DEFAULT_CHANGES_SIZE_THRESHOLDS =
{ high: 2_000, medium: 500 }.freeze
- DEFAULT_COMMIT_MESSAGES_MAX_COMMITS_COUNT =
10
Instance Attribute Summary collapse
-
#ci_only_rules ⇒ Array<String>
Rules that cannot be run locally.
-
#code_size_thresholds ⇒ { high: Integer, medium: Integer }
A hash of the form { high: 42, medium: 12 } where
:high
is the lines changed threshold which triggers an error, and:medium
is the lines changed threshold which triggers a warning. -
#disabled_roulette_categories ⇒ Array
Indicating which categories would be disabled for the simple roulette.
-
#excluded_required_codeowners_sections_for_roulette ⇒ Array
Indicating which required codeowners sections should be excluded from roulette.
-
#files_to_category ⇒ {Regexp => Array<Symbol>}, {Array<Regexp> => Array<Symbol>}
A hash of the form { filename_regex => categories, [filename_regex, changes_regex] => categories }.
-
#included_optional_codeowners_sections_for_roulette ⇒ Array
Indicating which optional codeowners sections should be included in roulette.
-
#max_commits_count ⇒ Integer
The maximum number of allowed non-squashed/non-fixup commits for a given MR.
-
#project_name ⇒ String
The project name.
-
#project_root ⇒ String
The project root folder path.
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/gitlab/dangerfiles/config.rb', line 47 def initialize @files_to_category = {} @project_root = nil @project_name = ENV["CI_PROJECT_NAME"] @ci_only_rules = [] @code_size_thresholds = DEFAULT_CHANGES_SIZE_THRESHOLDS @max_commits_count = DEFAULT_COMMIT_MESSAGES_MAX_COMMITS_COUNT @disabled_roulette_categories = [] @included_optional_codeowners_sections_for_roulette = [] @excluded_required_codeowners_sections_for_roulette = [] end |
Instance Attribute Details
#ci_only_rules ⇒ Array<String>
Returns rules that cannot be run locally.
16 17 18 |
# File 'lib/gitlab/dangerfiles/config.rb', line 16 def ci_only_rules @ci_only_rules end |
#code_size_thresholds ⇒ { high: Integer, medium: Integer }
Returns a hash of the form { high: 42, medium: 12 } where :high
is the lines changed threshold which triggers an error, and :medium
is the lines changed threshold which triggers a warning. Also, see DEFAULT_CHANGES_SIZE_THRESHOLDS
for the format of the hash.
26 27 28 |
# File 'lib/gitlab/dangerfiles/config.rb', line 26 def code_size_thresholds @code_size_thresholds end |
#disabled_roulette_categories ⇒ Array
Returns indicating which categories would be disabled for the simple roulette. Default to ‘[]` (all categories are enabled).
34 35 36 |
# File 'lib/gitlab/dangerfiles/config.rb', line 34 def disabled_roulette_categories @disabled_roulette_categories end |
#excluded_required_codeowners_sections_for_roulette ⇒ Array
Returns indicating which required codeowners sections should be excluded from roulette. Default to ‘[]`.
42 43 44 |
# File 'lib/gitlab/dangerfiles/config.rb', line 42 def excluded_required_codeowners_sections_for_roulette @excluded_required_codeowners_sections_for_roulette end |
#files_to_category ⇒ {Regexp => Array<Symbol>}, {Array<Regexp> => Array<Symbol>}
Returns A hash of the form { filename_regex => categories, [filename_regex, changes_regex] => categories }. filename_regex
is the regex pattern to match file names. changes_regex
is the regex pattern to match changed lines in files that match filename_regex
. Used in ‘helper.changes_by_category`, `helper.changes`, and `helper.categories_for_file`.
22 23 24 |
# File 'lib/gitlab/dangerfiles/config.rb', line 22 def files_to_category @files_to_category end |
#included_optional_codeowners_sections_for_roulette ⇒ Array
Returns indicating which optional codeowners sections should be included in roulette. Default to ‘[]`.
38 39 40 |
# File 'lib/gitlab/dangerfiles/config.rb', line 38 def included_optional_codeowners_sections_for_roulette @included_optional_codeowners_sections_for_roulette end |
#max_commits_count ⇒ Integer
Returns the maximum number of allowed non-squashed/non-fixup commits for a given MR. A warning is triggered if the MR has more commits.
30 31 32 |
# File 'lib/gitlab/dangerfiles/config.rb', line 30 def max_commits_count @max_commits_count end |
#project_name ⇒ String
Returns the project name. Currently used by the Roulette plugin to fetch relevant reviewers/maintainers based on the project name. Default to ENV.
12 13 14 |
# File 'lib/gitlab/dangerfiles/config.rb', line 12 def project_name @project_name end |
#project_root ⇒ String
Returns the project root folder path.
8 9 10 |
# File 'lib/gitlab/dangerfiles/config.rb', line 8 def project_root @project_root end |