From cdf750d43002e09a84cd01fb351766a3288f6be3 Mon Sep 17 00:00:00 2001 From: Ryosuke Sato Date: Sat, 14 May 2022 00:02:54 +0900 Subject: [PATCH 1/3] The end of ruby 2.6 support --- .circleci/config.yml | 9 ++------- .rubocop.yml | 8 ++++---- Gemfile | 2 -- README.md | 14 +++++++------- challenger.gemspec | 2 +- 5 files changed, 14 insertions(+), 21 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4ff39dae..9f3aea4a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -12,7 +12,7 @@ references: - &ruby_version ruby_version: type: enum - enum: ["2.6", "2.7", "3.0", "3.1"] + enum: ["2.7", "3.0", "3.1"] default: "3.1" executors: @@ -159,7 +159,7 @@ jobs: - code-climate/install - code-climate/sum-coverage: input: codeclimate.*.json - parts: 4 + parts: 3 - code-climate/upload-coverage rubocop: executor: default @@ -192,9 +192,6 @@ workflows: commit: jobs: - - build: - name: build_on_ruby_2.6 - ruby_version: "2.6" - build: name: build_on_ruby_2.7 ruby_version: "2.7" @@ -209,14 +206,12 @@ workflows: - integration_testing - upload-coverage: requires: - - build_on_ruby_2.6 - build_on_ruby_2.7 - build_on_ruby_3.0 - build_on_ruby_3.1 - release: context: RubyGems API Key requires: - - build_on_ruby_2.6 - build_on_ruby_2.7 - build_on_ruby_3.0 - build_on_ruby_3.1 diff --git a/.rubocop.yml b/.rubocop.yml index 316d644c..e173939a 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -7,13 +7,13 @@ require: inherit_from: .rubocop_todo.yml AllCops: - TargetRubyVersion: 2.6 + TargetRubyVersion: 2.7 NewCops: enable Metrics/BlockLength: Exclude: - - 'challenger.gemspec' - - 'spec/**/*' + - "challenger.gemspec" + - "spec/**/*" Naming/VariableNumber: EnforcedStyle: snake_case @@ -21,7 +21,7 @@ Naming/VariableNumber: # For integration testing RSpec/MultipleExpectations: Exclude: - - 'spec/lib/rubocop_challenger/cli_spec.rb' + - "spec/lib/rubocop_challenger/cli_spec.rb" RSpec/MultipleMemoizedHelpers: Max: 10 diff --git a/Gemfile b/Gemfile index b78b23e2..e4284890 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,5 @@ source 'https://rubygems.org' git_source(:github) { |repo_name| "https://github.com/#{repo_name}" } -gem 'activesupport', '~> 6.1' # TODO: Remove this line at the end of Ruby 2.6 support - # Specify your gem's dependencies in rubocop_challenger.gemspec gemspec diff --git a/README.md b/README.md index 145ec53e..fc8a8d15 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ If you introduce [`rubocop`](https://github.com/rubocop-hq/rubocop) to an existing Rails project later, you will use [`$ rubocop --auto-gen-config`](https://github.com/rubocop-hq/rubocop/blob/master/manual/configuration.md#automatically-generated-configuration). But it will make a huge `.rubocop_todo.yml` and make you despair. On the other hand, `rubocop` has [`--auto-correct`](https://github.com/rubocop-hq/rubocop/blob/master/manual/basic_usage.md#other-useful-command-line-flags) option, it is possible to automatically repair the writing which does not conform to the rule. But since it occasionally destroys your code, it is quite dangerous to apply all at once. It is ideal that to remove a disabled rule from `.rubocop_todo.yml` every day, to check whether it passes test, and can be obtained consent from the team. But it requires strong persistence and time. -I call such work *Rubocop Challenge*. And the *RubocopChallenger* is a gem to support this challenge! +I call such work _Rubocop Challenge_. And the _RubocopChallenger_ is a gem to support this challenge! ## The history of RubocopChallenger with decrease of offense codes @@ -17,8 +17,8 @@ be continued to evolve. ## Rubocop Challenge Flow -1. Run *RubocopChallenger* periodically from CI tool etc. -1. When *RubocopChallenger* starts, delete a disabled rule from `.rubocop_todo.yml` existing in your project, execute `$ rubocop --auto-correct` and create a PR which include modified results +1. Run _RubocopChallenger_ periodically from CI tool etc. +1. When _RubocopChallenger_ starts, delete a disabled rule from `.rubocop_todo.yml` existing in your project, execute `$ rubocop --auto-correct` and create a PR which include modified results 1. You confirm the PR passes testing and then merge it if there is no problem [![Rubocop Challenge](images/rubocop_challenge.png)](https://github.com/ryz310/rubocop_challenger/pull/97) @@ -71,16 +71,16 @@ I have seen cases where errors occur due to compatibility issues with other gems GitHub personal access token is required for sending pull requests to your repository. 1. Go to [your account's settings page](https://github.com/settings/tokens) and [generate a new token](https://github.com/settings/tokens/new) with "repo" scope - ![generate token](images/generate_token.png) + ![generate token](images/generate_token.png) 1. On [CircleCI](https://circleci.com) dashboard, go to your application's "Project Settings" -> "Environment Variables" 1. Add an environment variable `GITHUB_ACCESS_TOKEN` with your GitHub personal access token - ![circleci environment variables](images/circleci_environment_variables.png) + ![circleci environment variables](images/circleci_environment_variables.png) ### Want to use on GitHub Actions? It's introduced in the following blog. Thank you Mr. Takuya Yamaguchi! -See: [RuboCop ChallengerをGitHub Actionsで動かす](https://zenn.dev/yamat47/articles/219e14ebcf31a1d13ff4) +See: [RuboCop Challenger を GitHub Actions で動かす](https://zenn.dev/yamat47/articles/219e14ebcf31a1d13ff4) ## CLI command references @@ -127,7 +127,7 @@ Run `$ rubocop --auto-correct` and create a PR to GitHub repo ## Requirement -* Ruby 2.6 or higher +- Ruby 2.7 or higher ## Development diff --git a/challenger.gemspec b/challenger.gemspec index 97728738..ad3cfe02 100644 --- a/challenger.gemspec +++ b/challenger.gemspec @@ -22,7 +22,7 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.6' + spec.required_ruby_version = '>= 2.7' spec.add_runtime_dependency 'pr_comet', '>= 0.5.1', '< 0.7.0' spec.add_runtime_dependency 'rainbow' From 093522b2877fc8d3049d69f7b3fe6b000643e568 Mon Sep 17 00:00:00 2001 From: Ryosuke Sato Date: Sat, 14 May 2022 00:12:05 +0900 Subject: [PATCH 2/3] Remove the code for backward compatibility with Ruby 2.6 --- lib/rubocop_challenger/rubocop/yardoc.rb | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/lib/rubocop_challenger/rubocop/yardoc.rb b/lib/rubocop_challenger/rubocop/yardoc.rb index 5ca32087..86d989cb 100644 --- a/lib/rubocop_challenger/rubocop/yardoc.rb +++ b/lib/rubocop_challenger/rubocop/yardoc.rb @@ -66,15 +66,7 @@ def instance_methods end def source_file_path - if Object.respond_to?(:const_source_location) - Object.const_source_location(cop_class.name).first - else - instance_methods - .map { |m| cop_class.instance_method(m).source_location } - .compact - .map(&:first) - .first - end + Object.const_source_location(cop_class.name).first end end end From 43e84e6c7af2f85859a7a8b52706f9db012b01b9 Mon Sep 17 00:00:00 2001 From: Ryosuke Sato Date: Sat, 14 May 2022 00:13:43 +0900 Subject: [PATCH 3/3] $ bundle update --- Gemfile.lock | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 7466f3aa..07179870 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -16,12 +16,11 @@ PATH GEM remote: https://rubygems.org/ specs: - activesupport (6.1.6) + activesupport (7.0.3) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) - zeitwerk (~> 2.3) addressable (2.8.0) public_suffix (>= 2.0.2, < 5.0) ast (2.4.2) @@ -136,13 +135,11 @@ GEM webrick (1.7.0) yard (0.9.27) webrick (~> 1.7.0) - zeitwerk (2.5.4) PLATFORMS ruby DEPENDENCIES - activesupport (~> 6.1) bundler (>= 2.0) pry-byebug rake (~> 13.0)