summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.rubocop.yml3
-rw-r--r--.rubocop_todo.yml17
-rw-r--r--app/models/ci/build.rb2
-rw-r--r--app/models/ci/pipeline.rb6
-rw-r--r--app/models/ci/runner_project.rb2
-rw-r--r--app/models/ci/trigger.rb4
-rw-r--r--app/models/commit_status.rb2
-rw-r--r--app/models/members/group_member.rb2
-rw-r--r--app/models/members/project_member.rb2
-rw-r--r--app/models/pages_domain.rb2
-rw-r--r--app/models/project.rb4
-rw-r--r--app/models/protected_branch.rb4
-rw-r--r--app/models/user.rb2
13 files changed, 19 insertions, 33 deletions
diff --git a/.rubocop.yml b/.rubocop.yml
index c81e7eb37b6..e0d65533bb5 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -941,6 +941,9 @@ Rails/OutputSafety:
Rails/TimeZone:
Enabled: false
+Rails/Validation:
+ Enabled: true
+
Style/AlignParameters:
Enabled: false
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index f24c74547e8..37d05ac4509 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -38,23 +38,6 @@ RSpec/SingleArgumentMessageChain:
Exclude:
- 'spec/requests/api/internal_spec.rb'
-# Cop supports --auto-correct.
-# Configuration parameters: Include.
-# Include: app/models/**/*.rb
-Rails/Validation:
- Exclude:
- - 'app/models/ci/build.rb'
- - 'app/models/ci/pipeline.rb'
- - 'app/models/ci/runner_project.rb'
- - 'app/models/ci/trigger.rb'
- - 'app/models/commit_status.rb'
- - 'app/models/members/group_member.rb'
- - 'app/models/members/project_member.rb'
- - 'app/models/pages_domain.rb'
- - 'app/models/project.rb'
- - 'app/models/protected_branch.rb'
- - 'app/models/user.rb'
-
# Offense count: 8
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect.
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index 9a45ef06750..f9592873ea0 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -23,7 +23,7 @@ module Ci
serialize :yaml_variables, Gitlab::Serializer::Ci::Variables
validates :coverage, numericality: true, allow_blank: true
- validates_presence_of :ref
+ validates :ref, presence: true
scope :unstarted, ->() { where(runner_id: nil) }
scope :ignore_failures, ->() { where(allow_failure: false) }
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index ae4759ed2a0..673647f284a 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -14,9 +14,9 @@ module Ci
has_many :builds, foreign_key: :commit_id
has_many :trigger_requests, dependent: :destroy, foreign_key: :commit_id
- validates_presence_of :sha, unless: :importing?
- validates_presence_of :ref, unless: :importing?
- validates_presence_of :status, unless: :importing?
+ validates :sha, presence: { unless: :importing? }
+ validates :ref, presence: { unless: :importing? }
+ validates :status, presence: { unless: :importing? }
validate :valid_commit_sha, unless: :importing?
after_create :keep_around_commits, unless: :importing?
diff --git a/app/models/ci/runner_project.rb b/app/models/ci/runner_project.rb
index 1f9baeca5b1..234376a7e4c 100644
--- a/app/models/ci/runner_project.rb
+++ b/app/models/ci/runner_project.rb
@@ -5,6 +5,6 @@ module Ci
belongs_to :runner
belongs_to :project, foreign_key: :gl_project_id
- validates_uniqueness_of :runner_id, scope: :gl_project_id
+ validates :runner_id, uniqueness: { scope: :gl_project_id }
end
end
diff --git a/app/models/ci/trigger.rb b/app/models/ci/trigger.rb
index 62889fe80d8..39a1dd86241 100644
--- a/app/models/ci/trigger.rb
+++ b/app/models/ci/trigger.rb
@@ -7,8 +7,8 @@ module Ci
belongs_to :project, foreign_key: :gl_project_id
has_many :trigger_requests, dependent: :destroy
- validates_presence_of :token
- validates_uniqueness_of :token
+ validates :token, presence: true
+ validates :token, uniqueness: true
before_validation :set_default_values
diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb
index d31a6d81ebd..ef5e6202519 100644
--- a/app/models/commit_status.rb
+++ b/app/models/commit_status.rb
@@ -13,7 +13,7 @@ class CommitStatus < ActiveRecord::Base
validates :pipeline, presence: true, unless: :importing?
- validates_presence_of :name
+ validates :name, presence: true
alias_attribute :author, :user
diff --git a/app/models/members/group_member.rb b/app/models/members/group_member.rb
index 4043fde5301..446f9f8f8a7 100644
--- a/app/models/members/group_member.rb
+++ b/app/models/members/group_member.rb
@@ -5,7 +5,7 @@ class GroupMember < Member
# Make sure group member points only to group as it source
default_value_for :source_type, SOURCE_TYPE
- validates_format_of :source_type, with: /\ANamespace\z/
+ validates :source_type, format: { with: /\ANamespace\z/ }
default_scope { where(source_type: SOURCE_TYPE) }
def self.access_level_roles
diff --git a/app/models/members/project_member.rb b/app/models/members/project_member.rb
index 06f8fd39c99..912820b51ac 100644
--- a/app/models/members/project_member.rb
+++ b/app/models/members/project_member.rb
@@ -7,7 +7,7 @@ class ProjectMember < Member
# Make sure project member points only to project as it source
default_value_for :source_type, SOURCE_TYPE
- validates_format_of :source_type, with: /\AProject\z/
+ validates :source_type, format: { with: /\AProject\z/ }
validates :access_level, inclusion: { in: Gitlab::Access.values }
default_scope { where(source_type: SOURCE_TYPE) }
diff --git a/app/models/pages_domain.rb b/app/models/pages_domain.rb
index 0b9ebf1ffe2..f2f2fc1e32a 100644
--- a/app/models/pages_domain.rb
+++ b/app/models/pages_domain.rb
@@ -2,7 +2,7 @@ class PagesDomain < ActiveRecord::Base
belongs_to :project
validates :domain, hostname: true
- validates_uniqueness_of :domain, case_sensitive: false
+ validates :domain, uniqueness: { case_sensitive: false }
validates :certificate, certificate: true, allow_nil: true, allow_blank: true
validates :key, certificate_key: true, allow_nil: true, allow_blank: true
diff --git a/app/models/project.rb b/app/models/project.rb
index 3a1a724b987..0da21be8351 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -191,8 +191,8 @@ class Project < ActiveRecord::Base
format: { with: Gitlab::Regex.project_path_regex,
message: Gitlab::Regex.project_path_regex_message }
validates :namespace, presence: true
- validates_uniqueness_of :name, scope: :namespace_id
- validates_uniqueness_of :path, scope: :namespace_id
+ validates :name, uniqueness: { scope: :namespace_id }
+ validates :path, uniqueness: { scope: :namespace_id }
validates :import_url, addressable_url: true, if: :external_import?
validates :star_count, numericality: { greater_than_or_equal_to: 0 }
validate :check_limit, on: :create
diff --git a/app/models/protected_branch.rb b/app/models/protected_branch.rb
index 6240912a6e1..39e979ef15b 100644
--- a/app/models/protected_branch.rb
+++ b/app/models/protected_branch.rb
@@ -8,8 +8,8 @@ class ProtectedBranch < ActiveRecord::Base
has_many :merge_access_levels, dependent: :destroy
has_many :push_access_levels, dependent: :destroy
- validates_length_of :merge_access_levels, is: 1, message: "are restricted to a single instance per protected branch."
- validates_length_of :push_access_levels, is: 1, message: "are restricted to a single instance per protected branch."
+ validates :merge_access_levels, length: { is: 1, message: "are restricted to a single instance per protected branch." }
+ validates :push_access_levels, length: { is: 1, message: "are restricted to a single instance per protected branch." }
accepts_nested_attributes_for :push_access_levels
accepts_nested_attributes_for :merge_access_levels
diff --git a/app/models/user.rb b/app/models/user.rb
index f614eb66e1f..f37735c5eba 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -104,7 +104,7 @@ class User < ActiveRecord::Base
#
# Note: devise :validatable above adds validations for :email and :password
validates :name, presence: true
- validates_confirmation_of :email
+ validates :email, confirmation: true
validates :notification_email, presence: true
validates :notification_email, email: true, if: ->(user) { user.notification_email != user.email }
validates :public_email, presence: true, uniqueness: true, email: true, allow_blank: true