From 0f38d64007d1b76d97d843ec43310c638cca06e2 Mon Sep 17 00:00:00 2001 From: apainintheneck Date: Sat, 22 Feb 2025 23:46:57 -0800 Subject: [PATCH] Use standard instead of rubocop It's more stable, less fiddly and requires fewer updates. --- .github/workflows/ci.yml | 2 +- .rubocop.yml | 78 ----------------------------- Gemfile | 4 +- Gemfile.lock | 31 +++++++----- README.md | 2 +- Rakefile | 9 +--- atlasq.gemspec | 2 +- lib/atlasq/format.rb | 12 ++--- lib/atlasq/util/string.rb | 2 +- script/generate_formatted_output.rb | 14 +++--- script/generate_readme.rb | 4 +- script/generate_search_index.rb | 12 ++--- script/generate_test_fixtures.rb | 2 +- script/shared/cache_generator.rb | 2 +- test/test_atlasq.rb | 28 +++++------ test/test_util.rb | 2 +- 16 files changed, 63 insertions(+), 143 deletions(-) delete mode 100644 .rubocop.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9cc80f8..e8c99a6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,7 +39,7 @@ jobs: bundler-cache: true - name: Run linter - run: bundle exec rake lint + run: bundle exec rake standard - name: Run tests run: bundle exec rake test diff --git a/.rubocop.yml b/.rubocop.yml deleted file mode 100644 index cd388bb..0000000 --- a/.rubocop.yml +++ /dev/null @@ -1,78 +0,0 @@ -require: - - rubocop-minitest - - rubocop-rake - -AllCops: - NewCops: enable - TargetRubyVersion: 3.0 - -Layout/FirstArrayElementIndentation: - Enabled: true - EnforcedStyle: consistent - -Layout/FirstArrayElementLineBreak: - Enabled: true - -Layout/FirstHashElementIndentation: - Enabled: true - EnforcedStyle: consistent - -Layout/FirstHashElementLineBreak: - Enabled: true - -Layout/LineLength: - Enabled: true - Max: 120 - -Layout/MultilineMethodCallIndentation: - Enabled: true - EnforcedStyle: indented - -Metrics/AbcSize: - Enabled: false - -Metrics/BlockLength: - Enabled: true - CountAsOne: ['array', 'heredoc', 'method_call'] - -Metrics/ClassLength: - Enabled: true - CountAsOne: ['array', 'heredoc', 'method_call'] - Exclude: ['test/**/*'] - -Metrics/CyclomaticComplexity: - Enabled: false - -Metrics/MethodLength: - Enabled: true - CountAsOne: ['array', 'heredoc', 'method_call'] - Max: 20 - -Metrics/ModuleLength: - Enabled: true - CountAsOne: ['array', 'heredoc', 'method_call'] - -Minitest/MultipleAssertions: - Enabled: false - -Style/Documentation: - Enabled: false - -Style/SingleArgumentDig: - Enabled: false - -Style/StringLiterals: - Enabled: true - EnforcedStyle: double_quotes - -Style/StringLiteralsInInterpolation: - Enabled: true - EnforcedStyle: double_quotes - -Style/TrailingCommaInArrayLiteral: - Enabled: true - EnforcedStyleForMultiline: comma - -Style/TrailingCommaInHashLiteral: - Enabled: true - EnforcedStyleForMultiline: comma diff --git a/Gemfile b/Gemfile index 96cab3a..cb3c00f 100644 --- a/Gemfile +++ b/Gemfile @@ -9,9 +9,7 @@ gem "rake" gem "minitest" -gem "rubocop" -gem "rubocop-minitest" -gem "rubocop-rake" +gem "standard" gem "countries" gem "iso-639" diff --git a/Gemfile.lock b/Gemfile.lock index d4188f0..2b37b4d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -31,10 +31,9 @@ GEM rainbow (3.1.1) rake (13.2.1) regexp_parser (2.10.0) - rubocop (1.72.1) + rubocop (1.71.2) json (~> 2.3) - language_server-protocol (~> 3.17.0.2) - lint_roller (~> 1.1.0) + language_server-protocol (>= 3.17.0) parallel (~> 1.10) parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) @@ -44,14 +43,22 @@ GEM unicode-display_width (>= 2.4.0, < 4.0) rubocop-ast (1.38.0) parser (>= 3.3.1.0) - rubocop-minitest (0.37.1) - lint_roller (~> 1.1) - rubocop (>= 1.72.1, < 2.0) - rubocop-ast (>= 1.38.0, < 2.0) - rubocop-rake (0.7.0) - lint_roller (~> 1.1) - rubocop (>= 1.72.1) + rubocop-performance (1.23.1) + rubocop (>= 1.48.1, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) ruby-progressbar (1.13.0) + standard (1.45.0) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.0) + rubocop (~> 1.71.0) + standard-custom (~> 1.0.0) + standard-performance (~> 1.6) + standard-custom (1.0.2) + lint_roller (~> 1.0) + rubocop (~> 1.50) + standard-performance (1.6.0) + lint_roller (~> 1.1) + rubocop-performance (~> 1.23.0) strings (0.2.1) strings-ansi (~> 0.2) unicode-display_width (>= 1.5, < 3.0) @@ -75,9 +82,7 @@ DEPENDENCIES minitest money rake - rubocop - rubocop-minitest - rubocop-rake + standard BUNDLED WITH 2.4.10 diff --git a/README.md b/README.md index 314b895..f562f44 100644 --- a/README.md +++ b/README.md @@ -240,7 +240,7 @@ Language data is sourced from the [ISO-639](https://github.com/xwmx/iso-639) gem ## Development -After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. Use either `rake lint` to lint the code or `rake fix` to automatically fix simple linter errors. +After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. Use either `rake standard` to lint the code. You can also run `bin/console` for an interactive prompt that will allow you to experiment. diff --git a/Rakefile b/Rakefile index 85fe836..fe3bd80 100644 --- a/Rakefile +++ b/Rakefile @@ -2,6 +2,7 @@ require "bundler/gem_tasks" require "rake/testtask" +require "standard/rake" require "tempfile" Rake::TestTask.new(:test) do |t| @@ -14,13 +15,7 @@ require "rubocop/rake_task" RuboCop::RakeTask.new -task default: %i[lint test readme:outdated cache:outdated] - -desc "Shortcut for `rake rubocop`" -task lint: :rubocop - -desc "Shortcut for `rake rubocop:autocorrect`" -task fix: :"rubocop:autocorrect" +task default: %i[standard test readme:outdated cache:outdated] namespace "readme" do desc "Check if the readme needs to be regenerated" diff --git a/atlasq.gemspec b/atlasq.gemspec index 3f7665a..26456f6 100644 --- a/atlasq.gemspec +++ b/atlasq.gemspec @@ -19,7 +19,7 @@ Gem::Specification.new do |spec| spec.metadata = { "homepage_uri" => "https://github.com/apainintheneck/atlasq/", "changelog_uri" => "https://github.com/apainintheneck/atlasq/blob/main/CHANGELOG.md", - "rubygems_mfa_required" => "true", + "rubygems_mfa_required" => "true" } spec.files = Dir["{lib,exe}/**/*", "{cache}/**/*.json"] diff --git a/lib/atlasq/format.rb b/lib/atlasq/format.rb index 3c99840..3e3da7f 100644 --- a/lib/atlasq/format.rb +++ b/lib/atlasq/format.rb @@ -13,7 +13,7 @@ def self.title(title) [ "*", "* #{title}", - "*#{" *" * ((title.size / 2) + 2)}", + "*#{" *" * ((title.size / 2) + 2)}" ].join("\n") end @@ -56,7 +56,7 @@ def self.brief_template(title:, elements:) [ Format.title(title), - *elements, + *elements ].join("\n") end @@ -78,7 +78,7 @@ def self.country(country_code) [ Format.country_title(country_code), Format.one_line_country(country_code), - Format.multiline_country(country_code), + Format.multiline_country(country_code) ].join("\n") end @@ -113,7 +113,7 @@ def self.subregions(subregions) subregions = subregions.to_h do |region, countries| [ Util::String.titleize(region), - countries.map(&Format.method(:one_line_country)), + countries.map(&Format.method(:one_line_country)) ] end @@ -127,7 +127,7 @@ def self.currencies(currencies, partial_match: false) currencies = currencies.to_h do |currency, countries| [ Format.one_line_currency(currency), - countries.map(&Format.method(:one_line_country)), + countries.map(&Format.method(:one_line_country)) ] end @@ -156,7 +156,7 @@ def self.languages(languages, partial_match: false) languages = languages.to_h do |language, countries| [ Format.one_line_language(language), - countries.map(&Format.method(:one_line_country)), + countries.map(&Format.method(:one_line_country)) ] end diff --git a/lib/atlasq/util/string.rb b/lib/atlasq/util/string.rb index 960de11..3079148 100644 --- a/lib/atlasq/util/string.rb +++ b/lib/atlasq/util/string.rb @@ -8,7 +8,7 @@ module String ABBREVIATIONS = { "AMER" => "North, Central and South America", "APAC" => "Asia-Pacific", - "EMEA" => "Europe, Middle East, and Africa", + "EMEA" => "Europe, Middle East, and Africa" }.freeze # @param string [String] diff --git a/script/generate_formatted_output.rb b/script/generate_formatted_output.rb index a76e7f7..6c4b81e 100644 --- a/script/generate_formatted_output.rb +++ b/script/generate_formatted_output.rb @@ -15,7 +15,7 @@ def one_line_country(country) country.number, country.alpha2, country.alpha3, - country.iso_short_name, + country.iso_short_name ].compact .join(" | ") .then { |country_string| "(#{country_string})" } @@ -41,7 +41,7 @@ def languages(language_codes) ALL_COUNTRIES.to_h do |country| [ country.alpha2.downcase, - one_line_country(country), + one_line_country(country) ] end end @@ -50,7 +50,7 @@ def languages(language_codes) ALL_COUNTRIES.to_h do |country| [ country.alpha2.downcase, - "Country: #{country.iso_long_name}", + "Country: #{country.iso_long_name}" ] end end @@ -62,7 +62,7 @@ def languages(language_codes) "Nationality" => country.nationality, "Region" => country.subregion, "Continent" => country.continent, - "Currency" => "#{country.currency.symbol} #{country.currency.name}", + "Currency" => "#{country.currency.symbol} #{country.currency.name}" }.reject do |_, value| # "countries" like Antarctica can have missing language, nationality, # and region data so we remove that missing data beforehand. @@ -76,7 +76,7 @@ def languages(language_codes) [ country.alpha2.downcase, - info_ladder.join("\n"), + info_ladder.join("\n") ] end end @@ -85,7 +85,7 @@ def languages(language_codes) ALL_CURRENCIES.to_h do |currency| [ currency.iso_code.downcase, - "[#{currency.iso_code}] #{currency.symbol} #{currency.name}", + "[#{currency.iso_code}] #{currency.symbol} #{currency.name}" ] end end @@ -94,7 +94,7 @@ def languages(language_codes) ALL_LANGUAGES.to_h do |language| [ language.alpha2, - "(#{language.alpha2}/#{language.alpha3}) #{language.english_name}", + "(#{language.alpha2}/#{language.alpha3}) #{language.english_name}" ] end end diff --git a/script/generate_readme.rb b/script/generate_readme.rb index 893d85b..76fdd0d 100644 --- a/script/generate_readme.rb +++ b/script/generate_readme.rb @@ -11,7 +11,7 @@ def atlasq(*args) [ "$ atlasq #{escaped_args}", - `#{EXECUTABLE_PATH} #{escaped_args}`, + `#{EXECUTABLE_PATH} #{escaped_args}` ].join("\n") end @@ -95,7 +95,7 @@ def atlasq(*args) ## Development - After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. Use either `rake lint` to lint the code or `rake fix` to automatically fix simple linter errors. + After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. Use either `rake standard` to lint the code. You can also run `bin/console` for an interactive prompt that will allow you to experiment. diff --git a/script/generate_search_index.rb b/script/generate_search_index.rb index 50886b3..0e0a9ee 100644 --- a/script/generate_search_index.rb +++ b/script/generate_search_index.rb @@ -18,7 +18,7 @@ country.iso_short_name, country.iso_long_name, *country.unofficial_names, - *country.translated_names, + *country.translated_names ] names.map! { |name| Atlasq::Util::String.normalize(name) } names.uniq! @@ -37,7 +37,7 @@ country.iso_short_name, country.iso_long_name, *country.unofficial_names, - *country.translated_names, + *country.translated_names ] words = names.flat_map do |name| @@ -61,7 +61,7 @@ country.region, country.subregion, country.continent, - country.world_region, + country.world_region ] names.map! { |name| Atlasq::Util::String.normalize(name) } names.uniq! @@ -81,7 +81,7 @@ names = [ currency.iso_numeric, currency.iso_code, - currency.name, + currency.name ] names.map! { |name| Atlasq::Util::String.normalize(name) } names.uniq! @@ -99,7 +99,7 @@ currency.iso_numeric, currency.iso_code, currency.symbol, - *Atlasq::Util::String.word_split(currency.name), + *Atlasq::Util::String.word_split(currency.name) ] words.map! { |word| Atlasq::Util::String.normalize(word) } words.uniq! @@ -132,7 +132,7 @@ ALL_LANGUAGES.each_with_object({}) do |language, hash| names = [ language.english_name, - language.french_name, + language.french_name ] words = names.flat_map do |name| diff --git a/script/generate_test_fixtures.rb b/script/generate_test_fixtures.rb index 83a6c6c..cbdcb06 100644 --- a/script/generate_test_fixtures.rb +++ b/script/generate_test_fixtures.rb @@ -18,7 +18,7 @@ def atlasq(*args) ["all_countries_output.txt", %w[--countries]], ["all_currencies_output.txt", %w[--money]], ["all_languages_output.txt", %w[--languages]], - ["all_regions_output.txt", %w[--regions]], + ["all_regions_output.txt", %w[--regions]] ].each do |filename, args| path = File.join(FIXTURE_PATH, filename) content = atlasq(*args) diff --git a/script/shared/cache_generator.rb b/script/shared/cache_generator.rb index 139f953..553e934 100644 --- a/script/shared/cache_generator.rb +++ b/script/shared/cache_generator.rb @@ -55,7 +55,7 @@ def outdated "--brief", "--new-file", tmp_dir.to_s, - namespaced_cache_dir.to_s, + namespaced_cache_dir.to_s ] exit 1 unless system(*diff_command) diff --git a/test/test_atlasq.rb b/test/test_atlasq.rb index 86dd17c..99b9b54 100644 --- a/test/test_atlasq.rb +++ b/test/test_atlasq.rb @@ -76,7 +76,7 @@ def test_country_success [ %w[chile], - %w[-c chile], + %w[-c chile] ].each do |args| assert_command args: args, expected_stdout: expected_output end @@ -84,8 +84,8 @@ def test_country_success def test_country_failure assert_command args: %w[-c atlantis], - expected_stdout: "Unknown country: atlantis\n", - expected_status: 1 + expected_stdout: "Unknown country: atlantis\n", + expected_status: 1 end def test_region_success @@ -102,7 +102,7 @@ def test_region_success [ ["australia and new zealand"], - ["-r", "australia and new zealand"], + ["-r", "australia and new zealand"] ].each do |args| assert_command args: args, expected_stdout: expected_output end @@ -110,8 +110,8 @@ def test_region_success def test_region_failure assert_command args: %w[-r Pyrrus], - expected_stdout: "Unknown region: pyrrus\n", - expected_status: 1 + expected_stdout: "Unknown region: pyrrus\n", + expected_status: 1 end def test_currency_success @@ -124,7 +124,7 @@ def test_currency_success [ ["canadian dollar"], - ["-m", "canadian dollar"], + ["-m", "canadian dollar"] ].each do |args| assert_command args: args, expected_stdout: expected_output end @@ -132,8 +132,8 @@ def test_currency_success def test_currency_failure assert_command args: ["-m", "Double Dollars"], - expected_stdout: "Unknown currency: double dollars\n", - expected_status: 1 + expected_stdout: "Unknown currency: double dollars\n", + expected_status: 1 end def test_language_success @@ -147,7 +147,7 @@ def test_language_success [ ["grn"], - ["-l", "grn"], + ["-l", "grn"] ].each do |args| assert_command args: args, expected_stdout: expected_output end @@ -155,13 +155,13 @@ def test_language_success def test_language_failure assert_command args: ["-l", "Vulcan"], - expected_stdout: "Unknown language: vulcan\n", - expected_status: 1 + expected_stdout: "Unknown language: vulcan\n", + expected_status: 1 end def test_any_failure assert_command args: ["Grand Line"], - expected_stdout: "Unknown search term: grand line\n", - expected_status: 1 + expected_stdout: "Unknown search term: grand line\n", + expected_status: 1 end end diff --git a/test/test_util.rb b/test/test_util.rb index 9c1d43d..a72021a 100644 --- a/test/test_util.rb +++ b/test/test_util.rb @@ -6,7 +6,7 @@ def test_string_titleize "One Two Three", "one two three", "OnE tWo ThReE", - "one_two_three", + "one_two_three" ].each do |string| assert_equal "One Two Three", Atlasq::Util::String.titleize(string) end