Skip to content

Commit

Permalink
Merge pull request #4244 from DavidKang/feature/rubocop/layout_indent…
Browse files Browse the repository at this point in the history
…ation

Rubocop is your friend part 7
  • Loading branch information
bgeuken committed Dec 19, 2017
2 parents 18f40e2 + 6c5ef05 commit 53856c6
Show file tree
Hide file tree
Showing 53 changed files with 296 additions and 329 deletions.
24 changes: 0 additions & 24 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,6 @@
Layout/DotPosition:
Enabled: false

# Offense count: 88
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
# SupportedStyles: special_inside_parentheses, consistent, align_braces
Layout/IndentHash:
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 All @@ -45,16 +31,6 @@ Layout/MultilineMethodCallIndentation:
- 'src/api/test/unit/issue_test.rb'
- 'src/api/test/unit/user_test.rb'

# Offense count: 91
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
# SupportedStyles: aligned, indented
Layout/MultilineOperationIndentation:
Enabled: false

- 'src/api/spec/controllers/webui/project_controller_spec.rb'
- 'src/api/spec/models/comment_spec.rb'

# Offense count: 3
Lint/DuplicateMethods:
Exclude:
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/controllers/webui/package_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,8 @@ def branch
end

branch_params = {
project: source_project_name,
package: source_package_name
project: source_project_name,
package: source_package_name
}

# Set the branch to the current revision if revision is present
Expand Down
10 changes: 5 additions & 5 deletions src/api/app/controllers/webui/request_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,11 @@ def change_devel_request
BsRequest.transaction do
req = BsRequest.new(state: "new", description: params[:description])
action = BsRequestActionChangeDevel.new({
target_project: params[:project],
target_package: params[:package],
source_project: params[:devel_project],
source_package: params[:devel_package] || params[:package]
})
target_project: params[:project],
target_package: params[:package],
source_project: params[:devel_project],
source_package: params[:devel_package] || params[:package]
})

req.bs_request_actions << action
action.bs_request = req
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/, '&nbsp;'),
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
6 changes: 3 additions & 3 deletions src/api/app/helpers/webui/project_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ def remove_parent_name(project_name, parent_name)
end

STATE_ICONS = {
'new' => 'flag_green',
'review' => 'flag_yellow',
'declined' => 'flag_red'
'new' => 'flag_green',
'review' => 'flag_yellow',
'declined' => 'flag_red'
}.freeze

def map_request_state_to_flag(state)
Expand Down
19 changes: 10 additions & 9 deletions src/api/app/models/bs_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1002,8 +1002,8 @@ def apply_default_reviewers
reviewers += action.default_reviewers

action.create_post_permissions_hook({
per_package_locking: @per_package_locking
})
per_package_locking: @per_package_locking
})
end

# apply reviewers
Expand Down 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 Expand Up @@ -1187,12 +1188,12 @@ def check_bs_request_actions!(opts = {})
return unless persisted? && priority_changed?

HistoryElement::RequestPriorityChange.create({
request: self,
# We need to have a user here
user: User.find_nobody!,
description_extension: "#{priority_was} => #{priority}",
comment: "Automatic priority bump: Priority of related action increased."
})
request: self,
# We need to have a user here
user: User.find_nobody!,
description_extension: "#{priority_was} => #{priority}",
comment: "Automatic priority bump: Priority of related action increased."
})
end

def _assignreview_update_reviews(reviewer, opts, new_review = nil)
Expand Down
12 changes: 6 additions & 6 deletions src/api/app/models/bs_request/data_table/params_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ def order_params
def sort_columns
# defaults to :created_at
{
0 => %w(bs_requests.created_at),
1 => %w(bs_request_actions.source_project bs_request_actions.source_package),
2 => %w(bs_request_actions.target_project bs_request_actions.target_package),
3 => %w(bs_requests.creator),
4 => %w(bs_request_actions.type),
5 => %w(bs_requests.priority)
0 => %w(bs_requests.created_at),
1 => %w(bs_request_actions.source_project bs_request_actions.source_package),
2 => %w(bs_request_actions.target_project bs_request_actions.target_package),
3 => %w(bs_requests.creator),
4 => %w(bs_request_actions.type),
5 => %w(bs_requests.priority)
}[order_params.fetch(:column, nil).to_i]
end

Expand Down
4 changes: 2 additions & 2 deletions src/api/app/models/bs_request_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ class VersionReleaseDiffers < APIException; end
validates :sourceupdate, inclusion: { in: VALID_SOURCEUPDATE_OPTIONS, allow_nil: true }
validate :check_sanity
validates :type, uniqueness: {
scope: [:target_project, :target_package, :bs_request_id],
conditions: -> { where.not(type: ['add_role', 'maintenance_incident']) }
scope: [:target_project, :target_package, :bs_request_id],
conditions: -> { where.not(type: ['add_role', 'maintenance_incident']) }
}

before_validation :set_target_associations
Expand Down
38 changes: 19 additions & 19 deletions src/api/app/models/buildresult.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,25 @@ class Buildresult < ActiveXML::Node
}.freeze

STATUS_DESCRIPTION = {
succeeded: "Package has built successfully and can be used to build further packages.",
failed: "The package does not build successfully. No packages have been created. Packages " +
"that depend on this package will be built using any previously created packages, if they exist.",
unresolvable: "The build can not begin, because required packages are either missing or not explicitly defined.",
broken: "The sources either contain no build description (e.g. specfile), automatic source processing failed or a " +
"merge conflict does exist.",
blocked: "This package waits for other packages to be built. These can be in the same or other projects.",
scheduled: "A package has been marked for building, but the build has not started yet.",
dispatching: "A package is being copied to a build host. This is an intermediate state before building.",
building: "The package is currently being built.",
signing: "The package has been built successfully and is assigned to get signed.",
finished: "The package has been built and signed, but has not yet been picked up by the scheduler. This is an " +
"intermediate state prior to 'succeeded' or 'failed'.",
disabled: "The package has been disabled from building in project or package metadata. " +
"Packages that depend on this package will be built using any previously created packages, if they still exist.",
excluded: "The package build has been disabled in package build description (for example in the .spec file) or " +
"does not provide a matching build description for the target.",
locked: "The package is frozen",
unknown: "The scheduler has not yet evaluated this package. Should be a short intermediate state for new packages."
succeeded: "Package has built successfully and can be used to build further packages.",
failed: "The package does not build successfully. No packages have been created. Packages " +
"that depend on this package will be built using any previously created packages, if they exist.",
unresolvable: "The build can not begin, because required packages are either missing or not explicitly defined.",
broken: "The sources either contain no build description (e.g. specfile), automatic source processing failed or a " +
"merge conflict does exist.",
blocked: "This package waits for other packages to be built. These can be in the same or other projects.",
scheduled: "A package has been marked for building, but the build has not started yet.",
dispatching: "A package is being copied to a build host. This is an intermediate state before building.",
building: "The package is currently being built.",
signing: "The package has been built successfully and is assigned to get signed.",
finished: "The package has been built and signed, but has not yet been picked up by the scheduler. This is an " +
"intermediate state prior to 'succeeded' or 'failed'.",
disabled: "The package has been disabled from building in project or package metadata. " +
"Packages that depend on this package will be built using any previously created packages, if they still exist.",
excluded: "The package build has been disabled in package build description (for example in the .spec file) or " +
"does not provide a matching build description for the target.",
locked: "The package is frozen",
unknown: "The scheduler has not yet evaluated this package. Should be a short intermediate state for new packages."
}.with_indifferent_access.freeze

def self.status_description(status)
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: 3 additions & 3 deletions src/api/app/models/issue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ class NotFoundError < APIException

def self.find_or_create_by_name_and_tracker(name, issue_tracker_name, force_update = nil)
find_by_name_and_tracker(name, issue_tracker_name, {
force_update: force_update,
create_missing: true
})
force_update: force_update,
create_missing: true
})
end

def self.find_by_name_and_tracker(name, issue_tracker_name, options = {})
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1583,7 +1583,7 @@ def self.validate_link_xml_attribute(request_data, project_name)
target_project.disabled_for?('access', nil, nil) &&
!FlagHelper.xml_disabled_for?(request_data, 'access')
return {
error: "Project links work only when both projects have same read access protection level: #{project_name} -> #{target_project_name}"
error: "Project links work only when both projects have same read access protection level: #{project_name} -> #{target_project_name}"
}
end
logger.debug "Project #{project_name} link checked against #{target_project_name} projects permission"
Expand Down
12 changes: 6 additions & 6 deletions src/api/app/models/project/update_from_xml_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -304,12 +304,12 @@ def update_download_repositories(current_repo, xml_hash)

dod_repositories = xml_hash.elements("download").map do |dod|
dod_attributes = {
repository: current_repo,
arch: dod["arch"],
url: dod["url"],
repotype: dod["repotype"],
archfilter: dod["archfilter"],
pubkey: dod["pubkey"]
repository: current_repo,
arch: dod["arch"],
url: dod["url"],
repotype: dod["repotype"],
archfilter: dod["archfilter"],
pubkey: dod["pubkey"]
}
if dod["master"]
dod_attributes[:masterurl] = dod["master"]["url"]
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
2 changes: 1 addition & 1 deletion src/api/lib/backend/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def self.put(path, data, in_headers = {})

def self.post(path, data = nil, in_headers = {})
in_headers = {
'Content-Type' => 'application/octet-stream'
'Content-Type' => 'application/octet-stream'
}.merge in_headers
put_or_post("POST", path, data, in_headers)
end
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
2 changes: 1 addition & 1 deletion src/api/lib/xpath_engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def initialize
'@email' => { cpart: 'users.email' },
'@realname' => { cpart: 'users.realname' },
'@state' => { cpart: 'users.state' }
},
},
'issues' => {
'@name' => { cpart: 'issues.name' },
'@state' => { cpart: 'issues.state' },
Expand Down
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
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
id: kiwi_repository.id,
repo_type: 'apt2-deb',
source_path: 'htt://example.com'
}
}
}
}
}
Expand Down
Loading

0 comments on commit 53856c6

Please sign in to comment.