Skip to content

Commit

Permalink
Merge pull request #209 from sul-dlss/rubocop
Browse files Browse the repository at this point in the history
Update rubocop to 0.65.0
  • Loading branch information
jcoyne committed Mar 13, 2019
2 parents 32b88ce + 2a754e2 commit fb4bef3
Show file tree
Hide file tree
Showing 21 changed files with 90 additions and 171 deletions.
102 changes: 9 additions & 93 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,87 +1,11 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2019-03-13 10:55:45 -0400 using RuboCop version 0.57.2.
# on 2019-03-13 10:32:54 -0500 using RuboCop version 0.65.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 5
# Cop supports --auto-correct.
# Configuration parameters: Include, TreatCommentsAsGroupSeparators.
# Include: **/*.gemfile, **/Gemfile, **/gems.rb
Bundler/OrderedGems:
Exclude:
- 'Gemfile'

# Offense count: 3
# Cop supports --auto-correct.
Layout/EmptyLines:
Exclude:
- 'config/environments/development.rb'
- 'config/environments/production.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: empty_lines, no_empty_lines
Layout/EmptyLinesAroundBlockBody:
Exclude:
- 'spec/services/registration_service_spec.rb'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: IndentationWidth.
# SupportedStyles: special_inside_parentheses, consistent, align_brackets
Layout/IndentArray:
EnforcedStyle: consistent

# Offense count: 1
# Cop supports --auto-correct.
Layout/MultilineBlockLayout:
Exclude:
- 'spec/controllers/workflows_controller_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
Layout/SpaceAfterComma:
Exclude:
- 'spec/rails_helper.rb'

# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment.
Layout/SpaceAroundOperators:
Exclude:
- 'spec/rails_helper.rb'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets.
# SupportedStyles: space, no_space, compact
# SupportedStylesForEmptyBrackets: space, no_space
Layout/SpaceInsideArrayLiteralBrackets:
Exclude:
- 'config/environments/production.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: final_newline, final_blank_line
Layout/TrailingBlankLines:
Exclude:
- 'spec/rails_helper.rb'

# Offense count: 12
# Cop supports --auto-correct.
# Configuration parameters: AllowInHeredoc.
Layout/TrailingWhitespace:
Exclude:
- 'app/controllers/sdr_controller.rb'
- 'app/controllers/workflows_controller.rb'
- 'config/routes.rb'
- 'spec/support/auth_helper.rb'

# Offense count: 1
Lint/AmbiguousBlockAssociation:
Exclude:
Expand Down Expand Up @@ -119,7 +43,7 @@ Metrics/CyclomaticComplexity:
Max: 24

# Offense count: 20
# Configuration parameters: CountComments.
# Configuration parameters: CountComments, ExcludedMethods.
Metrics/MethodLength:
Max: 58

Expand All @@ -142,7 +66,7 @@ Naming/HeredocDelimiterNaming:

# Offense count: 2
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
# AllowedNames: io, id, to, by, on, in, at
# AllowedNames: io, id, to, by, on, in, at, ip, db
Naming/UncommunicativeMethodParamName:
Exclude:
- 'spec/rails_helper.rb'
Expand Down Expand Up @@ -186,6 +110,7 @@ RSpec/DescribeClass:
- 'spec/requests/about_spec.rb'

# Offense count: 32
# Cop supports --auto-correct.
# Configuration parameters: SkipBlocks, EnforcedStyle.
# SupportedStyles: described_class, explicit
RSpec/DescribedClass:
Expand All @@ -196,13 +121,15 @@ RSpec/DescribedClass:
- 'spec/dor/update_marc_record_service_spec.rb'

# Offense count: 8
# Cop supports --auto-correct.
RSpec/EmptyLineAfterFinalLet:
Exclude:
- 'spec/controllers/sdr_controller_spec.rb'
- 'spec/dor/update_marc_record_service_spec.rb'
- 'spec/models/symphony_reader_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
RSpec/EmptyLineAfterSubject:
Exclude:
- 'spec/models/symphony_reader_spec.rb'
Expand Down Expand Up @@ -257,13 +184,15 @@ RSpec/NestedGroups:
Max: 5

# Offense count: 7
# Cop supports --auto-correct.
# Configuration parameters: Strict, EnforcedStyle.
# SupportedStyles: inflected, explicit
RSpec/PredicateMatcher:
Exclude:
- 'spec/dor/update_marc_record_service_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: and_return, block
RSpec/ReturnFromStub:
Expand All @@ -283,7 +212,7 @@ RSpec/SubjectStub:
- 'spec/dor/update_marc_record_service_spec.rb'

# Offense count: 17
# Configuration parameters: IgnoreSymbolicNames.
# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
RSpec/VerifiedDoubles:
Exclude:
- 'spec/controllers/objects_controller_spec.rb'
Expand Down Expand Up @@ -355,19 +284,6 @@ Style/GuardClause:
Exclude:
- 'config/initializers/okcomputer.rb'

# Offense count: 43
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
Style/HashSyntax:
Exclude:
- 'app/controllers/sdr_controller.rb'
- 'app/models/dor/goobi.rb'
- 'spec/controllers/objects_controller_spec.rb'
- 'spec/dor/registration_response_spec.rb'
- 'spec/dor/service_item_spec.rb'
- 'spec/rails_helper.rb'

# Offense count: 2
# Cop supports --auto-correct.
Style/IfUnlessModifier:
Expand Down
14 changes: 7 additions & 7 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ group :development do
end

# Ruby general dependencies
gem 'okcomputer'
gem 'config'
gem 'honeybadger'
gem 'okcomputer'

gem 'faraday'
gem 'rest-client'
# Pin net-http-persistent to avoid a problem with exhausting file handles when running under load
gem 'net-http-persistent', '~> 2.9'
gem 'marc'
gem 'net-http-persistent', '~> 2.9'
gem 'uuidtools', '~> 2.1.4'

# DLSS/domain-specific dependencies
Expand All @@ -39,14 +39,14 @@ group :production do
end

group :test, :development do
gem 'rspec-rails'
gem 'rails-controller-testing'
gem 'coveralls', '~> 0.8', require: false
gem 'simplecov'
gem 'equivalent-xml'
gem 'rack-console'
gem 'rubocop', '~> 0.57.1'
gem 'rubocop-rspec', '~> 1.27.0'
gem 'rails-controller-testing'
gem 'rspec-rails'
gem 'rubocop', '~> 0.65.0'
gem 'rubocop-rspec', '~> 1.32.0'
gem 'simplecov'
gem 'webmock'
end

Expand Down
24 changes: 13 additions & 11 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ GEM
i18n (1.5.3)
concurrent-ruby (~> 1.0)
iso-639 (0.2.8)
jaro_winkler (1.5.1)
jaro_winkler (1.5.2)
json (2.1.0)
link_header (0.0.8)
listen (3.0.8)
Expand Down Expand Up @@ -265,10 +265,11 @@ GEM
activesupport
nokogiri (>= 1.4.2)
solrizer (~> 3.3)
parallel (1.12.1)
parser (2.5.3.0)
parallel (1.14.0)
parser (2.6.0.0)
ast (~> 2.4.0)
powerpack (0.1.2)
psych (3.1.0)
public_suffix (3.0.3)
puma (3.12.0)
rack (2.0.6)
Expand Down Expand Up @@ -354,16 +355,17 @@ GEM
rspec-mocks (~> 3.8.0)
rspec-support (~> 3.8.0)
rspec-support (3.8.0)
rubocop (0.57.2)
rubocop (0.65.0)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.5)
parser (>= 2.5, != 2.5.1.1)
powerpack (~> 0.1)
psych (>= 3.1.0)
rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
rubocop-rspec (1.27.0)
rubocop (>= 0.56.0)
unicode-display_width (~> 1.4.0)
rubocop-rspec (1.32.0)
rubocop (>= 0.60.0)
ruby-cache (0.3.0)
ruby-oci8 (2.2.6.1)
ruby-progressbar (1.10.0)
Expand Down Expand Up @@ -425,7 +427,7 @@ GEM
unf (0.1.4)
unf_ext
unf_ext (0.0.7.5)
unicode-display_width (1.4.0)
unicode-display_width (1.4.1)
uuidtools (2.1.5)
webmock (3.4.2)
addressable (>= 2.3.6)
Expand Down Expand Up @@ -468,8 +470,8 @@ DEPENDENCIES
rails-controller-testing
rest-client
rspec-rails
rubocop (~> 0.57.1)
rubocop-rspec (~> 1.27.0)
rubocop (~> 0.65.0)
rubocop-rspec (~> 1.32.0)
ruby-oci8
simplecov
spring
Expand Down
1 change: 1 addition & 0 deletions app/controllers/content_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class ContentController < ApplicationController
def read
location = druid_tools.find(:content, params[:path])
return render status: :not_found unless location

send_file location
end

Expand Down
10 changes: 5 additions & 5 deletions app/controllers/sdr_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def cm_inv_diff
request.body.rewind
current_content = request.body.read

query_params = { :subset => params[:subset].to_s }
query_params = { subset: params[:subset].to_s }
query_params[:version] = params[:version].to_s unless params[:version].nil?
query_string = URI.encode_www_form(query_params)
sdr_query = "objects/#{params[:druid]}/cm-inv-diff?#{query_string}"
Expand All @@ -22,26 +22,26 @@ def ds_manifest
sdr_response = sdr_client[url].get { |response, _request, _result| response }
proxy_rest_client_response(sdr_response)
end

def ds_metadata
url = "objects/#{params[:druid]}/metadata/#{params[:dsname]}"
sdr_response = sdr_client[url].get { |response, _request, _result| response }
proxy_rest_client_response(sdr_response)
end

def current_version
sdr_response = sdr_client["objects/#{params[:druid]}/current_version"].get { |response, _request, _result| response }
proxy_rest_client_response(sdr_response)
end

def file_content
query_string = URI.encode_www_form(version: params[:version].to_s)
encoded_filename = URI.encode(params[:filename])
url = "objects/#{params[:druid]}/content/#{encoded_filename}?#{query_string}"
sdr_response = sdr_client[url].get { |response, _request, _result| response }
proxy_rest_client_response(sdr_response)
end

private

def sdr_client
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/versions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def build_error(err)
errors: [
{
"status": '422',
"title": 'Unable to open version',
"title": 'Unable to open version',
"detail": err.message
}
]
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/workflows_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ class WorkflowsController < ApplicationController
def initial
render content_type: 'application/xml', body: Dor::WorkflowObject.initial_workflow(params[:wf_name])
end

def archive
version = params.fetch(:ver_num) { @item.current_version }
archiver.archive_one_datastream 'dor', params[:object_id], params[:id], version

render plain: "#{params[:id]} version #{version} archived"
end

private

def archiver
Expand Down
12 changes: 6 additions & 6 deletions app/models/dor/goobi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ class Goobi < ServiceItem
def register
handler = proc do |exception, attempt_number, _total_delay|
if attempt_number >= Dor::Config.goobi.max_tries
throw :error, :message => "#{exception.class} on goobi notification web service call #{attempt_number} for #{@druid_obj.id}", :status => 500
throw :error, message: "#{exception.class} on goobi notification web service call #{attempt_number} for #{@druid_obj.id}", status: 500
end
end

# rubocop:disable Metrics/LineLength
with_retries(max_tries: Dor::Config.goobi.max_tries, handler: handler, base_sleep_seconds: Dor::Config.goobi.base_sleep_seconds, max_sleep_seconds: Dor::Config.goobi.max_sleep_seconds) do |_attempt|
response = RestClient.post(Dor::Config.goobi.url, xml_request, :content_type => 'application/xml') { |resp, _request, _result| resp }
response = RestClient.post(Dor::Config.goobi.url, xml_request, content_type: 'application/xml') { |resp, _request, _result| resp }
response
end
# rubocop:enable Metrics/LineLength
Expand All @@ -25,14 +25,14 @@ def xml_request
<stanfordCreationRequest>
<objectId>#{@druid_obj.id}</objectId>
<objectType>#{object_type}</objectType>
<sourceID>#{@druid_obj.source_id.encode(:xml => :text)}</sourceID>
<title>#{title_or_label.encode(:xml => :text)}</title>
<sourceID>#{@druid_obj.source_id.encode(xml: :text)}</sourceID>
<title>#{title_or_label.encode(xml: :text)}</title>
<contentType>#{content_type}</contentType>
<project>#{project_name.encode(:xml => :text)}</project>
<project>#{project_name.encode(xml: :text)}</project>
<catkey>#{ckey}</catkey>
<barcode>#{barcode}</barcode>
<collectionId>#{collection_id}</collectionId>
<collectionName>#{collection_name.encode(:xml => :text)}</collectionName>
<collectionName>#{collection_name.encode(xml: :text)}</collectionName>
<sdrWorkflow>#{Dor::Config.goobi.dpg_workflow_name}</sdrWorkflow>
<goobiWorkflow>#{goobi_workflow_name}</goobiWorkflow>
<ocr>#{goobi_ocr_tag_present?}</ocr>
Expand Down

0 comments on commit fb4bef3

Please sign in to comment.