Commit ffadefb3 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Merge pull request #9690 from ggarnier/master

Fix "useless assignment" Rubocop warnings
......@@ -932,7 +932,7 @@ Lint/UselessAccessModifier:
Lint/UselessAssignment:
Description: 'Checks for useless assignment to a local variable.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#underscore-unused-vars'
Enabled: false
Enabled: true
Lint/UselessComparison:
Description: 'Checks for comparison of something with itself.'
......
......@@ -18,7 +18,7 @@ def create
rescue Ci::GitlabCiYamlProcessor::ValidationError => e
@error = e.message
@status = false
rescue Exception => e
rescue Exception
@error = "Undefined error"
@status = false
end
......
......@@ -71,7 +71,7 @@ def handle_omniauth
redirect_to omniauth_error_path(oauth['provider'], error: error_message) and return
end
end
rescue Gitlab::OAuth::SignupDisabledError => e
rescue Gitlab::OAuth::SignupDisabledError
label = Gitlab::OAuth::Provider.label_for(oauth['provider'])
message = "Signing in using your #{label} account without a pre-existing GitLab account is not allowed."
......@@ -80,7 +80,7 @@ def handle_omniauth
end
flash[:notice] = message
redirect_to new_user_session_path
end
......
......@@ -98,7 +98,7 @@ def load_project_wiki
# Call #wiki to make sure the Wiki Repo is initialized
@project_wiki.wiki
rescue ProjectWiki::CouldNotCreateWikiError => ex
rescue ProjectWiki::CouldNotCreateWikiError
flash[:notice] = "Could not create Wiki Repository at this time. Please try again later."
redirect_to project_path(@project)
return false
......
......@@ -39,7 +39,7 @@ def execute
items = by_assignee(items)
items = by_author(items)
items = by_label(items)
items = sort(items)
sort(items)
end
def group
......
......@@ -35,7 +35,7 @@ def current_action?(*args)
def project_icon(project_id, options = {})
project =
if project_id.is_a?(Project)
project = project_id
project_id
else
Project.find_with_namespace(project_id)
end
......
......@@ -26,7 +26,7 @@
module Ci
class Build < ActiveRecord::Base
extend Ci::Model
LAZY_ATTRIBUTES = ['trace']
belongs_to :commit, class_name: 'Ci::Commit'
......@@ -140,7 +140,7 @@ def retry(build)
def trace_html
html = Ci::Ansi2html::convert(trace) if trace.present?
html ||= ''
html || ''
end
def started?
......@@ -211,7 +211,7 @@ def extract_coverage(text, regex)
if coverage.present?
coverage.to_f
end
rescue => ex
rescue
# if bad regex or something goes wrong we dont want to interrupt transition
# so we just silentrly ignore error for now
end
......
......@@ -184,7 +184,7 @@ def build_missing_services
# If service is available but missing in db
# we should create an instance. Ex `create_gitlab_ci_service`
service = self.send :"create_#{service_name}_service" if service.nil?
self.send :"create_#{service_name}_service" if service.nil?
end
end
......
......@@ -144,12 +144,10 @@ def reload_diffs
# Collect array of Git::Diff objects
# between target and source branches
def unmerged_diffs
diffs = compare_result.diffs
diffs ||= []
diffs
rescue Gitlab::Git::Diff::TimeoutError => ex
compare_result.diffs || []
rescue Gitlab::Git::Diff::TimeoutError
self.state = :timeout
diffs = []
[]
end
def repository
......
......@@ -413,7 +413,7 @@ def build_missing_services
if template.nil?
# If no template, we should create an instance. Ex `create_gitlab_ci_service`
service = self.send :"create_#{service_name}_service"
self.send :"create_#{service_name}_service"
else
Service.create_from_template(self.id, template)
end
......@@ -738,7 +738,7 @@ def repository_exists?
def create_wiki
ProjectWiki.new(self, self.owner).wiki
true
rescue ProjectWiki::CouldNotCreateWikiError => ex
rescue ProjectWiki::CouldNotCreateWikiError
errors.add(:base, 'Failed create wiki')
false
end
......
......@@ -85,17 +85,16 @@ def message_options
def create_message(data)
object_kind = data[:object_kind]
message = \
case object_kind
when "push", "tag_push"
create_push_message(data)
when "issue"
create_issue_message(data) unless is_update?(data)
when "merge_request"
create_merge_request_message(data) unless is_update?(data)
when "note"
create_note_message(data)
end
case object_kind
when "push", "tag_push"
create_push_message(data)
when "issue"
create_issue_message(data) unless is_update?(data)
when "merge_request"
create_merge_request_message(data) unless is_update?(data)
when "note"
create_note_message(data)
end
end
def create_push_message(push)
......@@ -167,8 +166,6 @@ def create_merge_request_message(data)
obj_attr = data[:object_attributes]
obj_attr = HashWithIndifferentAccess.new(obj_attr)
merge_request_id = obj_attr[:iid]
source_branch = obj_attr[:source_branch]
target_branch = obj_attr[:target_branch]
state = obj_attr[:state]
description = obj_attr[:description]
title = obj_attr[:title]
......@@ -194,8 +191,6 @@ def create_note_message(data)
data = HashWithIndifferentAccess.new(data)
user_name = data[:user][:name]
repo_attr = HashWithIndifferentAccess.new(data[:repository])
obj_attr = HashWithIndifferentAccess.new(data[:object_attributes])
note = obj_attr[:note]
note_url = obj_attr[:url]
......
......@@ -549,7 +549,7 @@ def commit_with_hooks(current_user, branch)
# Run GitLab post receive hook
post_receive_hook = Gitlab::Git::Hook.new('post-receive', path_to_repo)
status = post_receive_hook.trigger(gl_id, oldrev, newrev, ref)
post_receive_hook.trigger(gl_id, oldrev, newrev, ref)
else
# Remove tmp ref and return error to user
rugged.references.delete(tmp_ref)
......
......@@ -705,13 +705,7 @@ def toggle_star(project)
end
def manageable_namespaces
@manageable_namespaces ||=
begin
namespaces = []
namespaces << namespace
namespaces += owned_groups
namespaces += masters_groups
end
@manageable_namespaces ||= [namespace] + owned_groups + masters_groups
end
def namespaces
......
......@@ -21,7 +21,7 @@ def execute
create_target_branch
end
if sha = commit
if commit
success
else
error("Something went wrong. Your changes were not committed")
......
......@@ -62,7 +62,7 @@ def execute
after_create_actions if @project.persisted?
@project
rescue => ex
rescue
@project.errors.add(:base, "Can't save project. Please try again later")
@project
end
......
......@@ -282,9 +282,9 @@ def group_milestone
milestone1_project2 = create :milestone,
title: "Version 7.2",
project: project2
milestone1_project3 = create :milestone,
title: "Version 7.2",
project: @project3
create :milestone,
title: "Version 7.2",
project: @project3
milestone2_project1 = create :milestone,
title: "GL-113",
project: @project1
......@@ -301,28 +301,28 @@ def group_milestone
assignee: current_user,
author: current_user,
milestone: milestone2_project1
issue2 = create :issue,
project: project2,
assignee: current_user,
author: current_user,
milestone: milestone1_project2
issue3 = create :issue,
project: @project3,
assignee: current_user,
author: current_user,
milestone: milestone1_project1
mr1 = create :merge_request,
source_project: @project1,
target_project: @project1,
assignee: current_user,
author: current_user,
milestone: milestone2_project1
mr2 = create :merge_request,
source_project: project2,
target_project: project2,
assignee: current_user,
author: current_user,
milestone: milestone2_project2
create :issue,
project: project2,
assignee: current_user,
author: current_user,
milestone: milestone1_project2
create :issue,
project: @project3,
assignee: current_user,
author: current_user,
milestone: milestone1_project1
create :merge_request,
source_project: @project1,
target_project: @project1,
assignee: current_user,
author: current_user,
milestone: milestone2_project1
create :merge_request,
source_project: project2,
target_project: project2,
assignee: current_user,
author: current_user,
milestone: milestone2_project2
@mr3 = create :merge_request,
source_project: @project3,
target_project: @project3,
......
......@@ -32,6 +32,6 @@ class Spinach::Features::ProjectGraph < Spinach::FeatureSteps
end
def project
project ||= Project.find_by(name: "Shop")
@project ||= Project.find_by(name: "Shop")
end
end
......@@ -223,11 +223,11 @@ class Spinach::Features::ProjectIssues < Spinach::FeatureSteps
end
step 'project \'Shop\' has issue \'Bugfix1\' with description: \'Description for issue1\'' do
issue = create(:issue, title: 'Bugfix1', description: 'Description for issue1', project: project)
create(:issue, title: 'Bugfix1', description: 'Description for issue1', project: project)
end
step 'project \'Shop\' has issue \'Feature1\' with description: \'Feature submitted for issue1\'' do
issue = create(:issue, title: 'Feature1', description: 'Feature submitted for issue1', project: project)
create(:issue, title: 'Feature1', description: 'Feature submitted for issue1', project: project)
end
step 'I fill in issue search with \'Description for issue1\'' do
......
......@@ -39,7 +39,6 @@ class Spinach::Features::ProjectRedirects < Spinach::FeatureSteps
step 'Authenticate' do
admin = create(:admin)
project = Project.find_by(name: 'Community')
fill_in "user_login", with: admin.email
fill_in "user_password", with: admin.password
click_button "Sign in"
......@@ -54,7 +53,6 @@ class Spinach::Features::ProjectRedirects < Spinach::FeatureSteps
step 'I get redirected to signin page where I sign in' do
admin = create(:admin)
project = Project.find_by(name: 'Enterprise')
fill_in "user_login", with: admin.email
fill_in "user_password", with: admin.password
click_button "Sign in"
......
......@@ -37,7 +37,7 @@ def is_member_of(username, groupname, role)
group = Group.find_by(name: groupname) || create(:group, name: groupname)
group.add_user(user, role)
project ||= create(:project, namespace: group, path: "project#{@project_count}")
event ||= create(:closed_issue_event, project: project)
create(:closed_issue_event, project: project)
project.team << [user, :master]
@project_count += 1
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment