From 98f52bd2fd68394ae56cbd15842b8b084ab6d683 Mon Sep 17 00:00:00 2001 From: Dan Allen Date: Fri, 28 Oct 2022 20:26:37 -0600 Subject: upgrade RuboCop and RSpec; configure new rules and update code to conform --- .rubocop.yml | 28 ++++++++++++++++++++++++++-- Gemfile | 4 ++-- asciidoctor-pdf.gemspec | 2 +- spec/admonition_spec.rb | 4 ++-- spec/arrange_block_spec.rb | 2 +- spec/image_spec.rb | 4 ++-- spec/page_spec.rb | 2 +- spec/video_spec.rb | 4 ++-- 8 files changed, 37 insertions(+), 13 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 3e19ac42..ff9b5d4d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -80,6 +80,8 @@ Lint/DuplicateBranch: Enabled: true Lint/DuplicateElsifCondition: Enabled: true +Lint/DuplicateMagicComment: + Enabled: true Lint/DuplicateRegexpCharacterClassElement: Enabled: true Lint/DuplicateRequire: @@ -208,10 +210,18 @@ RSpec/BeNil: Enabled: true RSpec/BeforeAfterAll: Enabled: true +RSpec/Capybara/NegationMatcher: + Enabled: false +RSpec/Capybara/SpecificActions: + Enabled: false +RSpec/Capybara/SpecificFinders: + Enabled: false RSpec/Capybara/SpecificMatcher: Enabled: false RSpec/ChangeByZero: Enabled: true +RSpec/ClassCheck: + Enabled: true RSpec/ContextWording: Enabled: false RSpec/DescribeClass: @@ -226,8 +236,10 @@ RSpec/ExcessiveDocstringSpacing: Enabled: true RSpec/ExpectInHook: Enabled: true +RSpec/FactoryBot/ConsistentParenthesesStyle: + Enabled: false RSpec/FactoryBot/SyntaxMethods: - Enabled: true + Enabled: false RSpec/FilePath: Enabled: false RSpec/IdenticalEqualityAssertion: @@ -237,12 +249,18 @@ RSpec/MultipleExpectations: Max: 25 # FIXME get this down to 15 RSpec/NamedSubject: Enabled: false +RSpec/NoExpectationExample: + Enabled: false RSpec/Pending: Enabled: true RSpec/Rails/AvoidSetupHook: Enabled: false RSpec/Rails/HaveHttpStatus: Enabled: false +RSpec/Rails/InferredSpecType: + Enabled: false +RSpec/SortMetadata: + Enabled: true RSpec/SubjectDeclaration: Enabled: true RSpec/VerifiedDoubleReference: @@ -368,6 +386,8 @@ Style/InfiniteLoop: Enabled: false # reason: loop is measurably slower than while true Style/KeywordParametersOrder: Enabled: true +Style/MagicCommentFormat: + Enabled: true Style/MapCompactWithConditionalBlock: Enabled: true Style/MapToHash: @@ -411,6 +431,8 @@ Style/ObjectThen: Enabled: false # reason: not yet available in minimum JRuby version Style/OpenStructUse: Enabled: false # reason: the theming system relies on OpenStruct +Style/OperatorMethodCall: + Enabled: true Style/OptionalBooleanParameter: Enabled: false # reason: invasive Style/ParallelAssignment: @@ -448,6 +470,8 @@ Style/RedundantSelfAssignment: Enabled: true Style/RedundantSelfAssignmentBranch: Enabled: false +Style/RedundantStringEscape: + Enabled: false # reason: this rule crashes RuboCop Style/RegexpLiteral: Enabled: true Style/RescueModifier: @@ -481,7 +505,7 @@ Style/SymbolArray: Style/SymbolProc: Enabled: true Style/TernaryParentheses: - Enabled: true + Enabled: false # reason: this rule has become too buggy and gets it wrong most of the time EnforcedStyle: require_parentheses_when_complex Style/TrailingCommaInArrayLiteral: EnforcedStyleForMultiline: consistent_comma diff --git a/Gemfile b/Gemfile index b7b83e82..43e5c8df 100644 --- a/Gemfile +++ b/Gemfile @@ -27,9 +27,9 @@ group :lint do gem 'rubocop-rake', '~> 0.6.0', require: false gem 'rubocop-rspec', '~> 2.10.0', require: false else - gem 'rubocop', '~> 1.32.0', require: false + gem 'rubocop', '~> 1.37.0', require: false gem 'rubocop-rake', '~> 0.6.0', require: false - gem 'rubocop-rspec', '~> 2.12.0', require: false + gem 'rubocop-rspec', '~> 2.14.0', require: false end end diff --git a/asciidoctor-pdf.gemspec b/asciidoctor-pdf.gemspec index e1a43160..ec356b9d 100644 --- a/asciidoctor-pdf.gemspec +++ b/asciidoctor-pdf.gemspec @@ -44,7 +44,7 @@ Gem::Specification.new do |s| s.add_runtime_dependency 'treetop', '~> 1.6.0' s.add_development_dependency 'rake', '~> 13.0.0' - s.add_development_dependency 'rspec', '~> 3.11.0' + s.add_development_dependency 'rspec', '~> 3.12.0' s.add_development_dependency 'pdf-inspector', '~> 1.3.0' s.add_development_dependency 'chunky_png', '~> 1.4.0' end diff --git a/spec/admonition_spec.rb b/spec/admonition_spec.rb index aafd5596..32bca85c 100644 --- a/spec/admonition_spec.rb +++ b/spec/admonition_spec.rb @@ -98,7 +98,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do (expect lines[1][:to][:y]).to be > 36.0 end - it 'should draw border and background on all pages if block is split across pages', visual: true, breakable: true do + it 'should draw border and background on all pages if block is split across pages', breakable: true, visual: true do pdf_theme = { admonition_background_color: 'F5A9A9', admonition_border_width: 0.5, @@ -763,7 +763,7 @@ describe 'Asciidoctor::PDF::Converter - Admonition' do end).to log_message severity: :WARN, message: %(~could not embed admonition icon image: #{fixture_file 'corrupt.png'}; image file is an unrecognised format) end - it 'should embed remote image in icon if allow-uri-read attribute is set', visual: true, network: true do + it 'should embed remote image in icon if allow-uri-read attribute is set', network: true, visual: true do to_file = to_pdf_file <<~'EOS', 'admonition-custom-svg-icon-with-remote-image.pdf', attribute_overrides: { 'docdir' => fixtures_dir, 'allow-uri-read' => '' } :icons: font :iconsdir: diff --git a/spec/arrange_block_spec.rb b/spec/arrange_block_spec.rb index 4167b5e9..97d57e05 100644 --- a/spec/arrange_block_spec.rb +++ b/spec/arrange_block_spec.rb @@ -2051,7 +2051,7 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do end # NOTE: generate reference files using ./scripts/generate-arrange-block-reference-files.sh - describe 'acceptance', visual: true, if: ENV['COVERAGE'] do + describe 'acceptance', if: ENV['COVERAGE'], visual: true do it 'at top, fits' do to_file = to_pdf_file (Pathname.new (fixture_file 'arrange-block-at-top-fits.adoc')), 'arrange-block-at-top-fits.pdf', attribute_overrides: { 'source-highlighter' => 'rouge' } diff --git a/spec/image_spec.rb b/spec/image_spec.rb index 880454cc..e67a4d31 100644 --- a/spec/image_spec.rb +++ b/spec/image_spec.rb @@ -1009,7 +1009,7 @@ describe 'Asciidoctor::PDF::Converter - Image' do end).to log_message severity: :WARN, message: %(~problem encountered in image: #{fixture_file 'svg-with-remote-image.svg'}; Error retrieving URL https://cdn.jsdelivr.net/gh/asciidoctor/asciidoctor-pdf@v1.6.2/spec/fixtures/logo.png) end - it 'should embed remote image if allow allow-uri-read attribute is set', visual: true, network: true do + it 'should embed remote image if allow allow-uri-read attribute is set', network: true, visual: true do to_file = to_pdf_file <<~'EOS', 'image-svg-with-remote-image.pdf', attribute_overrides: { 'allow-uri-read' => '' } A sign of a good writer: image:svg-with-remote-image.svg[pdfwidth=1.27cm] EOS @@ -1297,7 +1297,7 @@ describe 'Asciidoctor::PDF::Converter - Image' do end # NOTE: gmagick reads `Depth: 8/2-bit` as 2 instead of 8 - it 'should reread bit depth if gmagick fails to read bit depth correctly', visual: true, if: (defined? GMagick::Image) do + it 'should reread bit depth if gmagick fails to read bit depth correctly', if: (defined? GMagick::Image), visual: true do to_file = to_pdf_file <<~'EOS', 'image-png-depth.pdf' image::square.png[pdfwidth=25%] EOS diff --git a/spec/page_spec.rb b/spec/page_spec.rb index e9602c4c..52c3f377 100644 --- a/spec/page_spec.rb +++ b/spec/page_spec.rb @@ -1404,7 +1404,7 @@ describe 'Asciidoctor::PDF::Converter - Page' do (expect to_file).to visually_match 'page-background-image-fill.pdf' end - it 'should allow remote image in SVG to be read if allow-uri-read attribute is set', visual: true, network: true do + it 'should allow remote image in SVG to be read if allow-uri-read attribute is set', network: true, visual: true do to_file = to_pdf_file <<~'EOS', 'page-background-image-svg-with-remote-image.pdf', attribute_overrides: { 'allow-uri-read' => '' } :page-background-image: image:svg-with-remote-image.svg[fit=none,position=top] diff --git a/spec/video_spec.rb b/spec/video_spec.rb index 8450e52c..9daca159 100644 --- a/spec/video_spec.rb +++ b/spec/video_spec.rb @@ -45,7 +45,7 @@ describe 'Asciidoctor::PDF::Converter - Video' do end context 'YouTube' do - it 'should replace video with poster image if allow-uri-read attribute is set', visual: true, network: true do + it 'should replace video with poster image if allow-uri-read attribute is set', network: true, visual: true do video_id = 'EJ09pSuA9hw' to_file = to_pdf_file <<~EOS, 'video-youtube-poster.pdf', attribute_overrides: { 'allow-uri-read' => '' } video::#{video_id}[youtube,pdfwidth=100%] @@ -79,7 +79,7 @@ describe 'Asciidoctor::PDF::Converter - Video' do end context 'Vimeo' do - it 'should replace video with poster image if allow-uri-read attribute is set', visual: true, network: true do + it 'should replace video with poster image if allow-uri-read attribute is set', network: true, visual: true do video_id = '77477140' to_file = to_pdf_file <<~EOS, 'video-vimeo-poster.pdf', attribute_overrides: { 'allow-uri-read' => '' } video::#{video_id}[vimeo,pdfwidth=100%] -- cgit v1.2.3