diff --git a/.rubocop.yml b/.rubocop.yml index 6b221c3..751c3d9 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -29,3 +29,9 @@ Metrics/MethodLength: Metrics/ModuleLength: Exclude: - 'spec/**/*' + +Style/TrailingCommaInArrayLiteral: + EnforcedStyleForMultiline: consistent_comma + +Style/TrailingCommaInHashLiteral: + EnforcedStyleForMultiline: consistent_comma diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 5cc2840..dd1cfe4 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -6,13 +6,6 @@ # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: with_first_element, with_fixed_indentation -Layout/ArrayAlignment: - Exclude: - - 'lib/heathen/processor_methods/convert_image.rb' - # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: special_inside_parentheses, consistent, align_braces @@ -505,29 +498,6 @@ Style/TrailingCommaInArguments: - 'lib/heathen/processor_methods/libreoffice.rb' - 'lib/heathen/processor_methods/tesseract.rb' -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyleForMultiline. -# SupportedStylesForMultiline: comma, consistent_comma, no_comma -Style/TrailingCommaInArrayLiteral: - Exclude: - - 'lib/heathen/processor_methods/wkhtmltopdf.rb' - - 'spec/lib/utils_spec.rb' - -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyleForMultiline. -# SupportedStylesForMultiline: comma, consistent_comma, no_comma -Style/TrailingCommaInHashLiteral: - Exclude: - - 'lib/app.rb' - - 'lib/autoheathen/email_processor.rb' - - 'lib/document.rb' - - 'lib/heathen/processor_methods/libreoffice.rb' - - 'lib/sidekiq_workers.rb' - - 'spec/lib/app_spec.rb' - - 'spec/lib/autoheathen/config_spec.rb' - - 'spec/lib/autoheathen/email_processor_spec.rb' - - 'spec/lib/utils_spec.rb' - # This cop supports safe autocorrection (--autocorrect). Style/VariableInterpolation: Exclude: diff --git a/lib/heathen/processor_methods/convert_image.rb b/lib/heathen/processor_methods/convert_image.rb index f29a861..ce9994f 100644 --- a/lib/heathen/processor_methods/convert_image.rb +++ b/lib/heathen/processor_methods/convert_image.rb @@ -9,10 +9,12 @@ def convert_image(to: 'tiff', params: '') target_file = temp_file_name '', ".#{to.to_s}" executioner.execute( - *[Colore::C_.convert_path, - job.content_file, - params.split(/ +/), - target_file].flatten + *[ + Colore::C_.convert_path, + job.content_file, + params.split(/ +/), + target_file, + ].flatten ) raise ConversionFailed.new if executioner.last_exit_status != 0 diff --git a/lib/heathen/processor_methods/libreoffice.rb b/lib/heathen/processor_methods/libreoffice.rb index 736304f..81d11cb 100644 --- a/lib/heathen/processor_methods/libreoffice.rb +++ b/lib/heathen/processor_methods/libreoffice.rb @@ -35,8 +35,8 @@ def libreoffice(format:) 'application/vnd.openxmlformats-officedocument.presentationml.presentation' => 'odp', }, 'txt' => { - '.*' => 'txt' - } + '.*' => 'txt', + }, } raise InvalidParameterInStep.new('format', format) unless suffixes[format.to_s] diff --git a/lib/sidekiq_workers.rb b/lib/sidekiq_workers.rb index 5ba5049..697db08 100644 --- a/lib/sidekiq_workers.rb +++ b/lib/sidekiq_workers.rb @@ -95,7 +95,7 @@ class LegacyPurgeWorker ::Sidekiq::Cron::Job.load_from_hash('legacy_purge_worker' => { 'cron' => '0 6 * * *', - 'class' => self.name + 'class' => self.name, }) # Looks for old legacy docs and deletes them diff --git a/spec/helpers/mime_types.rb b/spec/helpers/mime_types.rb index b75dd4a..1dbb603 100644 --- a/spec/helpers/mime_types.rb +++ b/spec/helpers/mime_types.rb @@ -4,14 +4,14 @@ def ms_excel_mime_types [ 'application/octet-stream; charset=binary', # LibreOffice 5.1 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=binary', - 'application/zip; charset=binary' # LibreOffice 6.0.7 + 'application/zip; charset=binary', # LibreOffice 6.0.7 ] end def ms_powerpoint_mime_types [ 'application/octet-stream; charset=binary', # LibreOffice 6.0.7 - 'application/vnd.openxmlformats-officedocument.presentationml.presentation; charset=binary' + 'application/vnd.openxmlformats-officedocument.presentationml.presentation; charset=binary', ] end @@ -19,7 +19,7 @@ def ms_word_mime_types [ 'application/octet-stream; charset=binary', # LibreOffice 6.0.7 'application/vnd.openxmlformats-officedocument.wordprocessingml.document; charset=binary', - 'application/zip; charset=binary' + 'application/zip; charset=binary', ] end @@ -38,6 +38,6 @@ def oo_odt_mime_types def tesseract_hocr_mime_types [ 'application/xml; charset=us-ascii', # tesseract v3 - 'text/xml; charset=us-ascii' # tesseract v4 + 'text/xml; charset=us-ascii', # tesseract v4 ] end diff --git a/spec/lib/app_spec.rb b/spec/lib/app_spec.rb index 81191d1..8a7359a 100644 --- a/spec/lib/app_spec.rb +++ b/spec/lib/app_spec.rb @@ -39,7 +39,7 @@ def show_backtrace(response) file: Rack::Test::UploadedFile.new(__FILE__, 'application/ruby'), actions: ['ocr', 'pdf'], author: author, - backtrace: true + backtrace: true, } show_backtrace last_response expect(last_response.status).to eq 201 @@ -54,7 +54,7 @@ def show_backtrace(response) title: 'A title', file: Rack::Test::UploadedFile.new(__FILE__, 'application/ruby'), actions: ['ocr', 'pdf'], - backtrace: true + backtrace: true, } show_backtrace last_response expect(last_response.status).to eq 409 @@ -69,7 +69,7 @@ def show_backtrace(response) post "/document/#{appname}/#{doc_id}/#{filename}", { file: Rack::Test::UploadedFile.new(__FILE__, 'application/ruby'), actions: ['ocr', 'pdf'], - backtrace: true + backtrace: true, } show_backtrace last_response expect(last_response.status).to eq 201 @@ -85,7 +85,7 @@ def show_backtrace(response) file: Rack::Test::UploadedFile.new(__FILE__, 'application/ruby'), actions: ['ocr', 'pdf'], author: author, - backtrace: true + backtrace: true, } expect(last_response.status).to eq 404 expect(last_response.content_type).to eq 'application/json' @@ -115,7 +115,7 @@ def show_backtrace(response) context 'POST new conversion' do it 'starts a new conversion' do post "/document/#{appname}/#{doc_id}/current/#{filename}/ocr", { - backtrace: true + backtrace: true, } show_backtrace last_response expect(last_response.status).to eq 202 @@ -127,7 +127,7 @@ def show_backtrace(response) end it 'fails if invalid document' do post "/document/#{appname}/#{invalid_doc_id}/current/#{filename}/ocr", { - backtrace: true + backtrace: true, } show_backtrace last_response expect(last_response.status).to eq 404 @@ -137,7 +137,7 @@ def show_backtrace(response) end it 'fails if invalid version' do post "/document/#{appname}/#{doc_id}/fred/#{filename}/ocr", { - backtrace: true + backtrace: true, } show_backtrace last_response expect(last_response.status).to eq 400 @@ -150,7 +150,7 @@ def show_backtrace(response) context 'DELETE document' do it 'runs' do delete "/document/#{appname}/#{doc_id}", { - deleted_by: 'a.person' + deleted_by: 'a.person', } show_backtrace last_response expect(last_response.status).to eq 200 @@ -164,7 +164,7 @@ def show_backtrace(response) context 'DELETE document version' do it 'runs' do delete "/document/#{appname}/#{doc_id}/v001", { - deleted_by: 'a.person' + deleted_by: 'a.person', } show_backtrace last_response expect(last_response.status).to eq 200 @@ -175,7 +175,7 @@ def show_backtrace(response) end it 'fails if you try to delete current' do delete "/document/#{appname}/#{doc_id}/current", { - deleted_by: 'a.person' + deleted_by: 'a.person', } show_backtrace last_response expect(last_response.status).to eq 400 @@ -184,7 +184,7 @@ def show_backtrace(response) end it 'fails if you try to delete the current version' do delete "/document/#{appname}/#{doc_id}/v002", { - deleted_by: 'a.person' + deleted_by: 'a.person', } show_backtrace last_response expect(last_response.status).to eq 400 @@ -235,7 +235,7 @@ def show_backtrace(response) context 'when file is nil' do it 'returns an error' do params = { - file: nil + file: nil, } post "/convert", params expect(last_response.status).to eq 400 @@ -247,7 +247,7 @@ def show_backtrace(response) context 'when file is not correct' do it 'returns an error' do params = { - file: "I'm definitely not a file" + file: "I'm definitely not a file", } post "/convert", params expect(last_response.status).to eq 400 diff --git a/spec/lib/autoheathen/config_spec.rb b/spec/lib/autoheathen/config_spec.rb index 1f36502..8b7468f 100644 --- a/spec/lib/autoheathen/config_spec.rb +++ b/spec/lib/autoheathen/config_spec.rb @@ -47,8 +47,8 @@ 'horse' => { 'duck' => :duckle, 'fish' => 'fishle', - 'eagle' => ['the', 'quick', 'brown', 'fox'] - } + 'eagle' => ['the', 'quick', 'brown', 'fox'], + }, } hash = @obj.symbolize_keys in_hash expect(hash).to eq({ @@ -57,8 +57,8 @@ horse: { duck: :duckle, fish: 'fishle', - eagle: ['the', 'quick', 'brown', 'fox'] - } + eagle: ['the', 'quick', 'brown', 'fox'], + }, }) end end diff --git a/spec/lib/utils_spec.rb b/spec/lib/utils_spec.rb index 367861a..2b7e8dd 100644 --- a/spec/lib/utils_spec.rb +++ b/spec/lib/utils_spec.rb @@ -18,7 +18,7 @@ 'awards' => [ { type: 'Medal of Honour', 'reason' => 'Stupidity' }, { 'type' => 'George Cross', reason: 'Bravery' }, - ] + ], } expect(symbolize_keys(h)).to eq({ name: 'Fred', @@ -32,7 +32,7 @@ awards: [ { type: 'Medal of Honour', reason: 'Stupidity' }, { type: 'George Cross', reason: 'Bravery' }, - ] + ], }) end @@ -61,7 +61,7 @@ content_type: 'application/pdf', filename: 'foo.pdf', }, - } + }, } expect(symbolize_keys(h)).to eq h end