Enable Style/NegatedIf Rubocop cop
Favor `unless` over `if` for negative conditions (or control flow ||). See #17478
This commit is contained in:
parent
43c35b0f20
commit
a55e8f109f
|
@ -394,7 +394,7 @@ Style/MutableConstant:
|
||||||
|
|
||||||
# Favor unless over if for negative conditions (or control flow or).
|
# Favor unless over if for negative conditions (or control flow or).
|
||||||
Style/NegatedIf:
|
Style/NegatedIf:
|
||||||
Enabled: false
|
Enabled: true
|
||||||
|
|
||||||
# Favor until over while for negative conditions.
|
# Favor until over while for negative conditions.
|
||||||
Style/NegatedWhile:
|
Style/NegatedWhile:
|
||||||
|
|
|
@ -60,7 +60,7 @@ module Ci
|
||||||
end
|
end
|
||||||
|
|
||||||
def display_name
|
def display_name
|
||||||
return short_sha unless !description.blank?
|
return short_sha if description.blank?
|
||||||
|
|
||||||
description
|
description
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,7 +23,7 @@ class GitTagPushService < BaseService
|
||||||
commits = []
|
commits = []
|
||||||
message = nil
|
message = nil
|
||||||
|
|
||||||
if !Gitlab::Git.blank_ref?(params[:newrev])
|
unless Gitlab::Git.blank_ref?(params[:newrev])
|
||||||
tag_name = Gitlab::Git.ref_name(params[:ref])
|
tag_name = Gitlab::Git.ref_name(params[:ref])
|
||||||
tag = project.repository.find_tag(tag_name)
|
tag = project.repository.find_tag(tag_name)
|
||||||
if tag && tag.target == params[:newrev]
|
if tag && tag.target == params[:newrev]
|
||||||
|
|
|
@ -22,7 +22,7 @@ module Projects
|
||||||
end
|
end
|
||||||
|
|
||||||
def execute
|
def execute
|
||||||
raise LeaseTaken if !try_obtain_lease
|
raise LeaseTaken unless try_obtain_lease
|
||||||
|
|
||||||
GitlabShellOneShotWorker.perform_async(:gc, @project.path_with_namespace)
|
GitlabShellOneShotWorker.perform_async(:gc, @project.path_with_namespace)
|
||||||
ensure
|
ensure
|
||||||
|
|
|
@ -52,7 +52,7 @@ class Settings < Settingslogic
|
||||||
# check that values in `current` (string or integer) is a contant in `modul`.
|
# check that values in `current` (string or integer) is a contant in `modul`.
|
||||||
def verify_constant_array(modul, current, default)
|
def verify_constant_array(modul, current, default)
|
||||||
values = default || []
|
values = default || []
|
||||||
if !current.nil?
|
unless current.nil?
|
||||||
values = []
|
values = []
|
||||||
current.each do |constant|
|
current.each do |constant|
|
||||||
values.push(verify_constant(modul, constant, nil))
|
values.push(verify_constant(modul, constant, nil))
|
||||||
|
|
|
@ -265,7 +265,7 @@ module Ci
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_job_dependencies!(name, job)
|
def validate_job_dependencies!(name, job)
|
||||||
if !validate_array_of_strings(job[:dependencies])
|
unless validate_array_of_strings(job[:dependencies])
|
||||||
raise ValidationError, "#{name} job: dependencies parameter should be an array of strings"
|
raise ValidationError, "#{name} job: dependencies parameter should be an array of strings"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue