Module: Sonarqube::Client::QualityGates
- Included in:
- Sonarqube::Client
- Defined in:
- lib/sonarqube/client/quality_gates.rb
Overview
Defines methods related to tokens.
Constant Summary collapse
- ALLOWED_OPERATORS =
%w[LT GT].freeze
- ALLOWED_METRICS =
%w[ coverage new_coverage duplicated_lines_density new_duplicated_lines_density reliability_rating new_reliability_rating maintainability_rating new_maintainability_rating ].freeze
Instance Method Summary collapse
-
#create_quality_gate(name) ⇒ Sonarqube::ObjectifiedHash
(also: #quality_gate_create)
Create new quality gate.
-
#create_quality_gate_condition(name, metric, error_threshold, operator = 'LT') ⇒ Sonarqube::ObjectifiedHash
(also: #quality_gate_condition_create)
Create condition for a quality gate.
-
#list_quality_gates ⇒ Sonarqube::ObjectifiedHash
(also: #quality_gates_list)
List quality gates.
-
#set_default_quality_gate(name) ⇒ Sonarqube::ObjectifiedHash
(also: #default_quality_gate_set)
Set the default quality gate.
Instance Method Details
#create_quality_gate(name) ⇒ Sonarqube::ObjectifiedHash Also known as: quality_gate_create
Create new quality gate.
27 28 29 30 31 32 |
# File 'lib/sonarqube/client/quality_gates.rb', line 27 def create_quality_gate(name) raise ArgumentError, 'Missing required parameters' if name.nil? body = { name: name } post('/api/qualitygates/create', body: body) end |
#create_quality_gate_condition(name, metric, error_threshold, operator = 'LT') ⇒ Sonarqube::ObjectifiedHash Also known as: quality_gate_condition_create
Create condition for a quality gate.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/sonarqube/client/quality_gates.rb', line 50 def create_quality_gate_condition(name, metric, error_threshold, operator = 'LT') raise ArgumentError, 'Missing required parameters' if name.nil? || metric.nil? || error_threshold.nil? unless ALLOWED_OPERATORS.include?(operator) raise ArgumentError, "Operator must be in #{ALLOWED_OPERATORS.join(', ')}" end raise ArgumentError, "Metric must be in #{ALLOWED_METRICS.join(', ')}" unless ALLOWED_METRICS.include?(metric) body = { gateName: name, metric: metric, error: error_threshold, op: operator } post('/api/qualitygates/create_condition', body: body) end |
#list_quality_gates ⇒ Sonarqube::ObjectifiedHash Also known as: quality_gates_list
List quality gates.
90 91 92 |
# File 'lib/sonarqube/client/quality_gates.rb', line 90 def list_quality_gates get('/api/qualitygates/list') end |
#set_default_quality_gate(name) ⇒ Sonarqube::ObjectifiedHash Also known as: default_quality_gate_set
Set the default quality gate.
rubocop:disable Naming/AccessorMethodName
75 76 77 78 79 80 |
# File 'lib/sonarqube/client/quality_gates.rb', line 75 def set_default_quality_gate(name) raise ArgumentError, 'Missing required parameters' if name.nil? body = { name: name } post('/api/qualitygates/set_as_default', body: body) end |