From d83959db063ac7f878b5f51cb26c568c1c1d675a Mon Sep 17 00:00:00 2001 From: Ronald Tse Date: Sat, 11 Jan 2025 17:55:37 +0800 Subject: [PATCH] chore: rubocop --- .rubocop_todo.yml | 30 ++++++++++++++++++++++++------ Gemfile | 10 ++++++---- lib/rfcxml/v3/blockquote.rb | 26 +++++--------------------- lib/rfcxml/v3/dd.rb | 28 +++++----------------------- lib/rfcxml/v3/dt.rb | 17 +++++------------ lib/rfcxml/v3/figure.rb | 12 +++++------- lib/rfcxml/v3/li.rb | 28 +++++----------------------- lib/rfcxml/v3/rfc.rb | 8 ++++---- lib/rfcxml/v3/td.rb | 26 +++++--------------------- rfcxml.gemspec | 18 ++---------------- 10 files changed, 66 insertions(+), 137 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 5439326..0830927 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2025-01-07 10:02:25 UTC using RuboCop version 1.69.2. +# on 2025-01-11 09:55:13 UTC using RuboCop version 1.70.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 @@ -13,8 +13,26 @@ Gemspec/RequiredRubyVersion: Exclude: - 'rfcxml.gemspec' -# Offense count: 6 -# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. -# AllowedMethods: refine -Metrics/BlockLength: - Max: 34 +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: with_first_element, with_fixed_indentation +Layout/ArrayAlignment: + Exclude: + - 'lib/rfcxml/v3/dt.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings. +# URISchemes: http, https +Layout/LineLength: + Exclude: + - 'lib/rfcxml/v3/dt.rb' + - 'lib/rfcxml/v3/li.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowInHeredoc. +Layout/TrailingWhitespace: + Exclude: + - 'lib/rfcxml/v3/dt.rb' diff --git a/Gemfile b/Gemfile index e880bfe..1435873 100644 --- a/Gemfile +++ b/Gemfile @@ -2,11 +2,13 @@ source "https://rubygems.org" -# Specify your gem's dependencies in rfcxml.gemspec +# Specify your gem's dependencies in genericode.gemspec gemspec +gem "equivalent-xml" +gem "nokogiri" gem "rake", "~> 13.0" - gem "rspec", "~> 3.0" - -gem "rubocop", "~> 1.21" +gem "rubocop" +gem "rubocop-performance" +gem "xml-c14n" diff --git a/lib/rfcxml/v3/blockquote.rb b/lib/rfcxml/v3/blockquote.rb index 533d8a3..7f86ddb 100644 --- a/lib/rfcxml/v3/blockquote.rb +++ b/lib/rfcxml/v3/blockquote.rb @@ -65,27 +65,11 @@ class Blockquote < Lutaml::Model::Serializable map_attribute "pn", to: :pn map_attribute "cite", to: :cite map_attribute "quotedFrom", to: :quoted_from - map_element "artset", to: :artset - map_element "artwork", to: :artwork - map_element "dl", to: :dl - map_element "figure", to: :figure - map_element "ol", to: :ol - map_element "sourcecode", to: :sourcecode - map_element "t", to: :t - map_element "ul", to: :ul - map_element "bcp14", to: :bcp14 - map_element "br", to: :br - map_element "cref", to: :cref - map_element "em", to: :em - map_element "eref", to: :eref - map_element "iref", to: :iref - map_element "relref", to: :relref - map_element "strong", to: :strong - map_element "sub", to: :sub - map_element "sup", to: :sup - map_element "tt", to: :tt - map_element "u", to: :u - map_element "xref", to: :xref + + %w[artset artwork dl figure ol sourcecode t ul bcp14 br cref em eref + iref relref strong sub sup tt u xref].each do |element| + map_element element, to: element.to_sym + end end end end diff --git a/lib/rfcxml/v3/dd.rb b/lib/rfcxml/v3/dd.rb index fc3fd30..6961b6f 100644 --- a/lib/rfcxml/v3/dd.rb +++ b/lib/rfcxml/v3/dd.rb @@ -63,29 +63,11 @@ class Dd < Lutaml::Model::Serializable map_content to: :content map_attribute "anchor", to: :anchor map_attribute "pn", to: :pn - map_element "artset", to: :artset - map_element "artwork", to: :artwork - map_element "aside", to: :aside - map_element "dl", to: :dl - map_element "figure", to: :figure - map_element "ol", to: :ol - map_element "sourcecode", to: :sourcecode - map_element "t", to: :t - map_element "table", to: :table - map_element "ul", to: :ul - map_element "bcp14", to: :bcp14 - map_element "br", to: :br - map_element "cref", to: :cref - map_element "em", to: :em - map_element "eref", to: :eref - map_element "iref", to: :iref - map_element "relref", to: :relref - map_element "strong", to: :strong - map_element "sub", to: :sub - map_element "sup", to: :sup - map_element "tt", to: :tt - map_element "u", to: :u - map_element "xref", to: :xref + + %w[artset artwork aside dl figure ol sourcecode t table ul bcp14 br + cref em eref iref relref strong sub sup tt u xref].each do |element| + map_element element, to: element.to_sym + end end end end diff --git a/lib/rfcxml/v3/dt.rb b/lib/rfcxml/v3/dt.rb index 2c7879f..40b05bd 100644 --- a/lib/rfcxml/v3/dt.rb +++ b/lib/rfcxml/v3/dt.rb @@ -40,18 +40,11 @@ class Dt < Lutaml::Model::Serializable map_content to: :content map_attribute "anchor", to: :anchor map_attribute "pn", to: :pn - map_element "bcp14", to: :bcp14 - map_element "br", to: :br - map_element "cref", to: :cref - map_element "em", to: :em - map_element "eref", to: :eref - map_element "iref", to: :iref - map_element "relref", to: :relref - map_element "strong", to: :strong - map_element "sub", to: :sub - map_element "sup", to: :sup - map_element "tt", to: :tt - map_element "xref", to: :xref + + %w[bcp14 br cref em eref iref relref strong sub sup tt + xref].each do |element| + map_element element, to: element.to_sym + end end end end diff --git a/lib/rfcxml/v3/figure.rb b/lib/rfcxml/v3/figure.rb index ea5c4ae..18f9442 100644 --- a/lib/rfcxml/v3/figure.rb +++ b/lib/rfcxml/v3/figure.rb @@ -44,13 +44,11 @@ class Figure < Lutaml::Model::Serializable map_attribute "alt", to: :alt map_attribute "width", to: :width map_attribute "height", to: :height - map_element "name", to: :name - map_element "iref", to: :iref - map_element "preamble", to: :preamble - map_element "artset", to: :artset - map_element "artwork", to: :artwork - map_element "sourcecode", to: :sourcecode - map_element "postamble", to: :postamble + + %w[name iref preamble artset artwork sourcecode + postamble].each do |element| + map_element element, to: element.to_sym + end end end end diff --git a/lib/rfcxml/v3/li.rb b/lib/rfcxml/v3/li.rb index bb8ad15..5ef55e9 100644 --- a/lib/rfcxml/v3/li.rb +++ b/lib/rfcxml/v3/li.rb @@ -68,29 +68,11 @@ class Li < Lutaml::Model::Serializable map_attribute "anchor", to: :anchor map_attribute "derivedCounter", to: :derived_counter map_attribute "pn", to: :pn - map_element "artset", to: :artset - map_element "artwork", to: :artwork - map_element "blockquote", to: :blockquote - map_element "dl", to: :dl - map_element "figure", to: :figure - map_element "ol", to: :ol - map_element "sourcecode", to: :sourcecode - map_element "t", to: :t - map_element "table", to: :table - map_element "ul", to: :ul - map_element "bcp14", to: :bcp14 - map_element "br", to: :br - map_element "cref", to: :cref - map_element "em", to: :em - map_element "eref", to: :eref - map_element "iref", to: :iref - map_element "relref", to: :relref - map_element "strong", to: :strong - map_element "sub", to: :sub - map_element "sup", to: :sup - map_element "tt", to: :tt - map_element "u", to: :u - map_element "xref", to: :xref + + %w[artset artwork blockquote dl figure ol sourcecode t table ul bcp14 + br cref em eref iref relref strong sub sup tt u xref].each do |element| + map_element element, to: element.to_sym + end end end end diff --git a/lib/rfcxml/v3/rfc.rb b/lib/rfcxml/v3/rfc.rb index 3311f92..e1ae9a7 100644 --- a/lib/rfcxml/v3/rfc.rb +++ b/lib/rfcxml/v3/rfc.rb @@ -60,10 +60,10 @@ class Rfc < Lutaml::Model::Serializable map_attribute "scripts", to: :scripts map_attribute "expiresDate", to: :expires_date map_attribute "lang", to: :lang, prefix: :xml - map_element "link", to: :link - map_element "front", to: :front - map_element "middle", to: :middle - map_element "back", to: :back + + %w[link front middle back].each do |element| + map_element element, to: element.to_sym + end end end end diff --git a/lib/rfcxml/v3/td.rb b/lib/rfcxml/v3/td.rb index 2eb64d4..b6971e2 100644 --- a/lib/rfcxml/v3/td.rb +++ b/lib/rfcxml/v3/td.rb @@ -62,27 +62,11 @@ class Td < Lutaml::Model::Serializable map_attribute "colspan", to: :colspan map_attribute "rowspan", to: :rowspan map_attribute "align", to: :align - map_element "artset", to: :artset - map_element "artwork", to: :artwork - map_element "dl", to: :dl - map_element "figure", to: :figure - map_element "ol", to: :ol - map_element "sourcecode", to: :sourcecode - map_element "t", to: :t - map_element "ul", to: :ul - map_element "bcp14", to: :bcp14 - map_element "br", to: :br - map_element "cref", to: :cref - map_element "em", to: :em - map_element "eref", to: :eref - map_element "iref", to: :iref - map_element "relref", to: :relref - map_element "strong", to: :strong - map_element "sub", to: :sub - map_element "sup", to: :sup - map_element "tt", to: :tt - map_element "u", to: :u - map_element "xref", to: :xref + + %w[artset artwork dl figure ol sourcecode t ul bcp14 br cref em eref + iref relref strong sub sup tt u xref].each do |element| + map_element element, to: element.to_sym + end end end end diff --git a/rfcxml.gemspec b/rfcxml.gemspec index ff8d872..f578ff7 100644 --- a/rfcxml.gemspec +++ b/rfcxml.gemspec @@ -17,9 +17,6 @@ Gem::Specification.new do |spec| spec.metadata["source_code_uri"] = spec.homepage spec.metadata["changelog_uri"] = "https://github.com/metanorma/rfcxml/releases" - # Specify which files should be added to the gem when it is released. - # The `git ls-files -z` loads the files in the RubyGem - # that have been added into git. spec.files = Dir.chdir(File.expand_path(__dir__)) do `git ls-files -z` .split("\x0") @@ -31,17 +28,6 @@ Gem::Specification.new do |spec| spec.required_ruby_version = ">= 2.7.0" - spec.add_runtime_dependency "lutaml-model" - spec.add_runtime_dependency "nokogiri" - - spec.add_development_dependency "equivalent-xml" - spec.add_development_dependency "rake" - spec.add_development_dependency "rspec" - spec.add_development_dependency "rubocop" - spec.add_development_dependency "rubocop-performance" - spec.add_development_dependency "xml-c14n" - - spec.metadata["homepage_uri"] = spec.homepage - spec.metadata["source_code_uri"] = spec.homepage - spec.metadata["changelog_uri"] = spec.homepage + spec.add_dependency "lutaml-model" + spec.add_dependency "nokogiri" end