Skip to content

Commit

Permalink
Merge pull request ryz310#615 from ryz310/the-end-of-ruby-2.6-support
Browse files Browse the repository at this point in the history
The end of ruby 2.6 support
  • Loading branch information
ryz310 committed May 13, 2022
2 parents 8941886 + 43e84e6 commit 3390c0a
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 34 deletions.
9 changes: 2 additions & 7 deletions .circleci/config.yml
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions .rubocop.yml
Expand Up @@ -7,21 +7,21 @@ 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

# For integration testing
RSpec/MultipleExpectations:
Exclude:
- 'spec/lib/rubocop_challenger/cli_spec.rb'
- "spec/lib/rubocop_challenger/cli_spec.rb"

RSpec/MultipleMemoizedHelpers:
Max: 10
Expand Down
2 changes: 0 additions & 2 deletions Gemfile
Expand Up @@ -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
5 changes: 1 addition & 4 deletions Gemfile.lock
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
14 changes: 7 additions & 7 deletions README.md
Expand Up @@ -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

Expand All @@ -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)
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion challenger.gemspec
Expand Up @@ -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'
Expand Down
10 changes: 1 addition & 9 deletions lib/rubocop_challenger/rubocop/yardoc.rb
Expand Up @@ -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
Expand Down

0 comments on commit 3390c0a

Please sign in to comment.