diff options
author | Robert Speicher <robert@gitlab.com> | 2016-05-30 17:59:10 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2016-05-30 17:59:10 +0000 |
commit | e7586cfbdc6a77b5771bea38a9ee3a9c17cdd37a (patch) | |
tree | 8c18de2755646c8e60c4554cf66d6475898b690f | |
parent | ea329376302bac3bd49244ad043fa8adeb1d002e (diff) | |
parent | a55e8f109fbaec1bb2db19a37a6537d8833c995c (diff) | |
download | gitlab-ce-e7586cfbdc6a77b5771bea38a9ee3a9c17cdd37a.tar.gz |
Merge branch 'rubocop/enable-negatedif-style-cop' into 'master'
Enable Style/NegatedIf Rubocop cop
Favor `unless` over `if` for negative conditions (or control flow ||).
```ruby
# bad
do_something if !some_condition
# bad
do_something if not some_condition
# good
do_something unless some_condition
# good
some_condition || do_something
```
See #17478
See merge request !4355
-rw-r--r-- | .rubocop.yml | 2 | ||||
-rw-r--r-- | app/models/ci/runner.rb | 2 | ||||
-rw-r--r-- | app/services/git_tag_push_service.rb | 2 | ||||
-rw-r--r-- | app/services/projects/housekeeping_service.rb | 2 | ||||
-rw-r--r-- | config/initializers/1_settings.rb | 2 | ||||
-rw-r--r-- | lib/ci/gitlab_ci_yaml_processor.rb | 2 |
6 files changed, 6 insertions, 6 deletions
diff --git a/.rubocop.yml b/.rubocop.yml index 877f0c2d45a..c27c8491126 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -394,7 +394,7 @@ Style/MutableConstant: # Favor unless over if for negative conditions (or control flow or). Style/NegatedIf: - Enabled: false + Enabled: true # Favor until over while for negative conditions. Style/NegatedWhile: diff --git a/app/models/ci/runner.rb b/app/models/ci/runner.rb index 6829dc91cb9..adb65292208 100644 --- a/app/models/ci/runner.rb +++ b/app/models/ci/runner.rb @@ -60,7 +60,7 @@ module Ci end def display_name - return short_sha unless !description.blank? + return short_sha if description.blank? description end diff --git a/app/services/git_tag_push_service.rb b/app/services/git_tag_push_service.rb index 7410442609d..299a0a967b0 100644 --- a/app/services/git_tag_push_service.rb +++ b/app/services/git_tag_push_service.rb @@ -23,7 +23,7 @@ class GitTagPushService < BaseService commits = [] 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 = project.repository.find_tag(tag_name) if tag && tag.target == params[:newrev] diff --git a/app/services/projects/housekeeping_service.rb b/app/services/projects/housekeeping_service.rb index 3b7c36f0908..43db29315a1 100644 --- a/app/services/projects/housekeeping_service.rb +++ b/app/services/projects/housekeeping_service.rb @@ -22,7 +22,7 @@ module Projects end def execute - raise LeaseTaken if !try_obtain_lease + raise LeaseTaken unless try_obtain_lease GitlabShellOneShotWorker.perform_async(:gc, @project.path_with_namespace) ensure diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index 124d63ce3ac..436751b9d16 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -52,7 +52,7 @@ class Settings < Settingslogic # check that values in `current` (string or integer) is a contant in `modul`. def verify_constant_array(modul, current, default) values = default || [] - if !current.nil? + unless current.nil? values = [] current.each do |constant| values.push(verify_constant(modul, constant, nil)) diff --git a/lib/ci/gitlab_ci_yaml_processor.rb b/lib/ci/gitlab_ci_yaml_processor.rb index e4b4760c53b..026a5ac97ca 100644 --- a/lib/ci/gitlab_ci_yaml_processor.rb +++ b/lib/ci/gitlab_ci_yaml_processor.rb @@ -265,7 +265,7 @@ module Ci end 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" end |