diff --git a/.rubocop.yml b/.rubocop.yml index 17494974d14823f810871cc14664370fd2bd10df..a4b51008194176c5ed4477b007594362590418b6 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,7 +1,7 @@ Style/AccessModifierIndentation: Description: Check indentation of private/protected visibility modifiers. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#indent-public-private-protected' - Enabled: false + Enabled: true Style/AccessorMethodName: Description: Check the naming of accessor methods for get_/set_. @@ -10,20 +10,20 @@ Style/AccessorMethodName: Style/Alias: Description: 'Use alias_method instead of alias.' StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#alias-method' - Enabled: false + Enabled: true Style/AlignArray: Description: >- Align the elements of an array literal if they span more than one line. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#align-multiline-arrays' - Enabled: false + Enabled: true Style/AlignHash: Description: >- Align the elements of a hash literal if they span more than one line. - Enabled: false + Enabled: true Style/AlignParameters: Description: >- @@ -45,12 +45,12 @@ Style/ArrayJoin: Style/AsciiComments: Description: 'Use only ascii symbols in comments.' StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#english-comments' - Enabled: false + Enabled: true Style/AsciiIdentifiers: Description: 'Use only ascii symbols in identifiers.' StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#english-identifiers' - Enabled: false + Enabled: true Style/Attr: Description: 'Checks for uses of Module#attr.' @@ -60,7 +60,7 @@ Style/Attr: Style/BeginBlock: Description: 'Avoid the use of BEGIN blocks.' StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-BEGIN-blocks' - Enabled: false + Enabled: true Style/BarePercentLiterals: Description: 'Checks if usage of %() or %Q() matches configuration.' @@ -74,7 +74,7 @@ Style/BlockComments: Style/BlockEndNewline: Description: 'Put end statement of multiline block on its own line.' - Enabled: false + Enabled: true Style/Blocks: Description: >- @@ -82,7 +82,7 @@ Style/Blocks: always ugly). Prefer {...} over do...end for single-line blocks. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#single-line-blocks' - Enabled: false + Enabled: true Style/BracesAroundHashParameters: Description: 'Enforce braces style around hash parameters.' @@ -96,17 +96,17 @@ Style/CaseEquality: Style/CaseIndentation: Description: 'Indentation of when in a case/when/[else/]end.' StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#indent-when-to-case' - Enabled: false + Enabled: true Style/CharacterLiteral: Description: 'Checks for uses of character literals.' StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-character-literals' - Enabled: false + Enabled: true Style/ClassAndModuleCamelCase: Description: 'Use CamelCase for classes and modules.' StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#camelcase-classes' - Enabled: false + Enabled: true Style/ClassAndModuleChildren: Description: 'Checks style of children classes and modules.' @@ -124,7 +124,7 @@ Style/ClassMethods: Style/ClassVars: Description: 'Avoid the use of class variables.' StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-class-vars' - Enabled: false + Enabled: true Style/ColonMethodCall: Description: 'Do not use :: for method call.' @@ -140,12 +140,12 @@ Style/CommentAnnotation: Style/CommentIndentation: Description: 'Indentation of comments.' - Enabled: false + Enabled: true Style/ConstantName: Description: 'Constants should use SCREAMING_SNAKE_CASE.' StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#screaming-snake-case' - Enabled: false + Enabled: true Style/DefWithParentheses: Description: 'Use def with parentheses when there are arguments.' @@ -177,7 +177,7 @@ Style/EachWithObject: Style/ElseAlignment: Description: 'Align elses and elsifs correctly.' - Enabled: false + Enabled: true Style/EmptyElse: Description: 'Avoid empty else-clauses.' @@ -283,12 +283,12 @@ Style/IfWithSemicolon: Style/IndentationConsistency: Description: 'Keep indentation straight.' - Enabled: false + Enabled: true Style/IndentationWidth: Description: 'Use 2 spaces for indentation.' StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#spaces-indentation' - Enabled: false + Enabled: true Style/IndentArray: Description: >- @@ -657,7 +657,7 @@ Style/Tab: Style/TrailingBlankLines: Description: 'Checks trailing blank lines and final newline.' StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#newline-eof' - Enabled: false + Enabled: true Style/TrailingComma: Description: 'Checks for trailing comma in parameter lists and literals.' @@ -909,7 +909,7 @@ Lint/StringConversionInInterpolation: Lint/UnderscorePrefixedVariableName: Description: 'Do not use prefix `_` for a variable that is used.' - Enabled: false + Enabled: true Lint/UnusedBlockArgument: Description: 'Checks for unused block arguments.' @@ -966,11 +966,11 @@ Rails/Delegate: Rails/HasAndBelongsToMany: Description: 'Prefer has_many :through to has_and_belongs_to_many.' - Enabled: false + Enabled: true Rails/Output: Description: 'Checks for calls to puts, print, etc.' - Enabled: false + Enabled: true Rails/ReadWriteAttribute: Description: >- @@ -991,6 +991,7 @@ Rails/Validation: # # AllCops: + RunRailsCops: true Exclude: - 'spec/**/*' - 'features/**/*' @@ -1000,3 +1001,6 @@ AllCops: - 'bin/**/*' - 'lib/backup/**/*' - 'lib/tasks/**/*' + - 'lib/email_validator.rb' + - 'lib/gitlab/upgrader.rb' + - 'lib/gitlab/seeder.rb' diff --git a/app/controllers/namespaces_controller.rb b/app/controllers/namespaces_controller.rb index c59a2401cefa36351745da02591a50bfa845204e..b7a9d8c12912711862fe6a362b3e2a3eb2916b4d 100644 --- a/app/controllers/namespaces_controller.rb +++ b/app/controllers/namespaces_controller.rb @@ -15,4 +15,3 @@ class NamespacesController < ApplicationController end end end - diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb index b471d57f6980dc595b408e9efc783be62c7c98a1..dccb96ba1d1f60e8943006481e4bcf0b1fddb184 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/controllers/projects/raw_controller.rb b/app/controllers/projects/raw_controller.rb index 84888265dc163fc3eb7e5bbb70a628cbb92bdafe..c4ddc32e8c38099287d41a937cccbd36e88c424e 100644 --- a/app/controllers/projects/raw_controller.rb +++ b/app/controllers/projects/raw_controller.rb @@ -35,4 +35,3 @@ class Projects::RawController < Projects::ApplicationController end end end - diff --git a/app/controllers/projects/refs_controller.rb b/app/controllers/projects/refs_controller.rb index cede0ebe0ae7934f0f1873d660d2e7d42f463c27..b80472f8eb49c76a71ff0523484dd4606239fef5 100644 --- a/app/controllers/projects/refs_controller.rb +++ b/app/controllers/projects/refs_controller.rb @@ -31,10 +31,10 @@ class Projects::RefsController < Projects::ApplicationController def logs_tree @offset = if params[:offset].present? - params[:offset].to_i - else - 0 - end + params[:offset].to_i + else + 0 + end @limit = 25 diff --git a/app/controllers/projects/wikis_controller.rb b/app/controllers/projects/wikis_controller.rb index 0e03956e7382bf24bb402e38a4cd0e3b6b43aeb0..0145207bf6f6c121176ce6beb78673b1e2d86c1d 100644 --- a/app/controllers/projects/wikis_controller.rb +++ b/app/controllers/projects/wikis_controller.rb @@ -16,16 +16,16 @@ class Projects::WikisController < Projects::ApplicationController if @page render 'show' elsif file = @project_wiki.find_file(params[:id], params[:version_id]) - if file.on_disk? - send_file file.on_disk_path, disposition: 'inline' - else - send_data( - file.raw_data, - type: file.mime_type, - disposition: 'inline', - filename: file.name - ) - end + if file.on_disk? + send_file file.on_disk_path, disposition: 'inline' + else + send_data( + file.raw_data, + type: file.mime_type, + disposition: 'inline', + filename: file.name + ) + end else return render('empty') unless can?(current_user, :write_wiki, @project) @page = WikiPage.new(@project_wiki) diff --git a/app/finders/notes_finder.rb b/app/finders/notes_finder.rb index bef82d7f0fdf23571e40242dbeaa274792eede58..6fe15b410605a93fdb836edb08512f36b0b15d84 100644 --- a/app/finders/notes_finder.rb +++ b/app/finders/notes_finder.rb @@ -7,18 +7,19 @@ class NotesFinder # Default to 0 to remain compatible with old clients last_fetched_at = Time.at(params.fetch(:last_fetched_at, 0).to_i) - notes = case target_type - when "commit" - project.notes.for_commit_id(target_id).not_inline.fresh - when "issue" - project.issues.find(target_id).notes.inc_author.fresh - when "merge_request" - project.merge_requests.find(target_id).mr_and_commit_notes.inc_author.fresh - when "snippet", "project_snippet" - project.snippets.find(target_id).notes.fresh - else - raise 'invalid target_type' - end + notes = + case target_type + when "commit" + project.notes.for_commit_id(target_id).not_inline.fresh + when "issue" + project.issues.find(target_id).notes.inc_author.fresh + when "merge_request" + project.merge_requests.find(target_id).mr_and_commit_notes.inc_author.fresh + when "snippet", "project_snippet" + project.snippets.find(target_id).notes.fresh + else + raise 'invalid target_type' + end # Use overlapping intervals to avoid worrying about race conditions notes.where('updated_at > ?', last_fetched_at - FETCH_OVERLAP) diff --git a/app/finders/snippets_finder.rb b/app/finders/snippets_finder.rb index 4b0c69f2d2f91cf80c31a02e0bd685854eb72be3..07b5759443b2cf8346cc34f3858b3196bfa87d8b 100644 --- a/app/finders/snippets_finder.rb +++ b/app/finders/snippets_finder.rb @@ -40,7 +40,7 @@ class SnippetsFinder when 'are_public' then snippets.are_public else - snippets + snippets end else snippets.public_and_internal diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index d00f1aac2d69a03cc1a7b02e8aa59c74151822d3..1fbb44ee4422ca85bf1aa02b55e15e2b27670b4e 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -75,10 +75,10 @@ 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 - project.name[0, 1].upcase + content_tag(:div, class: options[:class], style: style) do + project.name[0, 1].upcase end end diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb index 1a322ac048f5a9aee8147485220da9dfb68e75a7..b4ba14160edb320fdfaa0f55cbd1fc51863b3607 100644 --- a/app/helpers/commits_helper.rb +++ b/app/helpers/commits_helper.rb @@ -112,12 +112,13 @@ module CommitsHelper person_name = user.nil? ? source_name : user.name person_email = user.nil? ? source_email : user.email - text = if options[:avatar] - avatar = image_tag(avatar_icon(person_email, options[:size]), class: "avatar #{"s#{options[:size]}" if options[:size]}", width: options[:size], alt: "") - %Q{#{avatar} <span class="commit-#{options[:source]}-name">#{person_name}</span>} - else - person_name - end + text = + if options[:avatar] + avatar = image_tag(avatar_icon(person_email, options[:size]), class: "avatar #{"s#{options[:size]}" if options[:size]}", width: options[:size], alt: "") + %Q{#{avatar} <span class="commit-#{options[:source]}-name">#{person_name}</span>} + else + person_name + end options = { class: "commit-#{options[:source]}-link has_tooltip", diff --git a/app/helpers/notes_helper.rb b/app/helpers/notes_helper.rb index d41d56173969efb9698eb147e6e7659983bb88d9..8edcb8e6a80b2fa2ab20dab417c1e420cb6084d4 100644 --- a/app/helpers/notes_helper.rb +++ b/app/helpers/notes_helper.rb @@ -1,5 +1,5 @@ module NotesHelper - # Helps to distinguish e.g. commit notes in mr notes list + # Helps to distinguish e.g. commit notes in mr notes list def note_for_main_target?(note) (@noteable.class.name == note.noteable_type && !note.for_diff_line?) end diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 687b087e683b8e72cc89b3218bb2e7cca6c355ce..5cec6ae99d87d3223c4fd74de6c80b30b0d274e3 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -254,4 +254,3 @@ module ProjectsHelper enabled_oauth_providers.include?(:github) end end - diff --git a/app/helpers/tab_helper.rb b/app/helpers/tab_helper.rb index 639fc98c2224fc3dd3801b8b573f39794d379994..2142db29925fecb80b7e3ea6ffbbcd6993fd117e 100644 --- a/app/helpers/tab_helper.rb +++ b/app/helpers/tab_helper.rb @@ -90,7 +90,7 @@ module TabHelper return "active" if current_page?(controller: "/projects", action: :edit, id: @project) if ['services', 'hooks', 'deploy_keys', 'team_members', 'protected_branches'].include? controller.controller_name - "active" + "active" end end diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index 45ae79a75cc5ce65284d880c09921c930603c78a..0b3d430add0a387d9b420e548060bcb57a4e4cb3 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/commit.rb b/app/models/commit.rb index baccf28674012b7675fde49d5bba149642cf6325..e0461809e1007fa3608e375302697291c8955488 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -88,11 +88,12 @@ class Commit # cut off, ellipses (`&hellp;`) are prepended to the commit message. def description title_end = safe_message.index("\n") - @description ||= if (!title_end && safe_message.length > 100) || (title_end && title_end > 100) - "…".html_safe << safe_message[80..-1] - else - safe_message.split("\n", 2)[1].try(:chomp) - end + @description ||= + if (!title_end && safe_message.length > 100) || (title_end && title_end > 100) + "…".html_safe << safe_message[80..-1] + else + safe_message.split("\n", 2)[1].try(:chomp) + end end def description? diff --git a/app/models/namespace.rb b/app/models/namespace.rb index ea4b48fdd7f97df2774852d8dd9bebb67ba3268c..e7fd3024750cf6ebb44e8c9adfa5bc06ad6c1eec 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 f314ed9bd2582975cb1e92a308ed8fdfe8af6e98..cfe40553ab5c9c0e76782eac81e25e39acdaeef4 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 16e1b83da4ba5e56bc81eedd1c8244e7deeed30d..745609e59110add9b2559f8dd163ee4741edffa4 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 dca718b5e8c556c946a79e380f8f32e3efae63d6..287f5c0e84ed0b3d0aa7f8f829fea1cdffc2ed2d 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 9aba42a062264ae1e723b20948c5a0c89151ed43..a3222d298922d084745ce26a7470fd5a284879b1 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 27724b3ccba97b2ace6b79994459ed7e6d4cff95..552a37c95337fb1eba1839f8b03ffa2ea83539e2 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/app/models/wiki_page.rb b/app/models/wiki_page.rb index b9ab6702c539faa2a24a80216d06a0151a281056..32981a0e664be3a917c8ae7eecdb7b546e673723 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -43,7 +43,7 @@ class WikiPage @attributes[:slug] end - alias :to_param :slug + alias_method :to_param, :slug # The formatted title of this page. def title diff --git a/app/services/oauth2/access_token_validation_service.rb b/app/services/oauth2/access_token_validation_service.rb index 5a3b94129f128ad6983f71bc6328626b176c5f46..6194f6ce91eb334c30a14e9beba31cd63e4060ec 100644 --- a/app/services/oauth2/access_token_validation_service.rb +++ b/app/services/oauth2/access_token_validation_service.rb @@ -38,4 +38,4 @@ module Oauth2::AccessTokenValidationService end end end -end \ No newline at end of file +end diff --git a/app/services/projects/image_service.rb b/app/services/projects/image_service.rb index c79ddddd972003fbfb3ec730449ddc9af165f69f..7ca7e82c4a3f1479aa9982e35bbff5730a10a5c6 100644 --- a/app/services/projects/image_service.rb +++ b/app/services/projects/image_service.rb @@ -14,14 +14,14 @@ module Projects uploader.store!(image) link = { 'alt' => File.basename(alt, '.*'), - 'url' => File.join(@root_url, uploader.url) + 'url' => File.join(@root_url, uploader.url) } else link = nil end end - protected + protected def upload_path base_dir = FileUploader.generate_dir diff --git a/app/services/projects/participants_service.rb b/app/services/projects/participants_service.rb index c4d2c0963b783e329ed24303a560240e3d9e9e6a..e3b33de8d02727ab38ad1c585461a809cc48883a 100644 --- a/app/services/projects/participants_service.rb +++ b/app/services/projects/participants_service.rb @@ -5,11 +5,12 @@ module Projects end def execute(note_type, note_id) - participating = if note_type && note_id - participants_in(note_type, note_id) - else - [] - end + participating = + if note_type && note_id + participants_in(note_type, note_id) + else + [] + end team_members = sorted(@project.team.members) participants = all_members + team_members + participating participants.uniq diff --git a/config/initializers/7_omniauth.rb b/config/initializers/7_omniauth.rb index 18759f0cfb0923bb97e4bc1013c8482f75e40875..8f6c5673103de9d4feea06b2b42be6aa37130120 100644 --- a/config/initializers/7_omniauth.rb +++ b/config/initializers/7_omniauth.rb @@ -9,4 +9,4 @@ if Gitlab::LDAP::Config.enabled? server = Gitlab.config.ldap.servers.values.first alias_method server['provider_name'], :ldap end -end \ No newline at end of file +end diff --git a/config/initializers/acts_as_taggable_on_patch.rb b/config/initializers/acts_as_taggable_on_patch.rb index baa77fde392b45754d5d94bf17079d63124125ba..0d535cb5cac5a2bd11f877f5cdbda1576442e5c7 100644 --- a/config/initializers/acts_as_taggable_on_patch.rb +++ b/config/initializers/acts_as_taggable_on_patch.rb @@ -42,11 +42,12 @@ module ActsAsTaggableOn::Taggable elsif options.delete(:any) # get tags, drop out if nothing returned (we need at least one) - tags = if options.delete(:wild) - ActsAsTaggableOn::Tag.named_like_any(tag_list) - else - ActsAsTaggableOn::Tag.named_any(tag_list) - end + tags = + if options.delete(:wild) + ActsAsTaggableOn::Tag.named_like_any(tag_list) + else + ActsAsTaggableOn::Tag.named_any(tag_list) + end return empty_result unless tags.length > 0 @@ -68,12 +69,12 @@ module ActsAsTaggableOn::Taggable select_clause = "DISTINCT #{table_name}.*" unless context and tag_types.one? if owned_by - tagging_join << " AND " + - sanitize_sql([ - "#{taggings_alias}.tagger_id = ? AND #{taggings_alias}.tagger_type = ?", - owned_by.id, - owned_by.class.base_class.to_s - ]) + tagging_join << " AND " + + sanitize_sql([ + "#{taggings_alias}.tagger_id = ? AND #{taggings_alias}.tagger_type = ?", + owned_by.id, + owned_by.class.base_class.to_s + ]) end joins << tagging_join @@ -92,12 +93,12 @@ module ActsAsTaggableOn::Taggable tagging_join << " AND " + sanitize_sql(["#{taggings_alias}.context = ?", context.to_s]) if context if owned_by - tagging_join << " AND " + - sanitize_sql([ - "#{taggings_alias}.tagger_id = ? AND #{taggings_alias}.tagger_type = ?", - owned_by.id, - owned_by.class.base_class.to_s - ]) + tagging_join << " AND " + + sanitize_sql([ + "#{taggings_alias}.tagger_id = ? AND #{taggings_alias}.tagger_type = ?", + owned_by.id, + owned_by.class.base_class.to_s + ]) end joins << tagging_join diff --git a/config/initializers/carrierwave.rb b/config/initializers/carrierwave.rb index 667f198667cba6fb2551fb970e07d9eaa0efb60a..bfb8656df552da088bf7848deaa77540945bead2 100644 --- a/config/initializers/carrierwave.rb +++ b/config/initializers/carrierwave.rb @@ -12,11 +12,19 @@ if File.exists?(aws_file) aws_secret_access_key: AWS_CONFIG['secret_access_key'], # required region: AWS_CONFIG['region'], # optional, defaults to 'us-east-1' } - config.fog_directory = AWS_CONFIG['bucket'] # required - config.fog_public = false # optional, defaults to true - config.fog_attributes = { 'Cache-Control'=>'max-age=315576000' } # optional, defaults to {} - config.fog_authenticated_url_expiration = 1 << 29 # optional time (in seconds) that authenticated urls will be valid. - # when fog_public is false and provider is AWS or Google, defaults to 600 + + # required + config.fog_directory = AWS_CONFIG['bucket'] + + # optional, defaults to true + config.fog_public = false + + # optional, defaults to {} + config.fog_attributes = { 'Cache-Control'=>'max-age=315576000' } + + # optional time (in seconds) that authenticated urls will be valid. + # when fog_public is false and provider is AWS or Google, defaults to 600 + config.fog_authenticated_url_expiration = 1 << 29 end # Mocking Fog requests, based on: https://github.com/carrierwaveuploader/carrierwave/wiki/How-to%3A-Test-Fog-based-uploaders diff --git a/config/initializers/gitlab_shell_secret_token.rb b/config/initializers/gitlab_shell_secret_token.rb index 8d2b771e53590b3abb9133df0475133ba4e5bf7c..e7c9f0ba7c2b8025bcc520cc307c5e05edd3a01b 100644 --- a/config/initializers/gitlab_shell_secret_token.rb +++ b/config/initializers/gitlab_shell_secret_token.rb @@ -16,4 +16,4 @@ end if File.exist?(Gitlab.config.gitlab_shell.path) && !File.exist?(gitlab_shell_symlink) FileUtils.symlink(secret_file, gitlab_shell_symlink) -end \ No newline at end of file +end diff --git a/config/routes.rb b/config/routes.rb index a83c112a882c0331db75c1b1fb936cd32e17df48..a2d782cf633dc30b1e130bfc4276b91e26096877 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/api/api_guard.rb b/lib/api/api_guard.rb index be3d053efca6c1d9958841cc060fb5a83e35126f..b9994fcefdaba024913d585c7d319bc978022ec5 100644 --- a/lib/api/api_guard.rb +++ b/lib/api/api_guard.rb @@ -47,16 +47,12 @@ module APIGuard case validate_access_token(access_token, scopes) when Oauth2::AccessTokenValidationService::INSUFFICIENT_SCOPE raise InsufficientScopeError.new(scopes) - when Oauth2::AccessTokenValidationService::EXPIRED raise ExpiredError - when Oauth2::AccessTokenValidationService::REVOKED raise RevokedError - when Oauth2::AccessTokenValidationService::VALID @current_user = User.find(access_token.resource_owner_id) - end end end @@ -120,8 +116,9 @@ module APIGuard end def oauth2_bearer_token_error_handler - Proc.new {|e| - response = case e + Proc.new do |e| + response = + case e when MissingTokenError Rack::OAuth2::Server::Resource::Bearer::Unauthorized.new @@ -150,7 +147,7 @@ module APIGuard end response.finish - } + end end end diff --git a/lib/api/internal.rb b/lib/api/internal.rb index a999cff09c045da463c21340872c7a21728943f9..7a89a26facc8d8f974b12c19bdda5811de3f51d8 100644 --- a/lib/api/internal.rb +++ b/lib/api/internal.rb @@ -1,9 +1,7 @@ module API # Internal access API class Internal < Grape::API - before { - authenticate_by_gitlab_shell_token! - } + before { authenticate_by_gitlab_shell_token! } namespace 'internal' do # Check if git command is allowed to project diff --git a/lib/api/namespaces.rb b/lib/api/namespaces.rb index f9f2ed90ccc357ca49d1e0a436411f73b0888463..b90ed6af5fbe6e32f92a65e57df72f3a34d49c22 100644 --- a/lib/api/namespaces.rb +++ b/lib/api/namespaces.rb @@ -1,10 +1,10 @@ module API # namespaces API class Namespaces < Grape::API - before { + before do authenticate! authenticated_as_admin! - } + end resource :namespaces do # Get a namespaces list diff --git a/lib/api/system_hooks.rb b/lib/api/system_hooks.rb index 3e239c5afe773502151d31ae109f31fd6934abc6..518964db50d3739a5472771b9f1f3a8e0ab9b1e4 100644 --- a/lib/api/system_hooks.rb +++ b/lib/api/system_hooks.rb @@ -1,10 +1,10 @@ module API # Hooks API class SystemHooks < Grape::API - before { + before do authenticate! authenticated_as_admin! - } + end resource :hooks do # Get the list of system hooks diff --git a/lib/email_validator.rb b/lib/email_validator.rb index 0a67ebcd7959672cd617603235ae544dc84b5a5b..f509f0a584336fc0b3a1a5cccd36477eeb4c7fd4 100644 --- a/lib/email_validator.rb +++ b/lib/email_validator.rb @@ -1,5 +1,5 @@ # Based on https://github.com/balexand/email_validator -# +# # Extended to use only strict mode with following allowed characters: # ' - apostrophe # diff --git a/lib/gitlab/backend/shell_adapter.rb b/lib/gitlab/backend/shell_adapter.rb index f247f4593d7ffc8f1e2211245033b75a24d5fa16..fbe2a7a0d721ad474e85c72090c8b6431ce386da 100644 --- a/lib/gitlab/backend/shell_adapter.rb +++ b/lib/gitlab/backend/shell_adapter.rb @@ -9,4 +9,3 @@ module Gitlab end end end - diff --git a/lib/gitlab/diff/parser.rb b/lib/gitlab/diff/parser.rb index f7c1f20d76295e3b2147f1a38203bd9e059f811f..887ed76b36c6822cedbaf9c6f8d2b6cf52412196 100644 --- a/lib/gitlab/diff/parser.rb +++ b/lib/gitlab/diff/parser.rb @@ -4,7 +4,7 @@ module Gitlab include Enumerable def parse(lines) - @lines = lines, + @lines = lines lines_obj = [] line_obj_index = 0 line_old = 1 @@ -74,7 +74,7 @@ module Gitlab def html_escape(str) replacements = { '&' => '&', '>' => '>', '<' => '<', '"' => '"', "'" => ''' } - str.gsub(/[&"'><]/, replacements) + str.gsub(/[&"'><]/, replacements) end end end diff --git a/lib/gitlab/force_push_check.rb b/lib/gitlab/force_push_check.rb index 6ba2c3ad00a52b4c76233714049d1cf01bdb3a72..eae9773a067d4887f9565761589f556745830798 100644 --- a/lib/gitlab/force_push_check.rb +++ b/lib/gitlab/force_push_check.rb @@ -12,4 +12,3 @@ module Gitlab end end end - diff --git a/lib/gitlab/git_access.rb b/lib/gitlab/git_access.rb index ea96d04c5aba4c02ccf9fea7044ee4782a94bc47..6444cec7eb5d204bee6e407ffba01009b996fe31 100644 --- a/lib/gitlab/git_access.rb +++ b/lib/gitlab/git_access.rb @@ -112,14 +112,14 @@ module Gitlab def protected_branch_action(project, oldrev, newrev, branch_name) # we dont allow force push to protected branch if forced_push?(project, oldrev, newrev) - :force_push_code_to_protected_branches - # and we dont allow remove of protected branch + :force_push_code_to_protected_branches elsif newrev == Gitlab::Git::BLANK_SHA - :remove_protected_branches + # and we dont allow remove of protected branch + :remove_protected_branches elsif project.developers_can_push_to_protected_branch?(branch_name) - :push_code + :push_code else - :push_code_to_protected_branches + :push_code_to_protected_branches end end diff --git a/lib/gitlab/ldap/adapter.rb b/lib/gitlab/ldap/adapter.rb index 256cdb4c2f10928e35e25c8890532df43127636d..577a890a7d9879f8cc9f51a454644757c1dd6ff6 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)