summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorJacopo <beschi.jacopo@gmail.com>2017-11-14 10:02:39 +0100
committerJacopo <beschi.jacopo@gmail.com>2017-11-16 17:58:29 +0100
commit181cd299f9e06223e8338e93b1c318c671ccb1aa (patch)
tree0d71dcf3f786496eaa46b9d65ce2626f162015da /app/models
parentf2997af4d5cdec3266d3178edeedc36d4e590062 (diff)
downloadgitlab-ce-181cd299f9e06223e8338e93b1c318c671ccb1aa.tar.gz
Adds Rubocop rule for line break after guard clause
Adds a rubocop rule (with autocorrect) to ensure line break after guard clauses.
Diffstat (limited to 'app/models')
-rw-r--r--app/models/ci/build.rb1
-rw-r--r--app/models/ci/pipeline.rb2
-rw-r--r--app/models/clusters/providers/gcp.rb1
-rw-r--r--app/models/concerns/awardable.rb1
-rw-r--r--app/models/pages_domain.rb5
-rw-r--r--app/models/project_services/hipchat_service.rb2
-rw-r--r--app/models/project_services/jira_service.rb1
-rw-r--r--app/models/project_services/kubernetes_service.rb1
-rw-r--r--app/models/repository.rb2
-rw-r--r--app/models/user.rb2
10 files changed, 18 insertions, 0 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index 1b2b0d17910..1d9f367183e 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -317,6 +317,7 @@ module Ci
def execute_hooks
return unless project
+
build_data = Gitlab::DataBuilder::Build.build(self)
project.execute_hooks(build_data.dup, :job_hooks)
project.execute_services(build_data.dup, :job_hooks)
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index 19814864e50..bcc865357ff 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -300,8 +300,10 @@ module Ci
def latest?
return false unless ref
+
commit = project.commit(ref)
return false unless commit
+
commit.sha == sha
end
diff --git a/app/models/clusters/providers/gcp.rb b/app/models/clusters/providers/gcp.rb
index ee2e43ee9dd..7fac32466ab 100644
--- a/app/models/clusters/providers/gcp.rb
+++ b/app/models/clusters/providers/gcp.rb
@@ -56,6 +56,7 @@ module Clusters
before_transition any => [:creating] do |provider, transition|
operation_id = transition.args.first
raise ArgumentError.new('operation_id is required') unless operation_id.present?
+
provider.operation_id = operation_id
end
diff --git a/app/models/concerns/awardable.rb b/app/models/concerns/awardable.rb
index 9adc309a22b..d8394415362 100644
--- a/app/models/concerns/awardable.rb
+++ b/app/models/concerns/awardable.rb
@@ -98,6 +98,7 @@ module Awardable
def create_award_emoji(name, current_user)
return unless emoji_awardable?
+
award_emoji.create(name: normalize_name(name), user: current_user)
end
diff --git a/app/models/pages_domain.rb b/app/models/pages_domain.rb
index 43c77f3f2a2..8de42ff9d2e 100644
--- a/app/models/pages_domain.rb
+++ b/app/models/pages_domain.rb
@@ -65,6 +65,7 @@ class PagesDomain < ActiveRecord::Base
def expired?
return false unless x509
+
current = Time.new
current < x509.not_before || x509.not_after < current
end
@@ -75,6 +76,7 @@ class PagesDomain < ActiveRecord::Base
def subject
return unless x509
+
x509.subject.to_s
end
@@ -102,6 +104,7 @@ class PagesDomain < ActiveRecord::Base
def validate_pages_domain
return unless domain
+
if domain.downcase.ends_with?(Settings.pages.host.downcase)
self.errors.add(:domain, "*.#{Settings.pages.host} is restricted")
end
@@ -109,6 +112,7 @@ class PagesDomain < ActiveRecord::Base
def x509
return unless certificate
+
@x509 ||= OpenSSL::X509::Certificate.new(certificate)
rescue OpenSSL::X509::CertificateError
nil
@@ -116,6 +120,7 @@ class PagesDomain < ActiveRecord::Base
def pkey
return unless key
+
@pkey ||= OpenSSL::PKey::RSA.new(key)
rescue OpenSSL::PKey::PKeyError, OpenSSL::Cipher::CipherError
nil
diff --git a/app/models/project_services/hipchat_service.rb b/app/models/project_services/hipchat_service.rb
index 976d85246a8..768f0a7472e 100644
--- a/app/models/project_services/hipchat_service.rb
+++ b/app/models/project_services/hipchat_service.rb
@@ -51,8 +51,10 @@ class HipchatService < Service
def execute(data)
return unless supported_events.include?(data[:object_kind])
+
message = create_message(data)
return unless message.present?
+
gate[room].send('GitLab', message, message_options(data)) # rubocop:disable GitlabSecurity/PublicSend
end
diff --git a/app/models/project_services/jira_service.rb b/app/models/project_services/jira_service.rb
index b487378edd2..1c065e1ddbd 100644
--- a/app/models/project_services/jira_service.rb
+++ b/app/models/project_services/jira_service.rb
@@ -176,6 +176,7 @@ class JiraService < IssueTrackerService
def test_settings
return unless client_url.present?
+
# Test settings by getting the project
jira_request { client.ServerInfo.all.attrs }
end
diff --git a/app/models/project_services/kubernetes_service.rb b/app/models/project_services/kubernetes_service.rb
index 5080acffb3c..bc62972dbb0 100644
--- a/app/models/project_services/kubernetes_service.rb
+++ b/app/models/project_services/kubernetes_service.rb
@@ -182,6 +182,7 @@ class KubernetesService < DeploymentService
kubeclient.get_pods(namespace: actual_namespace).as_json
rescue KubeException => err
raise err unless err.error_code == 404
+
[]
end
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 3a89fa9264b..845929fb2cc 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -242,6 +242,7 @@ class Repository
Rails.logger.error "Unable to create #{REF_KEEP_AROUND} reference for repository #{path}: #{ex}"
rescue Rugged::OSError => ex
raise unless ex.message =~ /Failed to create locked file/ && ex.message =~ /File exists/
+
Rails.logger.error "Unable to create #{REF_KEEP_AROUND} reference for repository #{path}: #{ex}"
end
end
@@ -662,6 +663,7 @@ class Repository
def next_branch(name, opts = {})
branch_ids = self.branch_names.map do |n|
next 1 if n == name
+
result = n.match(/\A#{name}-([0-9]+)\z/)
result[1].to_i if result
end.compact
diff --git a/app/models/user.rb b/app/models/user.rb
index ea10e2854d6..5170d87e850 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -1119,6 +1119,7 @@ class User < ActiveRecord::Base
# override, from Devise::Validatable
def password_required?
return false if internal?
+
super
end
@@ -1136,6 +1137,7 @@ class User < ActiveRecord::Base
# Added according to https://github.com/plataformatec/devise/blob/7df57d5081f9884849ca15e4fde179ef164a575f/README.md#activejob-integration
def send_devise_notification(notification, *args)
return true unless can?(:receive_notifications)
+
devise_mailer.__send__(notification, self, *args).deliver_later # rubocop:disable GitlabSecurity/PublicSend
end