Commit 383b6f45 authored by Igor Drozdov's avatar Igor Drozdov

Fix Style/UnneededCondition offenses

The cop checks for unneeded ternary operators and conditions
It would be cool to have it enabled for all files
parent 84031c99
...@@ -626,17 +626,6 @@ Style/TernaryParentheses: ...@@ -626,17 +626,6 @@ Style/TernaryParentheses:
- 'spec/requests/api/pipeline_schedules_spec.rb' - 'spec/requests/api/pipeline_schedules_spec.rb'
- 'spec/support/capybara.rb' - 'spec/support/capybara.rb'
# Offense count: 8
# Cop supports --auto-correct.
Style/UnneededCondition:
Exclude:
- 'app/helpers/button_helper.rb'
- 'app/helpers/environment_helper.rb'
- 'app/models/project.rb'
- 'app/services/issuable/clone/base_service.rb'
- 'lib/gitlab/email/message/repository_push.rb'
- 'spec/lib/rspec_flaky/flaky_example_spec.rb'
# Offense count: 99 # Offense count: 99
# Cop supports --auto-correct. # Cop supports --auto-correct.
Style/UnneededInterpolation: Style/UnneededInterpolation:
......
...@@ -93,8 +93,8 @@ module ButtonHelper ...@@ -93,8 +93,8 @@ module ButtonHelper
content_tag (href ? :a : :span), content_tag (href ? :a : :span),
(href ? button_content : title), (href ? button_content : title),
class: "#{title.downcase}-selector #{active_class}", class: "#{title.downcase}-selector #{active_class}",
href: (href if href), href: href,
data: (data if data) data: data
end end
end end
......
...@@ -25,7 +25,7 @@ module EnvironmentHelper ...@@ -25,7 +25,7 @@ module EnvironmentHelper
def deployment_link(deployment, text: nil) def deployment_link(deployment, text: nil)
return unless deployment return unless deployment
link_label = text ? text : "##{deployment.iid}" link_label = text || "##{deployment.iid}"
link_to link_label, deployment_path(deployment) link_to link_label, deployment_path(deployment)
end end
......
...@@ -1179,11 +1179,7 @@ class Project < ApplicationRecord ...@@ -1179,11 +1179,7 @@ class Project < ApplicationRecord
end end
def issues_tracker def issues_tracker
if external_issue_tracker external_issue_tracker || default_issue_tracker
external_issue_tracker
else
default_issue_tracker
end
end end
def external_issue_reference_pattern def external_issue_reference_pattern
...@@ -1328,11 +1324,7 @@ class Project < ApplicationRecord ...@@ -1328,11 +1324,7 @@ class Project < ApplicationRecord
# rubocop: enable CodeReuse/ServiceClass # rubocop: enable CodeReuse/ServiceClass
def owner def owner
if group group || namespace.try(:owner)
group
else
namespace.try(:owner)
end
end end
def to_ability_name def to_ability_name
......
...@@ -47,7 +47,7 @@ module Issuable ...@@ -47,7 +47,7 @@ module Issuable
end end
def new_parent def new_parent
new_entity.project ? new_entity.project : new_entity.group new_entity.project || new_entity.group
end end
def group def group
......
...@@ -52,7 +52,7 @@ module Gitlab ...@@ -52,7 +52,7 @@ module Gitlab
end end
def compare def compare
@opts[:compare] if @opts[:compare] @opts[:compare]
end end
def diff_refs def diff_refs
......
...@@ -77,7 +77,7 @@ describe RspecFlaky::FlakyExample, :aggregate_failures do ...@@ -77,7 +77,7 @@ describe RspecFlaky::FlakyExample, :aggregate_failures do
it 'updates the first_flaky_at' do it 'updates the first_flaky_at' do
now = Time.now now = Time.now
expected_first_flaky_at = flaky_example.first_flaky_at ? flaky_example.first_flaky_at : now expected_first_flaky_at = flaky_example.first_flaky_at || now
Timecop.freeze(now) { flaky_example.update_flakiness! } Timecop.freeze(now) { flaky_example.update_flakiness! }
expect(flaky_example.first_flaky_at).to eq(expected_first_flaky_at) expect(flaky_example.first_flaky_at).to eq(expected_first_flaky_at)
......
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