From 1b33f37631d97f2d4377c646f460164a072dc01d Mon Sep 17 00:00:00 2001 From: Michael Grosser Date: Mon, 2 Sep 2024 14:49:39 -0700 Subject: [PATCH] rubocop --- .github/workflows/actions.yml | 6 ++- .rubocop.yml | 90 +++++++++++++++++++++++++++++++++++ Gemfile | 3 ++ Gemfile.lock | 35 ++++++++++++++ Rakefile | 7 ++- i18n_data.gemspec | 4 +- 6 files changed, 141 insertions(+), 4 deletions(-) create mode 100644 .rubocop.yml diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 54e3ff1..454f9d2 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -9,7 +9,11 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby: [ '2.5', '2.6', '2.7', '3.0', '3.1' ] + ruby: [ '3.0', '3.1', '3.2', '3.3' ] + task: [ 'spec' ] + include: + - ruby: '3.0' # keep in sync with rubocop.yml and gemspec + task: 'rubocop' name: ${{ matrix.ruby }} rake steps: - uses: actions/checkout@v2 diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..957f979 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,90 @@ +require: +- rubocop-rake +- rubocop-rspec + +AllCops: + NewCops: enable + TargetRubyVersion: 3.0 # keep in sync with gemspec and actions.yml + +Style/StringLiterals: + Enabled: false + +Bundler/OrderedGems: + Enabled: false + +Metrics: + Enabled: false + +Style/Documentation: + Enabled: false + +Layout/EmptyLineAfterMagicComment: + Enabled: false + +Layout/EndAlignment: + EnforcedStyleAlignWith: variable + +Layout/MultilineOperationIndentation: + Enabled: false + +Layout/MultilineMethodCallIndentation: + EnforcedStyle: indented + +Style/NumericPredicate: + EnforcedStyle: comparison + +Layout/EmptyLineAfterGuardClause: + Enabled: false + +Layout/FirstHashElementLineBreak: + Enabled: true # Opt-in + +# Opt-in +Layout/FirstMethodArgumentLineBreak: + Enabled: true # Opt-in + +Layout/FirstMethodParameterLineBreak: + Enabled: true # Opt-in + +# https://github.com/rubocop-hq/rubocop/issues/5891 +Style/SpecialGlobalVars: + Enabled: false + +Style/WordArray: + EnforcedStyle: brackets + +Style/SymbolArray: + EnforcedStyle: brackets + +Style/GuardClause: + Enabled: false + +Style/EmptyElse: + Enabled: false + +RSpec/DescribedClass: + EnforcedStyle: explicit + +Style/DoubleNegation: + Enabled: false + +RSpec/VerifiedDoubles: + Enabled: false + +RSpec/ExampleLength: + Enabled: false + +Style/CombinableLoops: + Enabled: false + +Lint/Void: + Enabled: false + +Security/MarshalLoad: + Enabled: false + +Lint/EmptyBlock: + Exclude: [spec/**/*.rb] + +Naming/MethodParameterName: + Exclude: [spec/**/*.rb] diff --git a/Gemfile b/Gemfile index edc4b02..b44ba30 100644 --- a/Gemfile +++ b/Gemfile @@ -4,3 +4,6 @@ gemspec gem 'bump' gem 'rake' gem 'rspec', '~>3.0' +gem 'rubocop' +gem 'rubocop-rake' +gem 'rubocop-rspec' diff --git a/Gemfile.lock b/Gemfile.lock index 519e5b7..b0ba889 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,9 +7,21 @@ PATH GEM remote: https://rubygems.org/ specs: + ast (2.4.2) bump (0.10.0) diff-lcs (1.4.4) + json (2.7.2) + language_server-protocol (3.17.0.3) + parallel (1.26.3) + parser (3.3.4.2) + ast (~> 2.4.1) + racc + racc (1.8.1) + rainbow (3.1.1) rake (13.0.6) + regexp_parser (2.9.2) + rexml (3.3.6) + strscan rspec (3.10.0) rspec-core (~> 3.10.0) rspec-expectations (~> 3.10.0) @@ -23,7 +35,27 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.10.0) rspec-support (3.10.3) + rubocop (1.65.1) + json (~> 2.3) + language_server-protocol (>= 3.17.0) + parallel (~> 1.10) + parser (>= 3.3.0.2) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 2.4, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.31.1, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.32.1) + parser (>= 3.3.1.0) + rubocop-rake (0.6.0) + rubocop (~> 1.0) + rubocop-rspec (2.9.0) + rubocop (~> 1.19) + ruby-progressbar (1.13.0) simple_po_parser (1.1.6) + strscan (3.1.0) + unicode-display_width (2.5.0) PLATFORMS ruby @@ -36,6 +68,9 @@ DEPENDENCIES i18n_data! rake rspec (~> 3.0) + rubocop + rubocop-rake + rubocop-rspec BUNDLED WITH 2.3.12 diff --git a/Rakefile b/Rakefile index 7bc8692..da57880 100644 --- a/Rakefile +++ b/Rakefile @@ -6,12 +6,17 @@ require 'yaml' $LOAD_PATH << "lib" require 'i18n_data' -task default: [:spec] +task default: [:spec, :rubocop] task :spec do sh "rspec --warnings spec/" end +desc "Rubocop" +task :rubocop do + sh "rubocop --parallel" +end + desc "write all languages to output" task :all_languages do I18nData.languages.keys.each do |lc| diff --git a/i18n_data.gemspec b/i18n_data.gemspec index 8560493..07ef70c 100644 --- a/i18n_data.gemspec +++ b/i18n_data.gemspec @@ -8,6 +8,6 @@ Gem::Specification.new name, I18nData::VERSION do |s| s.homepage = "https://github.com/grosser/#{name}" s.files = `git ls-files lib cache `.split("\n") s.license = "MIT" - s.required_ruby_version = '>= 2.5.0' - s.add_runtime_dependency 'simple_po_parser', '~> 1.1' + s.required_ruby_version = '>= 3.0.0' # keep in sync with rubocop.yml and actions.yml + s.add_dependency 'simple_po_parser', '~> 1.1' end