diff --git a/.rubocop.yml b/.rubocop.yml index 46634eb2337..3c64374772a 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -23,7 +23,7 @@ Style/AlignHash: Description: >- Align the elements of a hash literal if they span more than one line. - Enabled: false + Enabled: true Style/AlignParameters: Description: >- diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb index b471d57f698..dccb96ba1d1 100644 --- a/app/controllers/projects/blob_controller.rb +++ b/app/controllers/projects/blob_controller.rb @@ -59,8 +59,7 @@ class Projects::BlobController < Projects::ApplicationController def preview @content = params[:content] - diffy = Diffy::Diff.new(@blob.data, @content, diff: '-U 3', - include_diff_info: true) + diffy = Diffy::Diff.new(@blob.data, @content, diff: '-U 3', include_diff_info: true) @diff_lines = Gitlab::Diff::Parser.new.parse(diffy.diff.scan(/.*\n/)) render layout: false diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index d00f1aac2d6..7417261a847 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -75,9 +75,9 @@ module ApplicationHelper options[:class] ||= '' options[:class] << ' identicon' bg_key = project.id % 7 + style = "background-color: ##{ allowed_colors.values[bg_key] }; color: #555" - content_tag(:div, class: options[:class], - style: "background-color: ##{ allowed_colors.values[bg_key] }; color: #555") do + content_tag(:div, class: options[:class], style: style) do project.name[0, 1].upcase end end diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index 45ae79a75cc..0b3d430add0 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -14,7 +14,8 @@ # 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" }, if: :home_page_url_column_exist diff --git a/app/models/namespace.rb b/app/models/namespace.rb index ea4b48fdd7f..e7fd3024750 100644 --- a/app/models/namespace.rb +++ b/app/models/namespace.rb @@ -20,15 +20,20 @@ class Namespace < ActiveRecord::Base belongs_to :owner, class_name: "User" validates :owner, presence: true, unless: ->(n) { n.type == "Group" } - validates :name, presence: true, uniqueness: true, - length: { within: 0..255 }, - format: { with: Gitlab::Regex.name_regex, - message: Gitlab::Regex.name_regex_message } + validates :name, + presence: true, uniqueness: true, + length: { within: 0..255 }, + format: { with: Gitlab::Regex.name_regex, + message: Gitlab::Regex.name_regex_message } + validates :description, length: { within: 0..255 } - validates :path, uniqueness: { case_sensitive: false }, presence: true, length: { within: 1..255 }, - exclusion: { in: Gitlab::Blacklist.path }, - format: { with: Gitlab::Regex.path_regex, - message: Gitlab::Regex.path_regex_message } + validates :path, + uniqueness: { case_sensitive: false }, + presence: true, + 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 diff --git a/app/models/project.rb b/app/models/project.rb index f314ed9bd25..cfe40553ab5 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -108,13 +108,17 @@ class Project < ActiveRecord::Base # Validations validates :creator, presence: true, on: :create validates :description, length: { maximum: 2000 }, allow_blank: true - validates :name, presence: true, length: { within: 0..255 }, - format: { with: Gitlab::Regex.project_name_regex, - message: Gitlab::Regex.project_regex_message } - validates :path, presence: true, length: { within: 0..255 }, - exclusion: { in: Gitlab::Blacklist.path }, - format: { with: Gitlab::Regex.path_regex, - message: Gitlab::Regex.path_regex_message } + validates :name, + presence: true, + length: { within: 0..255 }, + format: { with: Gitlab::Regex.project_name_regex, + message: Gitlab::Regex.project_regex_message } + validates :path, + 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, :wiki_enabled, inclusion: { in: [true, false] } validates :visibility_level, diff --git a/app/models/project_services/bamboo_service.rb b/app/models/project_services/bamboo_service.rb index 16e1b83da4b..745609e5911 100644 --- a/app/models/project_services/bamboo_service.rb +++ b/app/models/project_services/bamboo_service.rb @@ -17,13 +17,19 @@ class BambooService < CiService prop_accessor :bamboo_url, :build_key, :username, :password - validates :bamboo_url, presence: true, - format: { with: URI::regexp }, if: :activated? + validates :bamboo_url, + presence: true, + format: { with: URI::regexp }, + if: :activated? validates :build_key, presence: true, if: :activated? - validates :username, presence: true, - if: ->(service) { service.password? }, if: :activated? - validates :password, presence: true, - if: ->(service) { service.username? }, if: :activated? + validates :username, + presence: true, + if: ->(service) { service.password? }, + if: :activated? + validates :password, + presence: true, + if: ->(service) { service.username? }, + if: :activated? attr_accessor :response diff --git a/app/models/project_services/teamcity_service.rb b/app/models/project_services/teamcity_service.rb index dca718b5e8c..287f5c0e84e 100644 --- a/app/models/project_services/teamcity_service.rb +++ b/app/models/project_services/teamcity_service.rb @@ -17,13 +17,16 @@ class TeamcityService < CiService prop_accessor :teamcity_url, :build_type, :username, :password - validates :teamcity_url, presence: true, - format: { with: URI::regexp }, if: :activated? + validates :teamcity_url, + presence: true, + format: { with: URI::regexp }, if: :activated? validates :build_type, presence: true, if: :activated? - validates :username, presence: true, - if: ->(service) { service.password? }, if: :activated? - validates :password, presence: true, - if: ->(service) { service.username? }, if: :activated? + validates :username, + presence: true, + if: ->(service) { service.password? }, if: :activated? + validates :password, + presence: true, + if: ->(service) { service.username? }, if: :activated? attr_accessor :response diff --git a/app/models/snippet.rb b/app/models/snippet.rb index 9aba42a0622..a3222d29892 100644 --- a/app/models/snippet.rb +++ b/app/models/snippet.rb @@ -29,9 +29,11 @@ class Snippet < ActiveRecord::Base validates :author, presence: true validates :title, presence: true, length: { within: 0..255 } - validates :file_name, presence: true, length: { within: 0..255 }, - format: { with: Gitlab::Regex.path_regex, - message: Gitlab::Regex.path_regex_message } + validates :file_name, + presence: true, + length: { within: 0..255 }, + format: { with: Gitlab::Regex.path_regex, + message: Gitlab::Regex.path_regex_message } validates :content, presence: true validates :visibility_level, inclusion: { in: Gitlab::VisibilityLevel.values } diff --git a/app/models/user.rb b/app/models/user.rb index 27724b3ccba..552a37c9533 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -116,10 +116,12 @@ class User < ActiveRecord::Base validates :email, presence: true, email: { strict_mode: true }, uniqueness: true validates :bio, length: { maximum: 255 }, allow_blank: true validates :projects_limit, presence: true, numericality: { greater_than_or_equal_to: 0 } - validates :username, presence: true, uniqueness: { case_sensitive: false }, - exclusion: { in: Gitlab::Blacklist.path }, - format: { with: Gitlab::Regex.username_regex, - message: Gitlab::Regex.username_regex_message } + validates :username, + presence: true, + uniqueness: { case_sensitive: false }, + 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 validate :namespace_uniq, if: ->(user) { user.username_changed? } diff --git a/config/routes.rb b/config/routes.rb index a83c112a882..a2d782cf633 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -294,12 +294,10 @@ Gitlab::Application.routes.draw do member do # tree viewer logs get 'logs_tree', constraints: { id: Gitlab::Regex.git_reference_regex } - get 'logs_tree/:path' => 'refs#logs_tree', - as: :logs_file, - constraints: { - id: Gitlab::Regex.git_reference_regex, - path: /.*/ - } + get 'logs_tree/:path' => 'refs#logs_tree', as: :logs_file, constraints: { + id: Gitlab::Regex.git_reference_regex, + path: /.*/ + } end end diff --git a/lib/gitlab/ldap/adapter.rb b/lib/gitlab/ldap/adapter.rb index 256cdb4c2f1..577a890a7d9 100644 --- a/lib/gitlab/ldap/adapter.rb +++ b/lib/gitlab/ldap/adapter.rb @@ -63,8 +63,10 @@ module Gitlab end def dn_matches_filter?(dn, filter) - ldap_search(base: dn, filter: filter, - scope: Net::LDAP::SearchScope_BaseObject, attributes: %w{dn}).any? + ldap_search(base: dn, + filter: filter, + scope: Net::LDAP::SearchScope_BaseObject, + attributes: %w{dn}).any? end def ldap_search(*args)