diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml index 732cf2b..d442459 100644 --- a/.github/workflows/rubocop.yml +++ b/.github/workflows/rubocop.yml @@ -12,6 +12,8 @@ on: pull_request: # The branches below must be a subset of the branches above branches: [ main ] + schedule: + - cron: '20 4 * * 5' jobs: rubocop: diff --git a/.rubocop.yml b/.rubocop.yml index f3d5561..72f47ae 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,6 +1,3 @@ -require: - - rubocop-rake - AllCops: NewCops: enable TargetRubyVersion: 2.7 diff --git a/Gemfile b/Gemfile index c57d2a7..26ea26a 100644 --- a/Gemfile +++ b/Gemfile @@ -8,9 +8,3 @@ group :ci do gem 'code-scanning-rubocop' gem 'rspec_junit_formatter' end - - -gem 'rake', '~> 13.0' -gem 'rspec' -gem 'rubocop', '~> 1.29' -gem 'rubocop-rake', '~> 0.6' diff --git a/Gemfile.lock b/Gemfile.lock index 9344382..9bd2244 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -10,51 +10,47 @@ GEM ast (2.4.2) code-scanning-rubocop (0.6.1) rubocop (~> 1.0) - colorize (1.1.0) - diff-lcs (1.5.1) - json (2.7.2) - language_server-protocol (3.17.0.3) - parallel (1.25.1) - parser (3.3.4.0) + colorize (0.8.1) + diff-lcs (1.5.0) + parallel (1.22.1) + parser (3.1.2.0) ast (~> 2.4.1) - racc - racc (1.8.1) rainbow (3.1.1) - rake (13.2.1) - regexp_parser (2.9.2) - rexml (3.3.9) - rspec (3.13.0) - rspec-core (~> 3.13.0) - rspec-expectations (~> 3.13.0) - rspec-mocks (~> 3.13.0) - rspec-core (3.13.0) - rspec-support (~> 3.13.0) - rspec-expectations (3.13.1) + rake (13.0.6) + regexp_parser (2.4.0) + rexml (3.2.5) + rspec (3.11.0) + rspec-core (~> 3.11.0) + rspec-expectations (~> 3.11.0) + rspec-mocks (~> 3.11.0) + rspec-core (3.11.0) + rspec-support (~> 3.11.0) + rspec-expectations (3.11.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.13.0) - rspec-mocks (3.13.1) + rspec-support (~> 3.11.0) + rspec-mocks (3.11.1) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.13.0) - rspec-support (3.13.1) - rspec_junit_formatter (0.6.0) + rspec-support (~> 3.11.0) + rspec-support (3.11.0) + rspec_junit_formatter (0.5.1) rspec-core (>= 2, < 4, != 2.12.0) - rubocop (1.65.1) - json (~> 2.3) - language_server-protocol (>= 3.17.0) + rubocop (1.29.1) parallel (~> 1.10) - parser (>= 3.3.0.2) + parser (>= 3.1.0.0) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 2.4, < 3.0) + regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.31.1, < 2.0) + rubocop-ast (>= 1.17.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.31.3) - parser (>= 3.3.1.0) + unicode-display_width (>= 1.4.0, < 3.0) + rubocop-ast (1.18.0) + parser (>= 3.1.1.0) rubocop-rake (0.6.0) rubocop (~> 1.0) - ruby-progressbar (1.13.0) - unicode-display_width (2.5.0) + rubocop-rspec (2.11.1) + rubocop (~> 1.19) + ruby-progressbar (1.11.0) + unicode-display_width (2.1.0) PLATFORMS ruby @@ -67,6 +63,7 @@ DEPENDENCIES rspec_junit_formatter rubocop (~> 1.29) rubocop-rake (~> 0.6) + rubocop-rspec BUNDLED WITH 2.1.4 diff --git a/README.md b/README.md index bcf923c..c204339 100644 --- a/README.md +++ b/README.md @@ -94,16 +94,3 @@ must read file content via `stdin`. Anything that the lint command outputs to option to tell it to read content from `stdin` instead of reading files from disk, and messages from `eslint` are redirected to `stderr` (using the `>&2` notation) so that you can see them. - -### Why the Ruby port if there already is a fine Python implementation? - -I don’t like Python ;) - -But jokes aside, I am already setting up a Ruby environment (using [rbenv][]) for my -projects to run [cocoapods][] and [fastlane][] and our git hooks. By using this port -we don’t need to ensure to have python available as well. - - -[rbenv]: https://github.com/rbenv/rbenv/ -[cocoapods]: https://cocoapods.org/ -[fastlane]: https://fastlane.tools/ diff --git a/bin/git-format-staged b/bin/git-format-staged index 2111bcc..41d0829 100755 --- a/bin/git-format-staged +++ b/bin/git-format-staged @@ -17,7 +17,7 @@ parser = OptionParser.new do |opt| <<~DOC Shell command to format files, will run once per file. Occurrences of the placeholder `{}` will \ be replaced with a path to the file being formatted. \ - (Example: "prettier --stdin-filepath '{}'") + (Example: "prettier --stdin-filepath \'{}\'") DOC ) do |o| parameters[:formatter] = o diff --git a/format-staged.gemspec b/format-staged.gemspec index ddde6c8..d8fd383 100644 --- a/format-staged.gemspec +++ b/format-staged.gemspec @@ -19,6 +19,12 @@ Gem::Specification.new do |s| s.add_dependency 'colorize' + s.add_development_dependency 'rake', '~> 13.0' + s.add_development_dependency 'rspec' + s.add_development_dependency 'rubocop', '~> 1.29' + s.add_development_dependency 'rubocop-rake', '~> 0.6' + s.add_development_dependency 'rubocop-rspec' + s.metadata = { 'rubygems_mfa_required' => 'true' } diff --git a/lib/format-staged/job.rb b/lib/format-staged/job.rb index 176b099..18bacc8 100644 --- a/lib/format-staged/job.rb +++ b/lib/format-staged/job.rb @@ -39,7 +39,7 @@ module FormatStaged return false unless formatted.size == files.size quiet = @verbose ? [] : ['--quiet'] - !write || get_status('git', 'diff-index', '--cached', '--exit-code', *quiet, 'HEAD') != 0 + return !write || get_status('git', 'diff-index', '--cached', '--exit-code', *quiet, 'HEAD') != 0 end def repo_root diff --git a/spec/test_spec.rb b/spec/test_spec.rb index 26fc0ff..ce53719 100644 --- a/spec/test_spec.rb +++ b/spec/test_spec.rb @@ -132,7 +132,7 @@ describe FormatStaged do repo.set_content 'test.test', 'a=b' repo.stage 'test.test' - expect(repo.run_formatter(write: false)).to be_truthy + expect(repo.run_formatter write: false).to be_truthy expect(repo.get_content('test.test')).to eq 'a=b' expect(repo.get_staged('test.test')).to eq 'a=b' end