Skip to content

Commit

Permalink
[frontend] Fix MultilineMethodCallBraceLayout offenses
Browse files Browse the repository at this point in the history
  • Loading branch information
David Kang committed Dec 18, 2017
1 parent fa92e5f commit 44ae09d
Show file tree
Hide file tree
Showing 29 changed files with 111 additions and 125 deletions.
7 changes: 0 additions & 7 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@
Layout/DotPosition:
Enabled: false

# Offense count: 66
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: symmetrical, new_line, same_line
Layout/MultilineMethodCallBraceLayout:
Enabled: false

# Offense count: 28
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
Expand Down
3 changes: 1 addition & 2 deletions src/api/app/helpers/comment_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ def comment_body(comment)
@md_parser ||= Redcarpet::Markdown.new(OBSApi::MarkdownRenderer.new(no_styles: true),
autolink: true,
no_intra_emphasis: true,
fenced_code_blocks: true, disable_indented_code_blocks: true
)
fenced_code_blocks: true, disable_indented_code_blocks: true)
@md_parser.render(comment.to_s).html_safe
end
end
3 changes: 1 addition & 2 deletions src/api/app/helpers/webui/buildresult_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ def arch_repo_table_cell(repo, arch, package_name, status = nil, enable_help = t
else
concat link_to(code.gsub(/\s/, ' '),
package_live_build_log_path(project: @project.to_s, package: package_name, repository: repo, arch: arch),
{ title: link_title, rel: 'nofollow' }
)
{ title: link_title, rel: 'nofollow' })
end

if enable_help && status['code']
Expand Down
3 changes: 2 additions & 1 deletion src/api/app/models/bs_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,8 @@ def update_cache
# Skipping Model validations in this case is fine as we only want to touch
# the associated user models to invalidate the cache keys
Group.joins(:relationships).where(relationships: { package_id: target_package_ids }).or(
Group.joins(:relationships).where(relationships: { project_id: target_project_ids })).update_all(updated_at: Time.now)
Group.joins(:relationships).where(relationships: { project_id: target_project_ids })
).update_all(updated_at: Time.now)
User.where(id: user_ids).update_all(updated_at: Time.now)
# rubocop:enable Rails/SkipsModelValidations
end
Expand Down
3 changes: 1 addition & 2 deletions src/api/app/models/channel_binary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ def create_channel_package_into(project, comment = nil)
channel = channel_binary_list.channel
package_exists = Package.exists_by_project_and_name(project.name, channel.name,
follow_project_links: false,
allow_remote_packages: false
)
allow_remote_packages: false)
# does it exist already? then just skip it
# create a channel package beside my package and return that
channel.branch_channel_package_into_project(project, comment) unless package_exists
Expand Down
3 changes: 2 additions & 1 deletion src/api/app/models/group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ def involved_reviews(search = nil)
roles: [:reviewer],
review_states: [:new],
states: [:review],
search: search)
search: search
)
end

def incoming_requests(search = nil)
Expand Down
6 changes: 2 additions & 4 deletions src/api/app/views/statistics/rating.xml.builder
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
if @package && @project
xml.rating(@rating[:score],
:count => @rating[:count], :project => @project, :package => @package,
:user_score => @rating[:user_score]
)
:user_score => @rating[:user_score])
elsif @project
xml.rating(@rating[:score],
:count => @rating[:count], :project => @project,
:user_score => @rating[:user_score]
)
:user_score => @rating[:user_score])
else
xml.rating
end
3 changes: 2 additions & 1 deletion src/api/app/views/webui/feeds/notifications.rss.builder
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ xml.rss version: '2.0' do
template: "event_mailer/#{notification.event.template_name}",
layout: false,
formats: :text,
locals: { event: notification.event.expanded_payload })
locals: { event: notification.event.expanded_payload }
)
xml.category "#{notification.event_type}/#{notification.subscription_receiver_role}"
xml.pubDate notification.created_at
xml.author @configuration['title']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ def self.up
binary_release: br.binary_release,
binary_epoch: br.binary_epoch,
binary_arch: br.binary_arch,
medium: br.medium
)
medium: br.medium)
unless added.length == 1
Rails.logger.error "ERROR: Unique added entry belonging to modified entry not found: #{br.id}"
next
Expand All @@ -31,8 +30,7 @@ def self.down
binary_release: br.binary_release,
binary_epoch: br.binary_epoch,
binary_arch: br.binary_arch,
medium: br.medium
)
medium: br.medium)
unless added.length == 1
Rails.logger.error "ERROR: Unique added entry belonging to modified entry not found: #{br.id}"
next
Expand Down
3 changes: 1 addition & 2 deletions src/api/lib/obsapi/markdown_renderer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ def preprocess(fulldoc)
# sanitize the HTML we get
Sanitize.fragment(fulldoc, Sanitize::Config.merge(Sanitize::Config::RESTRICTED,
elements: Sanitize::Config::RESTRICTED[:elements] + ['pre'],
remove_contents: true
))
remove_contents: true))
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@
subject! { get :index, params: { format: :xml, project: "#{remote}:my_project" } }

it 'forwards the request to the remote instance' do
expect(a_request(:get, maintenance_statistics_url(host: remote.remoteurl, project: 'my_project')
)).to have_been_made.once
expect(a_request(:get, maintenance_statistics_url(host: remote.remoteurl, project: 'my_project'))).to have_been_made.once
end

it 'responds with the xml received from the remote instance' do
Expand Down
75 changes: 34 additions & 41 deletions src/api/spec/controllers/webui/package_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,24 @@
repo
end
let(:fake_build_results) do
Buildresult.new(
'<resultlist state="2b71f05ecb8742e3cd7f6066a5097c72">
<result project="home:tom" repository="fake_repo_name" arch="i586" code="unknown" state="unknown" dirty="true">
<binarylist>
<binary filename="fake_binary_001"/>
<binary filename="fake_binary_002"/>
<binary filename="updateinfo.xml"/>
<binary filename="rpmlint.log"/>
</binarylist>
</result>
</resultlist>')
Buildresult.new('<resultlist state="2b71f05ecb8742e3cd7f6066a5097c72">
<result project="home:tom" repository="fake_repo_name" arch="i586" code="unknown" state="unknown" dirty="true">
<binarylist>
<binary filename="fake_binary_001"/>
<binary filename="fake_binary_002"/>
<binary filename="updateinfo.xml"/>
<binary filename="rpmlint.log"/>
</binarylist>
</result>
</resultlist>')
end
let(:fake_build_results_without_binaries) do
Buildresult.new(
'<resultlist state="2b71f05ecb8742e3cd7f6066a5097c72">
<result project="home:tom" repository="fake_repo_name" arch="i586" code="unknown" state="unknown" dirty="true">
<binarylist>
</binarylist>
</result>
</resultlist>')
Buildresult.new('<resultlist state="2b71f05ecb8742e3cd7f6066a5097c72">
<result project="home:tom" repository="fake_repo_name" arch="i586" code="unknown" state="unknown" dirty="true">
<binarylist>
</binarylist>
</result>
</resultlist>')
end

describe "POST #submit_request" do
Expand Down Expand Up @@ -405,13 +403,11 @@

context "adding a file that doesn't exist yet" do
before do
do_request(
project: source_project,
package: source_package,
filename: "newly_created_file",
file_type: "local",
file: "some_content"
)
do_request(project: source_project,
package: source_package,
filename: "newly_created_file",
file_type: "local",
file: "some_content")
end

it { expect(response).to have_http_status(expected_success_status) }
Expand All @@ -436,10 +432,8 @@

context "uploading a file from remote URL" do
before do
do_request(
project: source_project, package: source_package, filename: "remote_file",
file_url: "https://raw.github.com/openSUSE/open-build-service/master/.gitignore"
)
do_request(project: source_project, package: source_package, filename: "remote_file",
file_url: "https://raw.github.com/openSUSE/open-build-service/master/.gitignore")
end

after do
Expand Down Expand Up @@ -1044,12 +1038,10 @@ def do_request(params)
end

it 'redirects to the package binaries path' do
expect(response).to redirect_to(
controller: :package,
action: :binaries,
project: source_project,
package: source_package
)
expect(response).to redirect_to(controller: :package,
action: :binaries,
project: source_project,
package: source_package)
end
end

Expand Down Expand Up @@ -1111,8 +1103,9 @@ def do_request(params)
expect(flash[:error]).to match("no repository defined")
end
it {
expect(response).to redirect_to(package_live_build_log_path(
project: source_project, package: source_package, repository: 'foo', arch: 'bar'))
expect(response).to redirect_to(package_live_build_log_path(project: source_project,
package: source_package,
repository: 'foo', arch: 'bar'))
}
end

Expand Down Expand Up @@ -1159,8 +1152,8 @@ def do_request(params)

it { expect(flash[:error]).to eq("No statistics of a successful build could be found in #{repository}/i586") }
it {
expect(response).to redirect_to(package_binaries_path(
project: source_project, package: source_package, repository: repository.name, nextstatus: 404))
expect(response).to redirect_to(package_binaries_path(project: source_project, package: source_package,
repository: repository.name, nextstatus: 404))
}
end

Expand All @@ -1175,8 +1168,8 @@ def do_request(params)

it { expect(flash[:error]).to eq("No statistics of a successful build could be found in #{repository}/i586") }
it {
expect(response).to redirect_to(package_binaries_path(
project: source_project, package: source_package, repository: repository.name, nextstatus: 404))
expect(response).to redirect_to(package_binaries_path(project: source_project, package: source_package,
repository: repository.name, nextstatus: 404))
}
end
end
Expand Down
6 changes: 4 additions & 2 deletions src/api/spec/controllers/webui/patchinfo_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ def do_proper_post_save
<binary filename="rpmlint.log"/>
</binarylist>
</result>
</resultlist>')
</resultlist>'
)
end

let(:fake_patchinfo_with_binaries) do
Expand All @@ -44,7 +45,8 @@ def do_proper_post_save
<summary/>
<description/>
<binary>fake_binary_001</binary>
</patchinfo>')
</patchinfo>'
)
end

after do
Expand Down
3 changes: 2 additions & 1 deletion src/api/spec/controllers/webui/project_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1434,7 +1434,8 @@
<status package="c++" code="succeeded" />
<status package="redis" code="succeeded" />
</result>
</resultlist>')
</resultlist>'
)
end
let(:statushash) do
{ "openSUSE_Tumbleweed" => {
Expand Down
3 changes: 1 addition & 2 deletions src/api/spec/controllers/webui/request_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@
subject do
BsRequest.joins(:bs_request_actions).
where("bs_request_actions.target_project=? AND bs_request_actions.target_package=? AND type=?",
target_project.to_s, target_package.to_s, "delete"
).first
target_project.to_s, target_package.to_s, "delete").first
end

it { expect(response).to redirect_to(request_show_path(number: subject)) }
Expand Down
15 changes: 10 additions & 5 deletions src/api/spec/factories/bs_requests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
target_project: evaluator.target_project,
target_package: evaluator.target_package,
source_project: evaluator.source_project,
source_package: evaluator.source_package)
source_package: evaluator.source_package
)
end
end

Expand All @@ -49,7 +50,8 @@
target_project: evaluator.target_project,
target_package: evaluator.target_package,
source_project: evaluator.source_project,
source_package: evaluator.source_package)
source_package: evaluator.source_package
)
request.state = 'declined'
request.save!
end
Expand All @@ -63,7 +65,8 @@
target_project: evaluator.target_project,
target_package: evaluator.target_package,
source_project: evaluator.source_project,
source_package: evaluator.source_package)
source_package: evaluator.source_package
)
request.reviews << Review.new(by_user: evaluator.reviewer)
request.state = 'review'
request.save!
Expand All @@ -78,7 +81,8 @@
target_project: evaluator.target_project,
target_package: evaluator.target_package,
source_project: evaluator.source_project,
source_package: evaluator.source_package)
source_package: evaluator.source_package
)
end
end

Expand All @@ -90,7 +94,8 @@
target_project: evaluator.target_project,
target_package: evaluator.target_package,
source_project: evaluator.source_project,
source_package: evaluator.source_package)
source_package: evaluator.source_package
)
end
end
end
Expand Down
3 changes: 2 additions & 1 deletion src/api/spec/features/webui/packages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@

expect(page).to have_text("Successfully branched package")
expect(page.current_path).to eq(
package_show_path(project: user.branch_project_name(other_user.home_project_name), package: other_users_package))
package_show_path(project: user.branch_project_name(other_user.home_project_name), package: other_users_package)
)
end
end

Expand Down
9 changes: 3 additions & 6 deletions src/api/spec/helpers/webui/request_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
target_project: target_project,
target_package: 'does-not-exist-yet',
source_project: source_project,
source_package: source_package
)
source_package: source_package)
end
let(:row) { BsRequest::DataTable::Row .new(bs_request_with_submit_action) }

Expand All @@ -28,8 +27,7 @@
target_project: target_project,
target_package: target_package,
source_project: source_project,
source_package: source_package
)
source_package: source_package)
end
let(:row) { BsRequest::DataTable::Row .new(bs_request_with_maintenance_release_action) }

Expand All @@ -42,8 +40,7 @@
target_project: target_project,
target_package: target_package,
source_project: source_project,
source_package: source_package
)
source_package: source_package)
end
let(:row) { BsRequest::DataTable::Row .new(bs_request_with_submit_action) }

Expand Down
Loading

0 comments on commit 44ae09d

Please sign in to comment.