BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
181cd299
Commit
181cd299
authored
Nov 14, 2017
by
Jacopo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds Rubocop rule for line break after guard clause
Adds a rubocop rule (with autocorrect) to ensure line break after guard clauses.
parent
f2997af4
Hide whitespace changes
Inline
Side-by-side
Showing
113 changed files
with
410 additions
and
0 deletions
+410
-0
application_controller.rb
app/controllers/application_controller.rb
+1
-0
autocomplete_controller.rb
app/controllers/autocomplete_controller.rb
+2
-0
gitlab_projects_controller.rb
app/controllers/import/gitlab_projects_controller.rb
+1
-0
deployments_controller.rb
app/controllers/projects/deployments_controller.rb
+1
-0
group_links_controller.rb
app/controllers/projects/group_links_controller.rb
+1
-0
issues_controller.rb
app/controllers/projects/issues_controller.rb
+1
-0
labels_controller.rb
app/controllers/projects/labels_controller.rb
+1
-0
lfs_storage_controller.rb
app/controllers/projects/lfs_storage_controller.rb
+1
-0
notes_controller.rb
app/controllers/projects/notes_controller.rb
+1
-0
wikis_controller.rb
app/controllers/projects/wikis_controller.rb
+1
-0
projects_controller.rb
app/controllers/projects_controller.rb
+1
-0
personal_access_tokens_finder.rb
app/finders/personal_access_tokens_finder.rb
+1
-0
diff_helper.rb
app/helpers/diff_helper.rb
+1
-0
emails_helper.rb
app/helpers/emails_helper.rb
+1
-0
markup_helper.rb
app/helpers/markup_helper.rb
+1
-0
notifications_helper.rb
app/helpers/notifications_helper.rb
+1
-0
tree_helper.rb
app/helpers/tree_helper.rb
+1
-0
visibility_level_helper.rb
app/helpers/visibility_level_helper.rb
+2
-0
build.rb
app/models/ci/build.rb
+1
-0
pipeline.rb
app/models/ci/pipeline.rb
+2
-0
gcp.rb
app/models/clusters/providers/gcp.rb
+1
-0
awardable.rb
app/models/concerns/awardable.rb
+1
-0
pages_domain.rb
app/models/pages_domain.rb
+5
-0
hipchat_service.rb
app/models/project_services/hipchat_service.rb
+2
-0
jira_service.rb
app/models/project_services/jira_service.rb
+1
-0
kubernetes_service.rb
app/models/project_services/kubernetes_service.rb
+1
-0
repository.rb
app/models/repository.rb
+2
-0
user.rb
app/models/user.rb
+2
-0
fetch_kubernetes_token_service.rb
app/services/ci/fetch_kubernetes_token_service.rb
+1
-0
promote_service.rb
app/services/labels/promote_service.rb
+1
-0
build_service.rb
app/services/merge_requests/build_service.rb
+1
-0
destroy_service.rb
app/services/projects/group_links/destroy_service.rb
+1
-0
todo_service.rb
app/services/todo_service.rb
+1
-0
certificate_key_validator.rb
app/validators/certificate_key_validator.rb
+1
-0
certificate_validator.rb
app/validators/certificate_validator.rb
+1
-0
irker_worker.rb
app/workers/irker_worker.rb
+1
-0
stuck_ci_jobs_worker.rb
app/workers/stuck_ci_jobs_worker.rb
+1
-0
18040-rubocop-line-break-after-guard-clause.yml
...nreleased/18040-rubocop-line-break-after-guard-clause.yml
+5
-0
ar5_batching.rb
config/initializers/ar5_batching.rb
+1
-0
devise.rb
config/initializers/devise.rb
+1
-0
omniauth.rb
config/initializers/omniauth.rb
+1
-0
postgresql_cte.rb
config/initializers/postgresql_cte.rb
+2
-0
20170919211300_remove_temporary_ci_builds_index.rb
...igrate/20170919211300_remove_temporary_ci_builds_index.rb
+1
-0
20170406111121_clean_upload_symlinks.rb
db/post_migrate/20170406111121_clean_upload_symlinks.rb
+1
-0
20170612071012_move_personal_snippets_files.rb
...st_migrate/20170612071012_move_personal_snippets_files.rb
+1
-0
20170613111224_clean_appearance_symlinks.rb
db/post_migrate/20170613111224_clean_appearance_symlinks.rb
+1
-0
commits.rb
lib/api/commits.rb
+2
-0
custom_validators.rb
lib/api/helpers/custom_validators.rb
+1
-0
runner.rb
lib/api/helpers/runner.rb
+1
-0
runners.rb
lib/api/runners.rb
+4
-0
snippets.rb
lib/api/snippets.rb
+1
-0
commits.rb
lib/api/v3/commits.rb
+2
-0
runners.rb
lib/api/v3/runners.rb
+1
-0
snippets.rb
lib/api/v3/snippets.rb
+2
-0
object_renderer.rb
lib/banzai/object_renderer.rb
+1
-0
querying.rb
lib/banzai/querying.rb
+2
-0
user_parser.rb
lib/banzai/reference_parser/user_parser.rb
+1
-0
renderer.rb
lib/banzai/renderer.rb
+2
-0
declarative_policy.rb
lib/declarative_policy.rb
+2
-0
base.rb
lib/declarative_policy/base.rb
+2
-0
cache.rb
lib/declarative_policy/cache.rb
+2
-0
rule.rb
lib/declarative_policy/rule.rb
+5
-0
runner.rb
lib/declarative_policy/runner.rb
+1
-0
file_size_validator.rb
lib/file_size_validator.rb
+1
-0
changes_list.rb
lib/gitlab/changes_list.rb
+1
-0
metadata.rb
lib/gitlab/ci/build/artifacts/metadata.rb
+1
-0
entry.rb
lib/gitlab/ci/build/artifacts/metadata/entry.rb
+3
-0
image.rb
lib/gitlab/ci/build/image.rb
+1
-0
image.rb
lib/gitlab/ci/config/entry/image.rb
+1
-0
validators.rb
lib/gitlab/ci/config/entry/validators.rb
+1
-0
daemon.rb
lib/gitlab/daemon.rb
+1
-0
inline_diff.rb
lib/gitlab/diff/inline_diff.rb
+1
-0
parser.rb
lib/gitlab/diff/parser.rb
+1
-0
position.rb
lib/gitlab/diff/position.rb
+1
-0
unsubscribe_handler.rb
lib/gitlab/email/handler/unsubscribe_handler.rb
+1
-0
client.rb
lib/gitlab/fogbugz_import/client.rb
+1
-0
importer.rb
lib/gitlab/fogbugz_import/importer.rb
+2
-0
blob.rb
lib/gitlab/git/blob.rb
+1
-0
repository.rb
lib/gitlab/git/repository.rb
+3
-0
ref_service.rb
lib/gitlab/gitaly_client/ref_service.rb
+1
-0
wiki_service.rb
lib/gitlab/gitaly_client/wiki_service.rb
+1
-0
client.rb
lib/gitlab/gitlab_import/client.rb
+1
-0
namespace.rb
lib/gitlab/kubernetes/namespace.rb
+1
-0
authentication.rb
lib/gitlab/ldap/authentication.rb
+1
-0
importer.rb
lib/gitlab/legacy_github_import/importer.rb
+1
-0
ruby_sampler.rb
lib/gitlab/metrics/samplers/ruby_sampler.rb
+1
-0
active_record.rb
lib/gitlab/metrics/subscribers/active_record.rb
+1
-0
go.rb
lib/gitlab/middleware/go.rb
+1
-0
optimistic_locking.rb
lib/gitlab/optimistic_locking.rb
+1
-0
user.rb
lib/gitlab/saml/user.rb
+1
-0
shell.rb
lib/gitlab/shell.rb
+1
-0
string_range_marker.rb
lib/gitlab/string_range_marker.rb
+1
-0
repo_template_finder.rb
lib/gitlab/template/finders/repo_template_finder.rb
+1
-0
url_sanitizer.rb
lib/gitlab/url_sanitizer.rb
+1
-0
visibility_level.rb
lib/gitlab/visibility_level.rb
+1
-0
workhorse.rb
lib/gitlab/workhorse.rb
+1
-0
inline_javascript.rb
lib/haml_lint/inline_javascript.rb
+1
-0
simple_executor.rb
lib/system_check/simple_executor.rb
+1
-0
cleanup.rake
lib/tasks/gitlab/cleanup.rake
+2
-0
entry.rb
qa/qa/page/main/entry.rb
+1
-0
line_break_after_guard_clauses.rb
rubocop/cop/line_break_after_guard_clauses.rb
+100
-0
rubocop.rb
rubocop/rubocop.rb
+1
-0
notes.rb
spec/factories/notes.rb
+1
-0
diff_collection_spec.rb
spec/lib/gitlab/git/diff_collection_spec.rb
+1
-0
flowdock_service_spec.rb
spec/models/project_services/flowdock_service_spec.rb
+1
-0
projects_spec.rb
spec/requests/api/projects_spec.rb
+2
-0
projects_spec.rb
spec/requests/api/v3/projects_spec.rb
+2
-0
line_break_after_guard_clauses_spec.rb
spec/rubocop/cop/line_break_after_guard_clauses_spec.rb
+160
-0
notification_service_spec.rb
spec/services/notification_service_spec.rb
+2
-0
fixture_helpers.rb
spec/support/fixture_helpers.rb
+1
-0
generate-seed-repo-rb
spec/support/generate-seed-repo-rb
+1
-0
gitaly.rb
spec/support/gitaly.rb
+1
-0
unicorn_spec.rb
spec/unicorn/unicorn_spec.rb
+1
-0
No files found.
app/controllers/application_controller.rb
View file @
181cd299
...
...
@@ -97,6 +97,7 @@ class ApplicationController < ActionController::Base
# (e.g. tokens) to authenticate the user, whereas Devise sets current_user
def
auth_user
return
current_user
if
current_user
.
present?
return
try
(
:authenticated_user
)
end
...
...
app/controllers/autocomplete_controller.rb
View file @
181cd299
...
...
@@ -44,6 +44,7 @@ class AutocompleteController < ApplicationController
if
@project
.
blank?
&&
params
[
:group_id
].
present?
group
=
Group
.
find
(
params
[
:group_id
])
return
render_404
unless
can?
(
current_user
,
:read_group
,
group
)
group
end
end
...
...
@@ -54,6 +55,7 @@ class AutocompleteController < ApplicationController
if
params
[
:project_id
].
present?
project
=
Project
.
find
(
params
[
:project_id
])
return
render_404
unless
can?
(
current_user
,
:read_project
,
project
)
project
end
end
...
...
app/controllers/import/gitlab_projects_controller.rb
View file @
181cd299
...
...
@@ -4,6 +4,7 @@ class Import::GitlabProjectsController < Import::BaseController
def
new
@namespace
=
Namespace
.
find
(
project_params
[
:namespace_id
])
return
render_404
unless
current_user
.
can?
(
:create_projects
,
@namespace
)
@path
=
project_params
[
:path
]
end
...
...
app/controllers/projects/deployments_controller.rb
View file @
181cd299
...
...
@@ -12,6 +12,7 @@ class Projects::DeploymentsController < Projects::ApplicationController
def
metrics
return
render_404
unless
deployment
.
has_metrics?
@metrics
=
deployment
.
metrics
if
@metrics
&
.
any?
render
json:
@metrics
,
status: :ok
...
...
app/controllers/projects/group_links_controller.rb
View file @
181cd299
...
...
@@ -12,6 +12,7 @@ class Projects::GroupLinksController < Projects::ApplicationController
if
group
return
render_404
unless
can?
(
current_user
,
:read_group
,
group
)
Projects
::
GroupLinks
::
CreateService
.
new
(
project
,
current_user
,
group_link_create_params
).
execute
(
group
)
else
flash
[
:alert
]
=
'Please select a group.'
...
...
app/controllers/projects/issues_controller.rb
View file @
181cd299
...
...
@@ -171,6 +171,7 @@ class Projects::IssuesController < Projects::ApplicationController
def
issue
return
@issue
if
defined?
(
@issue
)
# The Sortable default scope causes performance issues when used with find_by
@issuable
=
@noteable
=
@issue
||=
@project
.
issues
.
where
(
iid:
params
[
:id
]).
reorder
(
nil
).
take!
@note
=
@project
.
notes
.
new
(
noteable:
@issuable
)
...
...
app/controllers/projects/labels_controller.rb
View file @
181cd299
...
...
@@ -111,6 +111,7 @@ class Projects::LabelsController < Projects::ApplicationController
begin
return
render_404
unless
promote_service
.
execute
(
@label
)
respond_to
do
|
format
|
format
.
html
do
redirect_to
(
project_labels_path
(
@project
),
...
...
app/controllers/projects/lfs_storage_controller.rb
View file @
181cd299
...
...
@@ -54,6 +54,7 @@ class Projects::LfsStorageController < Projects::GitHttpClientController
name
=
request
.
headers
[
'X-Gitlab-Lfs-Tmp'
]
return
if
name
.
include?
(
'/'
)
return
unless
oid
.
present?
&&
name
.
start_with?
(
oid
)
name
end
...
...
app/controllers/projects/notes_controller.rb
View file @
181cd299
...
...
@@ -76,6 +76,7 @@ class Projects::NotesController < Projects::ApplicationController
def
authorize_create_note!
return
unless
noteable
.
lockable?
access_denied!
unless
can?
(
current_user
,
:create_note
,
noteable
)
end
end
app/controllers/projects/wikis_controller.rb
View file @
181cd299
...
...
@@ -28,6 +28,7 @@ class Projects::WikisController < Projects::ApplicationController
)
else
return
render
(
'empty'
)
unless
can?
(
current_user
,
:create_wiki
,
@project
)
@page
=
WikiPage
.
new
(
@project_wiki
)
@page
.
title
=
params
[
:id
]
...
...
app/controllers/projects_controller.rb
View file @
181cd299
...
...
@@ -269,6 +269,7 @@ class ProjectsController < Projects::ApplicationController
def
render_landing_page
if
can?
(
current_user
,
:download_code
,
@project
)
return
render
'projects/no_repo'
unless
@project
.
repository_exists?
render
'projects/empty'
if
@project
.
empty_repo?
else
if
@project
.
wiki_enabled?
...
...
app/finders/personal_access_tokens_finder.rb
View file @
181cd299
...
...
@@ -18,6 +18,7 @@ class PersonalAccessTokensFinder
def
by_user
(
tokens
)
return
tokens
unless
@params
[
:user
]
tokens
.
where
(
user:
@params
[
:user
])
end
...
...
app/helpers/diff_helper.rb
View file @
181cd299
...
...
@@ -111,6 +111,7 @@ module DiffHelper
def
diff_file_old_blob_raw_path
(
diff_file
)
sha
=
diff_file
.
old_content_sha
return
unless
sha
project_raw_path
(
@project
,
tree_join
(
diff_file
.
old_content_sha
,
diff_file
.
old_path
))
end
...
...
app/helpers/emails_helper.rb
View file @
181cd299
...
...
@@ -24,6 +24,7 @@ module EmailsHelper
def
action_title
(
url
)
return
unless
url
%w(merge_requests issues commit)
.
each
do
|
action
|
if
url
.
split
(
"/"
).
include?
(
action
)
return
"View
#{
action
.
humanize
.
singularize
}
"
...
...
app/helpers/markup_helper.rb
View file @
181cd299
...
...
@@ -53,6 +53,7 @@ module MarkupHelper
# text, wrapping anything found in the requested link
fragment
.
children
.
each
do
|
node
|
next
unless
node
.
text?
node
.
replace
(
link_to
(
node
.
text
,
url
,
html_options
))
end
end
...
...
app/helpers/notifications_helper.rb
View file @
181cd299
...
...
@@ -78,6 +78,7 @@ module NotificationsHelper
# Create hidden field to send notification setting source to controller
def
hidden_setting_source_input
(
notification_setting
)
return
unless
notification_setting
.
source_type
hidden_field_tag
"
#{
notification_setting
.
source_type
.
downcase
}
_id"
,
notification_setting
.
source_id
end
...
...
app/helpers/tree_helper.rb
View file @
181cd299
...
...
@@ -88,6 +88,7 @@ module TreeHelper
part_path
=
part
if
part_path
.
empty?
next
if
parts
.
count
>
max_links
&&
!
parts
.
last
(
2
).
include?
(
part
)
yield
(
part
,
part_path
)
end
end
...
...
app/helpers/visibility_level_helper.rb
View file @
181cd299
...
...
@@ -150,6 +150,7 @@ module VisibilityLevelHelper
def
restricted_visibility_levels
(
show_all
=
false
)
return
[]
if
current_user
.
admin?
&&
!
show_all
current_application_settings
.
restricted_visibility_levels
||
[]
end
...
...
@@ -159,6 +160,7 @@ module VisibilityLevelHelper
def
disallowed_visibility_level?
(
form_model
,
level
)
return
false
unless
form_model
.
respond_to?
(
:visibility_level_allowed?
)
!
form_model
.
visibility_level_allowed?
(
level
)
end
...
...
app/models/ci/build.rb
View file @
181cd299
...
...
@@ -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
)
...
...
app/models/ci/pipeline.rb
View file @
181cd299
...
...
@@ -300,8 +300,10 @@ module Ci
def
latest?
return
false
unless
ref
commit
=
project
.
commit
(
ref
)
return
false
unless
commit
commit
.
sha
==
sha
end
...
...
app/models/clusters/providers/gcp.rb
View file @
181cd299
...
...
@@ -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
...
...
app/models/concerns/awardable.rb
View file @
181cd299
...
...
@@ -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
...
...
app/models/pages_domain.rb
View file @
181cd299
...
...
@@ -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
...
...
app/models/project_services/hipchat_service.rb
View file @
181cd299
...
...
@@ -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
...
...
app/models/project_services/jira_service.rb
View file @
181cd299
...
...
@@ -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
...
...
app/models/project_services/kubernetes_service.rb
View file @
181cd299
...
...
@@ -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
...
...
app/models/repository.rb
View file @
181cd299
...
...
@@ -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
...
...
app/models/user.rb
View file @
181cd299
...
...
@@ -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
...
...
app/services/ci/fetch_kubernetes_token_service.rb
View file @
181cd299
...
...
@@ -34,6 +34,7 @@ module Ci
kubeclient
.
get_secrets
.
as_json
rescue
KubeException
=>
err
raise
err
unless
err
.
error_code
==
404
[]
end
...
...
app/services/labels/promote_service.rb
View file @
181cd299
...
...
@@ -19,6 +19,7 @@ module Labels
# We skipped validations during creation. Let's run them now, after deleting conflicting labels
raise
ActiveRecord
::
RecordInvalid
.
new
(
new_label
)
unless
new_label
.
valid?
new_label
end
end
...
...
app/services/merge_requests/build_service.rb
View file @
181cd299
...
...
@@ -28,6 +28,7 @@ module MergeRequests
def
find_target_project
return
target_project
if
target_project
.
present?
&&
can?
(
current_user
,
:read_project
,
target_project
)
project
.
default_merge_request_target
end
...
...
app/services/projects/group_links/destroy_service.rb
View file @
181cd299
...
...
@@ -3,6 +3,7 @@ module Projects
class
DestroyService
<
BaseService
def
execute
(
group_link
)
return
false
unless
group_link
group_link
.
destroy
end
end
...
...
app/services/todo_service.rb
View file @
181cd299
...
...
@@ -208,6 +208,7 @@ class TodoService
def
create_todos
(
users
,
attributes
)
Array
(
users
).
map
do
|
user
|
next
if
pending_todos
(
user
,
attributes
).
exists?
todo
=
Todo
.
create
(
attributes
.
merge
(
user_id:
user
.
id
))
user
.
update_todos_count_cache
todo
...
...
app/validators/certificate_key_validator.rb
View file @
181cd299
...
...
@@ -17,6 +17,7 @@ class CertificateKeyValidator < ActiveModel::EachValidator
def
valid_private_key_pem?
(
value
)
return
false
unless
value
pkey
=
OpenSSL
::
PKey
::
RSA
.
new
(
value
)
pkey
.
private?
rescue
OpenSSL
::
PKey
::
PKeyError
...
...
app/validators/certificate_validator.rb
View file @
181cd299
...
...
@@ -17,6 +17,7 @@ class CertificateValidator < ActiveModel::EachValidator
def
valid_certificate_pem?
(
value
)
return
false
unless
value
OpenSSL
::
X509
::
Certificate
.
new
(
value
).
present?
rescue
OpenSSL
::
X509
::
CertificateError
false
...
...
app/workers/irker_worker.rb
View file @
181cd299
...
...
@@ -104,6 +104,7 @@ class IrkerWorker
parents
=
commit
.
parents
# Return old value if there's no new one
return
push_data
[
'before'
]
if
parents
.
empty?
# Or return the first parent-commit
parents
[
0
].
id
end
...
...
app/workers/stuck_ci_jobs_worker.rb
View file @
181cd299
...
...
@@ -39,6 +39,7 @@ class StuckCiJobsWorker
def
drop_stuck
(
status
,
timeout
)
search
(
status
,
timeout
)
do
|
build
|
return
unless
build
.
stuck?
drop_build
:stuck
,
build
,
status
,
timeout
end
end
...
...
changelogs/unreleased/18040-rubocop-line-break-after-guard-clause.yml
0 → 100644
View file @
181cd299
---
title
:
Adds Rubocop rule for line break after guard clause
merge_request
:
15188
author
:
Jacopo Beschi @jacopo-beschi
type
:
added
config/initializers/ar5_batching.rb
View file @
181cd299
...
...
@@ -34,6 +34,7 @@ module ActiveRecord
yield
yielded_relation
break
if
ids
.
length
<
of
batch_relation
=
relation
.
where
(
arel_table
[
primary_key
].
gt
(
primary_key_offset
))
end
end
...
...
config/initializers/devise.rb
View file @
181cd299
...
...
@@ -236,6 +236,7 @@ Devise.setup do |config|
provider
[
'args'
][
:on_single_sign_out
]
=
lambda
do
|
request
|
ticket
=
request
.
params
[
:session_index
]
raise
"Service Ticket not found."
unless
Gitlab
::
OAuth
::
Session
.
valid?
(
:cas3
,
ticket
)
Gitlab
::
OAuth
::
Session
.
destroy
(
:cas3
,
ticket
)
true
end
...
...
config/initializers/omniauth.rb
View file @
181cd299
...
...
@@ -3,6 +3,7 @@ if Gitlab::LDAP::Config.enabled?
Gitlab
::
LDAP
::
Config
.
available_servers
.
each
do
|
server
|
# do not redeclare LDAP
next
if
server
[
'provider_name'
]
==
'ldap'
const_set
(
server
[
'provider_class'
],
Class
.
new
(
LDAP
))
end
end
...
...
config/initializers/postgresql_cte.rb
View file @
181cd299
...
...
@@ -61,11 +61,13 @@ module ActiveRecord
def
with_values
=
(
values
)
raise
ImmutableRelation
if
@loaded
@values
[
:with
]
=
values
end
def
recursive_value
=
(
value
)
raise
ImmutableRelation
if
@loaded
@values
[
:recursive
]
=
value
end
...
...
db/migrate/20170919211300_remove_temporary_ci_builds_index.rb
View file @
181cd299
...
...
@@ -12,6 +12,7 @@ class RemoveTemporaryCiBuildsIndex < ActiveRecord::Migration
def
up
return
unless
index_exists?
(
:ci_builds
,
:id
,
name:
'index_for_ci_builds_retried_migration'
)
remove_concurrent_index
(
:ci_builds
,
:id
,
name:
"index_for_ci_builds_retried_migration"
)
end
...
...
db/post_migrate/20170406111121_clean_upload_symlinks.rb
View file @
181cd299
...
...
@@ -14,6 +14,7 @@ class CleanUploadSymlinks < ActiveRecord::Migration
DIRECTORIES_TO_MOVE
.
each
do
|
dir
|
symlink_location
=
File
.
join
(
old_upload_dir
,
dir
)
next
unless
File
.
symlink?
(
symlink_location
)
say
"removing symlink:
#{
symlink_location
}
"
FileUtils
.
rm
(
symlink_location
)
end
...
...
db/post_migrate/20170612071012_move_personal_snippets_files.rb
View file @
181cd299
...
...
@@ -32,6 +32,7 @@ class MovePersonalSnippetsFiles < ActiveRecord::Migration
file_name
=
upload
[
'path'
].
split
(
'/'
)[
1
]
next
unless
move_file
(
upload
[
'model_id'
],
secret
,
file_name
)
update_markdown
(
upload
[
'model_id'
],
secret
,
file_name
,
upload
[
'description'
])
end
end
...
...
db/post_migrate/20170613111224_clean_appearance_symlinks.rb
View file @
181cd299
...
...
@@ -13,6 +13,7 @@ class CleanAppearanceSymlinks < ActiveRecord::Migration
symlink_location
=
File
.
join
(
old_upload_dir
,
dir
)
return
unless
File
.
symlink?
(
symlink_location
)
say
"removing symlink:
#{
symlink_location
}
"
FileUtils
.
rm
(
symlink_location
)
end
...
...
lib/api/commits.rb
View file @
181cd299
...
...
@@ -180,10 +180,12 @@ module API
if
params
[
:path
]
commit
.
raw_diffs
(
limits:
false
).
each
do
|
diff
|
next
unless
diff
.
new_path
==
params
[
:path
]
lines
=
Gitlab
::
Diff
::
Parser
.
new
.
parse
(
diff
.
diff
.
each_line
)
lines
.
each
do
|
line
|
next
unless
line
.
new_pos
==
params
[
:line
]
&&
line
.
type
==
params
[
:line_type
]
break
opts
[
:line_code
]
=
Gitlab
::
Git
.
diff_line_code
(
diff
.
new_path
,
line
.
new_pos
,
line
.
old_pos
)
end
...
...
lib/api/helpers/custom_validators.rb
View file @
181cd299
...
...
@@ -4,6 +4,7 @@ module API
class
Absence
<
Grape
::
Validations
::
Base
def
validate_param!
(
attr_name
,
params
)
return
if
params
.
respond_to?
(
:key?
)
&&
!
params
.
key?
(
attr_name
)
raise
Grape
::
Exceptions
::
Validation
,
params:
[
@scope
.
full_name
(
attr_name
)],
message:
message
(
:absence
)
end
end
...
...
lib/api/helpers/runner.rb
View file @
181cd299
...
...
@@ -14,6 +14,7 @@ module API
def
get_runner_version_from_params
return
unless
params
[
'info'
].
present?
attributes_for_keys
(
%w(name version revision platform architecture)
,
params
[
'info'
])
end
...
...
lib/api/runners.rb
View file @
181cd299
...
...
@@ -165,17 +165,20 @@ module API
def
authenticate_show_runner!
(
runner
)
return
if
runner
.
is_shared
||
current_user
.
admin?
forbidden!
(
"No access granted"
)
unless
user_can_access_runner?
(
runner
)
end
def
authenticate_update_runner!
(
runner
)
return
if
current_user
.
admin?
forbidden!
(
"Runner is shared"
)
if
runner
.
is_shared?
forbidden!
(
"No access granted"
)
unless
user_can_access_runner?
(
runner
)
end
def
authenticate_delete_runner!
(
runner
)
return
if
current_user
.
admin?
forbidden!
(
"Runner is shared"
)
if
runner
.
is_shared?
forbidden!
(
"Runner associated with more than one project"
)
if
runner
.
projects
.
count
>
1
forbidden!
(
"No access granted"
)
unless
user_can_access_runner?
(
runner
)
...
...
@@ -185,6 +188,7 @@ module API
forbidden!
(
"Runner is shared"
)
if
runner
.
is_shared?
forbidden!
(
"Runner is locked"
)
if
runner
.
locked?
return
if
current_user
.
admin?
forbidden!
(
"No access granted"
)
unless
user_can_access_runner?
(
runner
)
end
...
...
lib/api/snippets.rb
View file @
181cd299
...
...
@@ -95,6 +95,7 @@ module API
put
':id'
do
snippet
=
snippets_for_current_user
.
find_by
(
id:
params
.
delete
(
:id
))
return
not_found!
(
'Snippet'
)
unless
snippet
authorize!
:update_personal_snippet
,
snippet
attrs
=
declared_params
(
include_missing:
false
).
merge
(
request:
request
,
api:
true
)
...
...
lib/api/v3/commits.rb
View file @
181cd299
...
...
@@ -169,10 +169,12 @@ module API
if
params
[
:path
]
commit
.
raw_diffs
(
limits:
false
).
each
do
|
diff
|
next
unless
diff
.
new_path
==
params
[
:path
]
lines
=
Gitlab
::
Diff
::
Parser
.
new
.
parse
(
diff
.
diff
.
each_line
)
lines
.
each
do
|
line
|
next
unless
line
.
new_pos
==
params
[
:line
]
&&
line
.
type
==
params
[
:line_type
]
break
opts
[
:line_code
]
=
Gitlab
::
Git
.
diff_line_code
(
diff
.
new_path
,
line
.
new_pos
,
line
.
old_pos
)
end
...
...
lib/api/v3/runners.rb
View file @
181cd299
...
...
@@ -51,6 +51,7 @@ module API
helpers
do
def
authenticate_delete_runner!
(
runner
)
return
if
current_user
.
admin?
forbidden!
(
"Runner is shared"
)
if
runner
.
is_shared?
forbidden!
(
"Runner associated with more than one project"
)
if
runner
.
projects
.
count
>
1
forbidden!
(
"No access granted"
)
unless
user_can_access_runner?
(
runner
)
...
...
lib/api/v3/snippets.rb
View file @
181cd299
...
...
@@ -91,6 +91,7 @@ module API
put
':id'
do
snippet
=
snippets_for_current_user
.
find_by
(
id:
params
.
delete
(
:id
))
return
not_found!
(
'Snippet'
)
unless
snippet
authorize!
:update_personal_snippet
,
snippet
attrs
=
declared_params
(
include_missing:
false
)
...
...
@@ -113,6 +114,7 @@ module API
delete
':id'
do
snippet
=
snippets_for_current_user
.
find_by
(
id:
params
.
delete
(
:id
))
return
not_found!
(
'Snippet'
)
unless
snippet
authorize!
:destroy_personal_snippet
,
snippet
snippet
.
destroy
no_content!
...
...
lib/banzai/object_renderer.rb
View file @
181cd299
...
...
@@ -86,6 +86,7 @@ module Banzai
def
save_options
return
{}
unless
base_context
[
:xhtml
]
{
save_with:
Nokogiri
::
XML
::
Node
::
SaveOptions
::
AS_XHTML
}
end
end
...
...
lib/banzai/querying.rb
View file @
181cd299
...
...
@@ -52,8 +52,10 @@ module Banzai
children
.
each
do
|
child
|
next
if
child
.
text
.
blank?
node
=
nodes
.
shift
break
unless
node
==
child
filtered_nodes
<<
node
end
end
...
...
lib/banzai/reference_parser/user_parser.rb
View file @
181cd299
...
...
@@ -31,6 +31,7 @@ module Banzai
nodes
.
each
do
|
node
|
if
node
.
has_attribute?
(
group_attr
)
next
unless
can_read_group_reference?
(
node
,
user
,
groups
)
visible
<<
node
elsif
can_read_project_reference?
(
node
)
visible
<<
node
...
...
lib/banzai/renderer.rb
View file @
181cd299
...
...
@@ -149,6 +149,7 @@ module Banzai
def
self
.
full_cache_key
(
cache_key
,
pipeline_name
)
return
unless
cache_key
[
"banzai"
,
*
cache_key
,
pipeline_name
||
:full
]
end
...
...
@@ -157,6 +158,7 @@ module Banzai
# method.
def
self
.
full_cache_multi_key
(
cache_key
,
pipeline_name
)
return
unless
cache_key
Rails
.
cache
.
__send__
(
:expanded_key
,
full_cache_key
(
cache_key
,
pipeline_name
))
# rubocop:disable GitlabSecurity/PublicSend
end
end
...
...
lib/declarative_policy.rb
View file @
181cd299
...
...
@@ -30,6 +30,7 @@ module DeclarativePolicy
policy_class
=
class_for_class
(
subject
.
class
)
raise
"no policy for
#{
subject
.
class
.
name
}
"
if
policy_class
.
nil?
policy_class
end
...
...
@@ -84,6 +85,7 @@ module DeclarativePolicy
while
subject
.
respond_to?
(
:declarative_policy_delegate
)
raise
ArgumentError
,
"circular delegations"
if
seen
.
include?
(
subject
.
object_id
)
seen
<<
subject
.
object_id
subject
=
subject
.
declarative_policy_delegate
end
...
...
lib/declarative_policy/base.rb
View file @
181cd299
...
...
@@ -276,6 +276,7 @@ module DeclarativePolicy
# boolean `false`
def
cache
(
key
,
&
b
)
return
@cache
[
key
]
if
cached?
(
key
)
@cache
[
key
]
=
yield
end
...
...
@@ -291,6 +292,7 @@ module DeclarativePolicy
@_conditions
[
name
]
||=
begin
raise
"invalid condition
#{
name
}
"
unless
self
.
class
.
conditions
.
key?
(
name
)
ManifestCondition
.
new
(
self
.
class
.
conditions
[
name
],
self
)
end
end
...
...
lib/declarative_policy/cache.rb
View file @
181cd299
...
...
@@ -3,6 +3,7 @@ module DeclarativePolicy
class
<<
self
def
user_key
(
user
)
return
'<anonymous>'
if
user
.
nil?
id_for
(
user
)
end
...
...
@@ -15,6 +16,7 @@ module DeclarativePolicy
def
subject_key
(
subject
)
return
'<nil>'
if
subject
.
nil?
return
subject
.
inspect
if
subject
.
is_a?
(
Symbol
)
"
#{
subject
.
class
.
name
}
:
#{
id_for
(
subject
)
}
"
end
...
...
lib/declarative_policy/rule.rb
View file @
181cd299
...
...
@@ -83,6 +83,7 @@ module DeclarativePolicy
def
cached_pass?
(
context
)
condition
=
context
.
condition
(
@name
)
return
nil
unless
condition
.
cached?
condition
.
pass?
end
...
...
@@ -109,6 +110,7 @@ module DeclarativePolicy
def
delegated_context
(
context
)
policy
=
context
.
delegated_policies
[
@delegate_name
]
raise
MissingDelegate
if
policy
.
nil?
policy
end
...
...
@@ -121,6 +123,7 @@ module DeclarativePolicy
def
cached_pass?
(
context
)
condition
=
delegated_context
(
context
).
condition
(
@name
)
return
nil
unless
condition
.
cached?
condition
.
pass?
rescue
MissingDelegate
false
...
...
@@ -157,6 +160,7 @@ module DeclarativePolicy
def
cached_pass?
(
context
)
runner
=
context
.
runner
(
@ability
)
return
nil
unless
runner
.
cached?
runner
.
pass?
end
...
...
@@ -258,6 +262,7 @@ module DeclarativePolicy
def
score
(
context
)
return
0
unless
cached_pass?
(
context
).
nil?
@rules
.
map
{
|
r
|
r
.
score
(
context
)
}.
inject
(
0
,
:
+
)
end
...
...
lib/declarative_policy/runner.rb
View file @
181cd299
...
...
@@ -43,6 +43,7 @@ module DeclarativePolicy
# used by Rule::Ability. See #steps_by_score
def
score
return
0
if
cached?
steps
.
map
(
&
:score
).
inject
(
0
,
:
+
)
end
...
...
lib/file_size_validator.rb
View file @
181cd299
...
...
@@ -8,6 +8,7 @@ class FileSizeValidator < ActiveModel::EachValidator
def
initialize
(
options
)
if
range
=
(
options
.
delete
(
:in
)
||
options
.
delete
(
:within
))
raise
ArgumentError
,
":in and :within must be a Range"
unless
range
.
is_a?
(
Range
)
options
[
:minimum
],
options
[
:maximum
]
=
range
.
begin
,
range
.
end
options
[
:maximum
]
-=
1
if
range
.
exclude_end?
end
...
...
lib/gitlab/changes_list.rb
View file @
181cd299
...
...
@@ -16,6 +16,7 @@ module Gitlab
@changes
||=
begin
@raw_changes
.
map
do
|
change
|
next
if
change
.
blank?
oldrev
,
newrev
,
ref
=
change
.
strip
.
split
(
' '
)
{
oldrev:
oldrev
,
newrev:
newrev
,
ref:
ref
}
end
.
compact
...
...
lib/gitlab/ci/build/artifacts/metadata.rb
View file @
181cd299
...
...
@@ -98,6 +98,7 @@ module Gitlab
def
read_string
(
gz
)
string_size
=
read_uint32
(
gz
)
return
nil
unless
string_size
gz
.
read
(
string_size
)
end
...
...
lib/gitlab/ci/build/artifacts/metadata/entry.rb
View file @
181cd299
...
...
@@ -43,6 +43,7 @@ module Gitlab
def
parent
return
nil
unless
has_parent?
self
.
class
.
new
(
@path
.
to_s
.
chomp
(
basename
),
@entries
)
end
...
...
@@ -64,6 +65,7 @@ module Gitlab
def
directories
(
opts
=
{})
return
[]
unless
directory?
dirs
=
children
.
select
(
&
:directory?
)
return
dirs
unless
has_parent?
&&
opts
[
:parent
]
...
...
@@ -74,6 +76,7 @@ module Gitlab
def
files
return
[]
unless
directory?
children
.
select
(
&
:file?
)
end
...
...
lib/gitlab/ci/build/image.rb
View file @
181cd299
...
...
@@ -8,6 +8,7 @@ module Gitlab
def
from_image
(
job
)
image
=
Gitlab
::
Ci
::
Build
::
Image
.
new
(
job
.
options
[
:image
])
return
unless
image
.
valid?
image
end
...
...
lib/gitlab/ci/config/entry/image.rb
View file @
181cd299
...
...
@@ -37,6 +37,7 @@ module Gitlab
def
value
return
{
name:
@config
}
if
string?
return
@config
if
hash
?
{}
end
end
...
...
lib/gitlab/ci/config/entry/validators.rb
View file @
181cd299
...
...
@@ -111,6 +111,7 @@ module Gitlab
def
validate_string_or_regexp
(
value
)
return
false
unless
value
.
is_a?
(
String
)
return
validate_regexp
(
value
)
if
look_like_regexp?
(
value
)
true
end
end
...
...
lib/gitlab/daemon.rb
View file @
181cd299
...
...
@@ -2,6 +2,7 @@ module Gitlab
class
Daemon
def
self
.
initialize_instance
(
*
args
)
raise
"
#{
name
}
singleton instance already initialized"
if
@instance
@instance
=
new
(
*
args
)
Kernel
.
at_exit
(
&
@instance
.
method
(
:stop
))
@instance
...
...
lib/gitlab/diff/inline_diff.rb
View file @
181cd299
...
...
@@ -102,6 +102,7 @@ module Gitlab
new_char
=
b
[
pos
]
break
if
old_char
!=
new_char
length
+=
1
end
...
...
lib/gitlab/diff/parser.rb
View file @
181cd299
...
...
@@ -30,6 +30,7 @@ module Gitlab
line_new
=
line
.
match
(
/\+[0-9]*/
)[
0
].
to_i
.
abs
rescue
0
next
if
line_old
<=
1
&&
line_new
<=
1
# top of file
yielder
<<
Gitlab
::
Diff
::
Line
.
new
(
full_line
,
type
,
line_obj_index
,
line_old
,
line_new
)
line_obj_index
+=
1
next
...
...
lib/gitlab/diff/position.rb
View file @
181cd299
...
...
@@ -125,6 +125,7 @@ module Gitlab
def
find_diff_file
(
repository
)
return
unless
diff_refs
.
complete?
return
unless
comparison
=
diff_refs
.
compare_in
(
repository
.
project
)
comparison
.
diffs
(
paths:
paths
,
expanded:
true
).
diff_files
.
first
end
...
...
lib/gitlab/email/handler/unsubscribe_handler.rb
View file @
181cd299
...
...
@@ -16,6 +16,7 @@ module Gitlab
noteable
=
sent_notification
.
noteable
raise
NoteableNotFoundError
unless
noteable
noteable
.
unsubscribe
(
sent_notification
.
recipient
)
end
...
...
lib/gitlab/fogbugz_import/client.rb
View file @
181cd299
...
...
@@ -45,6 +45,7 @@ module Gitlab
project_name
=
repo
(
project_id
).
name
res
=
@api
.
command
(
:search
,
q:
"project:'
#{
project_name
}
'"
,
cols:
'ixPersonAssignedTo,ixPersonOpenedBy,ixPersonClosedBy,sStatus,sPriority,sCategory,fOpen,sTitle,sLatestTextSummary,dtOpened,dtClosed,dtResolved,dtLastUpdated,events'
)
return
[]
unless
res
[
'cases'
][
'count'
].
to_i
>
0
res
[
'cases'
][
'case'
]
end
...
...
lib/gitlab/fogbugz_import/importer.rb
View file @
181cd299
...
...
@@ -18,6 +18,7 @@ module Gitlab
def
execute
return
true
unless
repo
.
valid?
client
=
Gitlab
::
FogbugzImport
::
Client
.
new
(
token:
fb_session
[
:token
],
uri:
fb_session
[
:uri
])
@cases
=
client
.
cases
(
@repo
.
id
.
to_i
)
...
...
@@ -206,6 +207,7 @@ module Gitlab
def
format_content
(
raw_content
)
return
raw_content
if
raw_content
.
nil?
linkify_issues
(
escape_for_markdown
(
raw_content
))
end
...
...
lib/gitlab/git/blob.rb
View file @
181cd299
...
...
@@ -102,6 +102,7 @@ module Gitlab
if
path_arr
.
size
>
1
return
nil
unless
entry
[
:type
]
==
:tree
path_arr
.
shift
find_entry_by_path
(
repository
,
entry
[
:oid
],
path_arr
.
join
(
'/'
))
else
...
...
lib/gitlab/git/repository.rb
View file @
181cd299
...
...
@@ -1376,6 +1376,7 @@ module Gitlab
end
return
nil
unless
tmp_entry
.
type
==
:tree
tmp_entry
=
tmp_entry
[
dir
]
end
end
...
...
@@ -1496,6 +1497,7 @@ module Gitlab
# Ref names must start with `refs/`.
def
rugged_ref_exists?
(
ref_name
)
raise
ArgumentError
,
'invalid refname'
unless
ref_name
.
start_with?
(
'refs/'
)
rugged
.
references
.
exist?
(
ref_name
)
rescue
Rugged
::
ReferenceError
false
...
...
@@ -1562,6 +1564,7 @@ module Gitlab
Gitlab
::
Git
::
Branch
.
new
(
self
,
rugged_ref
.
name
,
rugged_ref
.
target
,
target_commit
)
rescue
Rugged
::
ReferenceError
=>
e
raise
InvalidRef
.
new
(
"Branch
#{
ref
}
already exists"
)
if
e
.
to_s
=~
/'refs\/heads\/
#{
ref
}
'/
raise
InvalidRef
.
new
(
"Invalid reference
#{
start_point
}
"
)
end
...
...
lib/gitlab/gitaly_client/ref_service.rb
View file @
181cd299
...
...
@@ -137,6 +137,7 @@ module Gitlab
enum_value
=
Gitaly
::
FindLocalBranchesRequest
::
SortBy
.
resolve
(
sort_by
.
upcase
.
to_sym
)
raise
ArgumentError
,
"Invalid sort_by key `
#{
sort_by
}
`"
unless
enum_value
enum_value
end
...
...
lib/gitlab/gitaly_client/wiki_service.rb
View file @
181cd299
...
...
@@ -94,6 +94,7 @@ module Gitlab
page
,
version
=
wiki_page_from_iterator
(
response
)
{
|
message
|
message
.
end_of_page
}
break
unless
page
&&
version
pages
<<
[
page
,
version
]
end
...
...
lib/gitlab/gitlab_import/client.rb
View file @
181cd299
...
...
@@ -65,6 +65,7 @@ module Gitlab
y
<<
item
end
break
if
items
.
empty?
||
items
.
size
<
per_page
page
+=
1
end
end
...
...
lib/gitlab/kubernetes/namespace.rb
View file @
181cd299
...
...
@@ -12,6 +12,7 @@ module Gitlab
@client
.
get_namespace
(
name
)
rescue
::
KubeException
=>
ke
raise
ke
unless
ke
.
error_code
==
404
false
end
...
...
lib/gitlab/ldap/authentication.rb
View file @
181cd299
...
...
@@ -62,6 +62,7 @@ module Gitlab
def
user
return
nil
unless
ldap_user
Gitlab
::
LDAP
::
User
.
find_by_uid_and_provider
(
ldap_user
.
dn
,
provider
)
end
end
...
...
lib/gitlab/legacy_github_import/importer.rb
View file @
181cd299
...
...
@@ -15,6 +15,7 @@ module Gitlab
def
client
return
@client
if
defined?
(
@client
)
unless
credentials
raise
Projects
::
ImportService
::
Error
,
"Unable to find project import data credentials for project ID:
#{
@project
.
id
}
"
...
...
lib/gitlab/metrics/samplers/ruby_sampler.rb
View file @
181cd299
...
...
@@ -96,6 +96,7 @@ module Gitlab
def
worker_label
return
{}
unless
defined?
(
Unicorn
::
Worker
)
worker_no
=
::
Prometheus
::
Client
::
Support
::
Unicorn
.
worker_id
if
worker_no
...
...
lib/gitlab/metrics/subscribers/active_record.rb
View file @
181cd299
...
...
@@ -7,6 +7,7 @@ module Gitlab
def
sql
(
event
)
return
unless
current_transaction
metric_sql_duration_seconds
.
observe
(
current_transaction
.
labels
,
event
.
duration
/
1000.0
)
current_transaction
.
increment
(
:sql_duration
,
event
.
duration
,
false
)
...
...
lib/gitlab/middleware/go.rb
View file @
181cd299
...
...
@@ -66,6 +66,7 @@ module Gitlab
project_path_match
=
"
#{
path_info
}
/"
.
match
(
PROJECT_PATH_REGEX
)
return
unless
project_path_match
path
=
project_path_match
[
1
]
# Go subpackages may be in the form of `namespace/project/path1/path2/../pathN`.
...
...
lib/gitlab/optimistic_locking.rb
View file @
181cd299
...
...
@@ -11,6 +11,7 @@ module Gitlab
rescue
ActiveRecord
::
StaleObjectError
retries
-=
1
raise
unless
retries
>=
0
subject
.
reload
end
end
...
...
lib/gitlab/saml/user.rb
View file @
181cd299
...
...
@@ -28,6 +28,7 @@ module Gitlab
def
changed?
return
true
unless
gl_user
gl_user
.
changed?
||
gl_user
.
identities
.
any?
(
&
:changed?
)
end
...
...
lib/gitlab/shell.rb
View file @
181cd299
...
...
@@ -368,6 +368,7 @@ module Gitlab
output
,
status
=
gitlab_shell_fast_execute_helper
(
cmd
,
vars
)
raise
Error
,
output
unless
status
.
zero?
true
end
...
...
lib/gitlab/string_range_marker.rb
View file @
181cd299
...
...
@@ -90,6 +90,7 @@ module Gitlab
# Takes an array of integers, and returns an array of ranges covering the same integers
def
collapse_ranges
(
positions
)
return
[]
if
positions
.
empty?
ranges
=
[]
start
=
prev
=
positions
[
0
]
...
...
lib/gitlab/template/finders/repo_template_finder.rb
View file @
181cd299
...
...
@@ -18,6 +18,7 @@ module Gitlab
def
read
(
path
)
blob
=
@repository
.
blob_at
(
@commit
.
id
,
path
)
if
@commit
raise
FileNotFoundError
if
blob
.
nil?
blob
.
data
end
...
...
lib/gitlab/url_sanitizer.rb
View file @
181cd299
...
...
@@ -70,6 +70,7 @@ module Gitlab
def
generate_full_url
return
@url
unless
valid_credentials?
@full_url
=
@url
.
dup
@full_url
.
password
=
credentials
[
:password
]
if
credentials
[
:password
].
present?
...
...
lib/gitlab/visibility_level.rb
View file @
181cd299
...
...
@@ -99,6 +99,7 @@ module Gitlab
def
level_value
(
level
)
return
level
.
to_i
if
level
.
to_i
.
to_s
==
level
.
to_s
&&
string_options
.
key
(
level
.
to_i
)
string_options
[
level
]
||
PRIVATE
end
...
...
lib/gitlab/workhorse.rb
View file @
181cd299
...
...
@@ -174,6 +174,7 @@ module Gitlab
@secret
||=
begin
bytes
=
Base64
.
strict_decode64
(
File
.
read
(
secret_path
).
chomp
)
raise
"
#{
secret_path
}
does not contain
#{
SECRET_LENGTH
}
bytes"
if
bytes
.
length
!=
SECRET_LENGTH
bytes
end
end
...
...
lib/haml_lint/inline_javascript.rb
View file @
181cd299
...
...
@@ -9,6 +9,7 @@ unless Rails.env.production?
def
visit_filter
(
node
)
return
unless
node
.
filter_type
==
'javascript'
record_lint
(
node
,
'Inline JavaScript is discouraged (https://docs.gitlab.com/ee/development/gotchas.html#do-not-use-inline-javascript-in-views)'
)
end
end
...
...
lib/system_check/simple_executor.rb
View file @
181cd299
...
...
@@ -24,6 +24,7 @@ module SystemCheck
# @param [BaseCheck] check class
def
<<
(
check
)
raise
ArgumentError
unless
check
.
is_a?
(
Class
)
&&
check
<
BaseCheck
@checks
<<
check
end
...
...
lib/tasks/gitlab/cleanup.rake
View file @
181cd299
...
...
@@ -60,6 +60,7 @@ namespace :gitlab do
.
chomp
(
'.git'
)
.
chomp
(
'.wiki'
)
next
if
Project
.
find_by_full_path
(
repo_with_namespace
)
new_path
=
path
+
move_suffix
puts
path
.
inspect
+
' -> '
+
new_path
.
inspect
File
.
rename
(
path
,
new_path
)
...
...
@@ -75,6 +76,7 @@ namespace :gitlab do
User
.
find_each
do
|
user
|
next
unless
user
.
ldap_user?
print
"
#{
user
.
name
}
(
#{
user
.
ldap_identity
.
extern_uid
}
) ..."
if
Gitlab
::
LDAP
::
Access
.
allowed?
(
user
)
puts
" [OK]"
.
color
(
:green
)
...
...
qa/qa/page/main/entry.rb
View file @
181cd299
...
...
@@ -16,6 +16,7 @@ module QA
while
Time
.
now
-
start
<
240
break
if
page
.
has_css?
(
'.application'
,
wait:
10
)
refresh
end
end
...
...
rubocop/cop/line_break_after_guard_clauses.rb
0 → 100644
View file @
181cd299
# frozen_string_literal: true
module
RuboCop
module
Cop
# Ensures a line break after guard clauses.
#
# @example
# # bad
# return unless condition
# do_stuff
#
# # good
# return unless condition
#
# do_stuff
#
# # bad
# raise if condition
# do_stuff
#
# # good
# raise if condition
#
# do_stuff
#
# Multiple guard clauses are allowed without
# line break.
#
# # good
# return unless condition_a
# return unless condition_b
#
# do_stuff
#
# Guard clauses in case statement are allowed without
# line break.
#
# # good
# case model
# when condition_a
# return true unless condition_b
# when
# ...
# end
#
# Guard clauses before end are allowed without
# line break.
#
# # good
# if condition_a
# do_something
# else
# do_something_else
# return unless condition
# end
#
# do_something_more
class
LineBreakAfterGuardClauses
<
RuboCop
::
Cop
::
Cop
MSG
=
'Add a line break after guard clauses'
def_node_matcher
:guard_clause_node?
,
<<-
PATTERN
[{(send nil? {:raise :fail :throw} ...) return break next} single_line?]
PATTERN
def
on_if
(
node
)
return
unless
node
.
single_line?
return
unless
guard_clause?
(
node
)
return
if
next_line
(
node
).
blank?
||
clause_last_line?
(
next_line
(
node
))
||
guard_clause?
(
next_sibling
(
node
))
add_offense
(
node
,
:expression
,
MSG
)
end
def
autocorrect
(
node
)
lambda
do
|
corrector
|
corrector
.
insert_after
(
node
.
loc
.
expression
,
"
\n
"
)
end
end
private
def
guard_clause?
(
node
)
return
false
unless
node
.
if_type?
guard_clause_node?
(
node
.
if_branch
)
end
def
next_sibling
(
node
)
node
.
parent
.
children
[
node
.
sibling_index
+
1
]
end
def
next_line
(
node
)
processed_source
[
node
.
loc
.
line
]
end
def
clause_last_line?
(
line
)
line
=~
/^\s*(?:end|elsif|else|when|rescue|ensure)/
end
end
end
end
rubocop/rubocop.rb
View file @
181cd299
...
...
@@ -3,6 +3,7 @@ require_relative 'cop/active_record_serialize'
require_relative
'cop/custom_error_class'
require_relative
'cop/gem_fetcher'
require_relative
'cop/in_batches'
require_relative
'cop/line_break_after_guard_clauses'
require_relative
'cop/polymorphic_associations'
require_relative
'cop/project_path_helper'
require_relative
'cop/redirect_with_status'
...
...
spec/factories/notes.rb
View file @
181cd299
...
...
@@ -130,6 +130,7 @@ FactoryGirl.define do
before
(
:create
)
do
|
note
,
evaluator
|
discussion
=
evaluator
.
in_reply_to
next
unless
discussion
discussion
=
discussion
.
to_discussion
if
discussion
.
is_a?
(
Note
)
next
unless
discussion
...
...
spec/lib/gitlab/git/diff_collection_spec.rb
View file @
181cd299
...
...
@@ -487,6 +487,7 @@ describe Gitlab::Git::DiffCollection, seed_helper: true do
loop
do
break
if
@count
.
zero?
# It is critical to decrement before yielding. We may never reach the lines after 'yield'.
@count
-=
1
yield
@value
...
...
spec/models/project_services/flowdock_service_spec.rb
View file @
181cd299
...
...
@@ -46,6 +46,7 @@ describe FlowdockService do
@sample_data
[
:commits
].
each
do
|
commit
|
# One request to Flowdock per new commit
next
if
commit
[
:id
]
==
@sample_data
[
:before
]
expect
(
WebMock
).
to
have_requested
(
:post
,
@api_url
).
with
(
body:
/
#{
commit
[
:id
]
}
.*
#{
project
.
path
}
/
).
once
...
...
spec/requests/api/projects_spec.rb
View file @
181cd299
...
...
@@ -437,6 +437,7 @@ describe API::Projects do
project
.
each_pair
do
|
k
,
v
|
next
if
%i[has_external_issue_tracker issues_enabled merge_requests_enabled wiki_enabled]
.
include?
(
k
)
expect
(
json_response
[
k
.
to_s
]).
to
eq
(
v
)
end
...
...
@@ -643,6 +644,7 @@ describe API::Projects do
expect
(
response
).
to
have_gitlab_http_status
(
201
)
project
.
each_pair
do
|
k
,
v
|
next
if
%i[has_external_issue_tracker path]
.
include?
(
k
)
expect
(
json_response
[
k
.
to_s
]).
to
eq
(
v
)
end
end
...
...
spec/requests/api/v3/projects_spec.rb
View file @
181cd299
...
...
@@ -404,6 +404,7 @@ describe API::V3::Projects do
project
.
each_pair
do
|
k
,
v
|
next
if
%i[has_external_issue_tracker issues_enabled merge_requests_enabled wiki_enabled]
.
include?
(
k
)
expect
(
json_response
[
k
.
to_s
]).
to
eq
(
v
)
end
...
...
@@ -547,6 +548,7 @@ describe API::V3::Projects do
expect
(
response
).
to
have_gitlab_http_status
(
201
)
project
.
each_pair
do
|
k
,
v
|
next
if
%i[has_external_issue_tracker path]
.
include?
(
k
)
expect
(
json_response
[
k
.
to_s
]).
to
eq
(
v
)
end
end
...
...
spec/rubocop/cop/line_break_after_guard_clauses_spec.rb
0 → 100644
View file @
181cd299
require
'spec_helper'
require
'rubocop'
require
'rubocop/rspec/support'
require_relative
'../../../rubocop/cop/line_break_after_guard_clauses'
describe
RuboCop
::
Cop
::
LineBreakAfterGuardClauses
do
include
CopHelper
subject
(
:cop
)
{
described_class
.
new
}
shared_examples
'examples with guard clause'
do
|
title
|
%w[if unless]
.
each
do
|
conditional
|
it
"flags violation for
#{
title
}
#{
conditional
}
without line breaks"
do
source
=
<<~
RUBY
#{
title
}
#{
conditional
}
condition
do_stuff
RUBY
inspect_source
(
cop
,
source
)
expect
(
cop
.
offenses
.
size
).
to
eq
(
1
)
offense
=
cop
.
offenses
.
first
expect
(
offense
.
line
).
to
eq
(
1
)
expect
(
cop
.
highlights
).
to
eq
([
"
#{
title
}
#{
conditional
}
condition"
])
expect
(
offense
.
message
).
to
eq
(
'Add a line break after guard clauses'
)
end
it
"doesn't flag violation for
#{
title
}
#{
conditional
}
with line break"
do
source
=
<<~
RUBY
#{
title
}
#{
conditional
}
condition
do_stuff
RUBY
inspect_source
(
cop
,
source
)
expect
(
cop
.
offenses
).
to
be_empty
end
it
"doesn't flag violation for
#{
title
}
#{
conditional
}
on multiple lines without line break"
do
source
=
<<~
RUBY
#{
conditional
}
condition
#{
title
}
end
do_stuff
RUBY
inspect_source
(
cop
,
source
)
expect
(
cop
.
offenses
).
to
be_empty
end
it
"doesn't flag violation for
#{
title
}
#{
conditional
}
without line breaks when followed by end keyword"
do
source
=
<<~
RUBY
def test
#{
title
}
#{
conditional
}
condition
end
RUBY
inspect_source
(
cop
,
source
)
expect
(
cop
.
offenses
).
to
be_empty
end
it
"doesn't flag violation for
#{
title
}
#{
conditional
}
without line breaks when followed by elsif keyword"
do
source
=
<<~
RUBY
if model
#{
title
}
#{
conditional
}
condition
elsif
do_something
end
RUBY
inspect_source
(
cop
,
source
)
expect
(
cop
.
offenses
).
to
be_empty
end
it
"doesn't flag violation for
#{
title
}
#{
conditional
}
without line breaks when followed by else keyword"
do
source
=
<<~
RUBY
if model
#{
title
}
#{
conditional
}
condition
else
do_something
end
RUBY
inspect_source
(
cop
,
source
)
expect
(
cop
.
offenses
).
to
be_empty
end
it
"doesn't flag violation for
#{
title
}
#{
conditional
}
without line breaks when followed by when keyword"
do
source
=
<<~
RUBY
case model
when condition_a
#{
title
}
#{
conditional
}
condition
when condition_b
do_something
end
RUBY
inspect_source
(
cop
,
source
)
expect
(
cop
.
offenses
).
to
be_empty
end
it
"doesn't flag violation for
#{
title
}
#{
conditional
}
without line breaks when followed by rescue keyword"
do
source
=
<<~
RUBY
begin
#{
title
}
#{
conditional
}
condition
rescue StandardError
do_something
end
RUBY
inspect_source
(
cop
,
source
)
expect
(
cop
.
offenses
).
to
be_empty
end
it
"doesn't flag violation for
#{
title
}
#{
conditional
}
without line breaks when followed by ensure keyword"
do
source
=
<<~
RUBY
def foo
#{
title
}
#{
conditional
}
condition
ensure
do_something
end
RUBY
inspect_source
(
cop
,
source
)
expect
(
cop
.
offenses
).
to
be_empty
end
it
"doesn't flag violation for
#{
title
}
#{
conditional
}
without line breaks when followed by another guard clause"
do
source
=
<<~
RUBY
#{
title
}
#{
conditional
}
condition
#{
title
}
#{
conditional
}
condition
do_stuff
RUBY
inspect_source
(
cop
,
source
)
expect
(
cop
.
offenses
).
to
be_empty
end
it
"autocorrects
#{
title
}
#{
conditional
}
guard clauses without line break"
do
source
=
<<~
RUBY
#{
title
}
#{
conditional
}
condition
do_stuff
RUBY
autocorrected
=
autocorrect_source
(
cop
,
source
)
expected_source
=
<<~
RUBY
#{
title
}
#{
conditional
}
condition
do_stuff
RUBY
expect
(
autocorrected
).
to
eql
(
expected_source
)
end
end
end
%w[return fail raise next break throw]
.
each
do
|
example
|
it_behaves_like
'examples with guard clause'
,
example
end
end
spec/services/notification_service_spec.rb
View file @
181cd299
...
...
@@ -280,6 +280,7 @@ describe NotificationService, :mailer do
next
if
member
.
id
==
@u_disabled
.
id
# Author should not be notified
next
if
member
.
id
==
note
.
author
.
id
should_email
(
member
)
end
...
...
@@ -327,6 +328,7 @@ describe NotificationService, :mailer do
next
if
member
.
id
==
@u_disabled
.
id
# Author should not be notified
next
if
member
.
id
==
note
.
author
.
id
should_email
(
member
)
end
...
...
spec/support/fixture_helpers.rb
View file @
181cd299
module
FixtureHelpers
def
fixture_file
(
filename
)
return
''
if
filename
.
blank?
File
.
read
(
expand_fixture_path
(
filename
))
end
...
...
spec/support/generate-seed-repo-rb
View file @
181cd299
...
...
@@ -33,6 +33,7 @@ end
def
capture!
(
cmd
,
dir
)
output
=
IO
.
popen
(
cmd
,
'r'
,
chdir:
dir
)
{
|
io
|
io
.
read
}
raise
"command failed with
#{
$?
}
:
#{
cmd
.
join
(
' '
)
}
"
unless
$?
.
success?
output
.
chomp
end
...
...
spec/support/gitaly.rb
View file @
181cd299
...
...
@@ -4,6 +4,7 @@ RSpec.configure do |config|
allow
(
Gitlab
::
GitalyClient
).
to
receive
(
:feature_enabled?
).
and_return
(
false
)
else
next
if
example
.
metadata
[
:skip_gitaly_mock
]
allow
(
Gitlab
::
GitalyClient
).
to
receive
(
:feature_enabled?
).
and_return
(
true
)
end
end
...
...
spec/unicorn/unicorn_spec.rb
View file @
181cd299
...
...
@@ -71,6 +71,7 @@ describe 'Unicorn' do
timeout
=
5
*
60
timeout
.
times
do
return
if
File
.
exist?
(
ready_file
)
pid
=
Process
.
waitpid
(
master_pid
,
Process
::
WNOHANG
)
raise
"unicorn failed to boot:
#{
$?
}
"
unless
pid
.
nil?
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment