Commit cc39bca3 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Rubocop: Style/AlignHash enabled

parent c427bf08
...@@ -23,7 +23,7 @@ Style/AlignHash: ...@@ -23,7 +23,7 @@ Style/AlignHash:
Description: >- Description: >-
Align the elements of a hash literal if they span more than Align the elements of a hash literal if they span more than
one line. one line.
Enabled: false Enabled: true
Style/AlignParameters: Style/AlignParameters:
Description: >- Description: >-
......
...@@ -59,8 +59,7 @@ class Projects::BlobController < Projects::ApplicationController ...@@ -59,8 +59,7 @@ class Projects::BlobController < Projects::ApplicationController
def preview def preview
@content = params[:content] @content = params[:content]
diffy = Diffy::Diff.new(@blob.data, @content, diff: '-U 3', diffy = Diffy::Diff.new(@blob.data, @content, diff: '-U 3', include_diff_info: true)
include_diff_info: true)
@diff_lines = Gitlab::Diff::Parser.new.parse(diffy.diff.scan(/.*\n/)) @diff_lines = Gitlab::Diff::Parser.new.parse(diffy.diff.scan(/.*\n/))
render layout: false render layout: false
......
...@@ -75,9 +75,9 @@ module ApplicationHelper ...@@ -75,9 +75,9 @@ module ApplicationHelper
options[:class] ||= '' options[:class] ||= ''
options[:class] << ' identicon' options[:class] << ' identicon'
bg_key = project.id % 7 bg_key = project.id % 7
style = "background-color: ##{ allowed_colors.values[bg_key] }; color: #555"
content_tag(:div, class: options[:class], content_tag(:div, class: options[:class], style: style) do
style: "background-color: ##{ allowed_colors.values[bg_key] }; color: #555") do
project.name[0, 1].upcase project.name[0, 1].upcase
end end
end end
......
...@@ -14,7 +14,8 @@ ...@@ -14,7 +14,8 @@
# #
class ApplicationSetting < ActiveRecord::Base class ApplicationSetting < ActiveRecord::Base
validates :home_page_url, allow_blank: true, validates :home_page_url,
allow_blank: true,
format: { with: URI::regexp(%w(http https)), message: "should be a valid url" }, format: { with: URI::regexp(%w(http https)), message: "should be a valid url" },
if: :home_page_url_column_exist if: :home_page_url_column_exist
......
...@@ -20,15 +20,20 @@ class Namespace < ActiveRecord::Base ...@@ -20,15 +20,20 @@ class Namespace < ActiveRecord::Base
belongs_to :owner, class_name: "User" belongs_to :owner, class_name: "User"
validates :owner, presence: true, unless: ->(n) { n.type == "Group" } validates :owner, presence: true, unless: ->(n) { n.type == "Group" }
validates :name, presence: true, uniqueness: true, validates :name,
length: { within: 0..255 }, presence: true, uniqueness: true,
format: { with: Gitlab::Regex.name_regex, length: { within: 0..255 },
message: Gitlab::Regex.name_regex_message } format: { with: Gitlab::Regex.name_regex,
message: Gitlab::Regex.name_regex_message }
validates :description, length: { within: 0..255 } validates :description, length: { within: 0..255 }
validates :path, uniqueness: { case_sensitive: false }, presence: true, length: { within: 1..255 }, validates :path,
exclusion: { in: Gitlab::Blacklist.path }, uniqueness: { case_sensitive: false },
format: { with: Gitlab::Regex.path_regex, presence: true,
message: Gitlab::Regex.path_regex_message } length: { within: 1..255 },
exclusion: { in: Gitlab::Blacklist.path },
format: { with: Gitlab::Regex.path_regex,
message: Gitlab::Regex.path_regex_message }
delegate :name, to: :owner, allow_nil: true, prefix: true delegate :name, to: :owner, allow_nil: true, prefix: true
......
...@@ -108,13 +108,17 @@ class Project < ActiveRecord::Base ...@@ -108,13 +108,17 @@ class Project < ActiveRecord::Base
# Validations # Validations
validates :creator, presence: true, on: :create validates :creator, presence: true, on: :create
validates :description, length: { maximum: 2000 }, allow_blank: true validates :description, length: { maximum: 2000 }, allow_blank: true
validates :name, presence: true, length: { within: 0..255 }, validates :name,
format: { with: Gitlab::Regex.project_name_regex, presence: true,
message: Gitlab::Regex.project_regex_message } length: { within: 0..255 },
validates :path, presence: true, length: { within: 0..255 }, format: { with: Gitlab::Regex.project_name_regex,
exclusion: { in: Gitlab::Blacklist.path }, message: Gitlab::Regex.project_regex_message }
format: { with: Gitlab::Regex.path_regex, validates :path,
message: Gitlab::Regex.path_regex_message } presence: true,
length: { within: 0..255 },
exclusion: { in: Gitlab::Blacklist.path },
format: { with: Gitlab::Regex.path_regex,
message: Gitlab::Regex.path_regex_message }
validates :issues_enabled, :merge_requests_enabled, validates :issues_enabled, :merge_requests_enabled,
:wiki_enabled, inclusion: { in: [true, false] } :wiki_enabled, inclusion: { in: [true, false] }
validates :visibility_level, validates :visibility_level,
......
...@@ -17,13 +17,19 @@ class BambooService < CiService ...@@ -17,13 +17,19 @@ class BambooService < CiService
prop_accessor :bamboo_url, :build_key, :username, :password prop_accessor :bamboo_url, :build_key, :username, :password
validates :bamboo_url, presence: true, validates :bamboo_url,
format: { with: URI::regexp }, if: :activated? presence: true,
format: { with: URI::regexp },
if: :activated?
validates :build_key, presence: true, if: :activated? validates :build_key, presence: true, if: :activated?
validates :username, presence: true, validates :username,
if: ->(service) { service.password? }, if: :activated? presence: true,
validates :password, presence: true, if: ->(service) { service.password? },
if: ->(service) { service.username? }, if: :activated? if: :activated?
validates :password,
presence: true,
if: ->(service) { service.username? },
if: :activated?
attr_accessor :response attr_accessor :response
......
...@@ -17,13 +17,16 @@ class TeamcityService < CiService ...@@ -17,13 +17,16 @@ class TeamcityService < CiService
prop_accessor :teamcity_url, :build_type, :username, :password prop_accessor :teamcity_url, :build_type, :username, :password
validates :teamcity_url, presence: true, validates :teamcity_url,
format: { with: URI::regexp }, if: :activated? presence: true,
format: { with: URI::regexp }, if: :activated?
validates :build_type, presence: true, if: :activated? validates :build_type, presence: true, if: :activated?
validates :username, presence: true, validates :username,
if: ->(service) { service.password? }, if: :activated? presence: true,
validates :password, presence: true, if: ->(service) { service.password? }, if: :activated?
if: ->(service) { service.username? }, if: :activated? validates :password,
presence: true,
if: ->(service) { service.username? }, if: :activated?
attr_accessor :response attr_accessor :response
......
...@@ -29,9 +29,11 @@ class Snippet < ActiveRecord::Base ...@@ -29,9 +29,11 @@ class Snippet < ActiveRecord::Base
validates :author, presence: true validates :author, presence: true
validates :title, presence: true, length: { within: 0..255 } validates :title, presence: true, length: { within: 0..255 }
validates :file_name, presence: true, length: { within: 0..255 }, validates :file_name,
format: { with: Gitlab::Regex.path_regex, presence: true,
message: Gitlab::Regex.path_regex_message } length: { within: 0..255 },
format: { with: Gitlab::Regex.path_regex,
message: Gitlab::Regex.path_regex_message }
validates :content, presence: true validates :content, presence: true
validates :visibility_level, inclusion: { in: Gitlab::VisibilityLevel.values } validates :visibility_level, inclusion: { in: Gitlab::VisibilityLevel.values }
......
...@@ -116,10 +116,12 @@ class User < ActiveRecord::Base ...@@ -116,10 +116,12 @@ class User < ActiveRecord::Base
validates :email, presence: true, email: { strict_mode: true }, uniqueness: true validates :email, presence: true, email: { strict_mode: true }, uniqueness: true
validates :bio, length: { maximum: 255 }, allow_blank: true validates :bio, length: { maximum: 255 }, allow_blank: true
validates :projects_limit, presence: true, numericality: { greater_than_or_equal_to: 0 } validates :projects_limit, presence: true, numericality: { greater_than_or_equal_to: 0 }
validates :username, presence: true, uniqueness: { case_sensitive: false }, validates :username,
exclusion: { in: Gitlab::Blacklist.path }, presence: true,
format: { with: Gitlab::Regex.username_regex, uniqueness: { case_sensitive: false },
message: Gitlab::Regex.username_regex_message } exclusion: { in: Gitlab::Blacklist.path },
format: { with: Gitlab::Regex.username_regex,
message: Gitlab::Regex.username_regex_message }
validates :notification_level, inclusion: { in: Notification.notification_levels }, presence: true validates :notification_level, inclusion: { in: Notification.notification_levels }, presence: true
validate :namespace_uniq, if: ->(user) { user.username_changed? } validate :namespace_uniq, if: ->(user) { user.username_changed? }
......
...@@ -294,12 +294,10 @@ Gitlab::Application.routes.draw do ...@@ -294,12 +294,10 @@ Gitlab::Application.routes.draw do
member do member do
# tree viewer logs # tree viewer logs
get 'logs_tree', constraints: { id: Gitlab::Regex.git_reference_regex } get 'logs_tree', constraints: { id: Gitlab::Regex.git_reference_regex }
get 'logs_tree/:path' => 'refs#logs_tree', get 'logs_tree/:path' => 'refs#logs_tree', as: :logs_file, constraints: {
as: :logs_file, id: Gitlab::Regex.git_reference_regex,
constraints: { path: /.*/
id: Gitlab::Regex.git_reference_regex, }
path: /.*/
}
end end
end end
......
...@@ -63,8 +63,10 @@ module Gitlab ...@@ -63,8 +63,10 @@ module Gitlab
end end
def dn_matches_filter?(dn, filter) def dn_matches_filter?(dn, filter)
ldap_search(base: dn, filter: filter, ldap_search(base: dn,
scope: Net::LDAP::SearchScope_BaseObject, attributes: %w{dn}).any? filter: filter,
scope: Net::LDAP::SearchScope_BaseObject,
attributes: %w{dn}).any?
end end
def ldap_search(*args) def ldap_search(*args)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment