Skip to content

Commit

Permalink
Drop support for Ruby 2.2
Browse files Browse the repository at this point in the history
RuboCop has dropped support for Ruby 2.2 (rubocop/rubocop@bcbcfb8) and so should we.
  • Loading branch information
bquorning committed May 13, 2019
1 parent 109fc8c commit e7a99b9
Show file tree
Hide file tree
Showing 18 changed files with 43 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ require: rubocop-rspec

AllCops:
DisplayCopNames: true
TargetRubyVersion: 2.2
TargetRubyVersion: 2.3
Exclude:
- 'vendor/**/*'
- 'spec/fixtures/**/*'
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Fix `FactoryBot/AttributeDefinedStatically` not working with an explicit receiver. ([@composerinteralia][])
* Add `RSpec/Dialect` enforces custom RSpec dialects. ([@gsamokovarov][])
* Fix redundant blank lines in `RSpec/MultipleSubjects`'s autocorrect. ([@pirj][])
* Drop support for ruby `2.2`. ([@bquorning][])

## 1.32.0 (2019-01-27)

Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source 'https://rubygems.org'

gemspec
Expand Down
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'open3'

require 'bundler'
Expand Down
2 changes: 2 additions & 0 deletions lib/rubocop-rspec_rails.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'pathname'
require 'yaml'

Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cop/rspec_rails/http_status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def checker_class
# :nodoc:
class SymbolicStyleChecker
MSG = 'Prefer `%<prefer>s` over `%<current>s` ' \
'to describe HTTP status code.'.freeze
'to describe HTTP status code.'

attr_reader :node
def initialize(node)
Expand Down Expand Up @@ -105,7 +105,7 @@ def custom_http_status_code?
# :nodoc:
class NumericStyleChecker
MSG = 'Prefer `%<prefer>s` over `%<current>s` ' \
'to describe HTTP status code.'.freeze
'to describe HTTP status code.'

WHITELIST_STATUS = %i[error success missing redirect].freeze

Expand Down
2 changes: 2 additions & 0 deletions lib/rubocop/cop/rspec_rails_cops.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative 'rspec/capybara/current_path_expectation'
require_relative 'rspec/capybara/feature_methods'

Expand Down
4 changes: 3 additions & 1 deletion lib/rubocop/rspec_rails/config_formatter.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# frozen_string_literal: true

require 'yaml'

module RuboCop
module RSpec
# Builds a YAML config file from two config hashes
class ConfigFormatter
NAMESPACES = /^(RSpec|Capybara|FactoryBot|Rails)/.freeze
STYLE_GUIDE_BASE_URL = 'http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/'.freeze
STYLE_GUIDE_BASE_URL = 'http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/'

def initialize(config, descriptions)
@config = config
Expand Down
4 changes: 3 additions & 1 deletion lib/rubocop/rspec_rails/description_extractor.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RuboCop
module RSpec
# Extracts cop descriptions from YARD docstrings
Expand All @@ -20,7 +22,7 @@ def to_h
# Decorator of a YARD code object for working with documented rspec cops
class CodeObject
COP_CLASS_NAMES = %w[RuboCop::Cop RuboCop::Cop::RSpec::Cop].freeze
RSPEC_NAMESPACE = 'RuboCop::Cop::RSpec'.freeze
RSPEC_NAMESPACE = 'RuboCop::Cop::RSpec'

def initialize(yardoc)
@yardoc = yardoc
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/rspec_rails/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module RuboCop
module RSpec
# Version information for the RSpec RuboCop plugin.
module Version
STRING = '1.32.0'.freeze
STRING = '1.32.0'
end
end
end
4 changes: 3 additions & 1 deletion rubocop-rspec_rails.gemspec
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

$LOAD_PATH.unshift File.expand_path('lib', __dir__)
require 'rubocop/rspec/version'

Expand All @@ -19,7 +21,7 @@ Gem::Specification.new do |spec|

spec.version = RuboCop::RSpec::Version::STRING
spec.platform = Gem::Platform::RUBY
spec.required_ruby_version = '>= 2.2.0'
spec.required_ruby_version = '>= 2.3.0'

spec.require_paths = ['lib']
spec.files = Dir[
Expand Down
2 changes: 2 additions & 0 deletions spec/project/changelog_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec.describe 'CHANGELOG.md' do
subject(:changelog) { SpecHelper::ROOT.join('CHANGELOG.md').read }

Expand Down
2 changes: 2 additions & 0 deletions spec/project/default_config_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec.describe 'config/default.yml' do
subject(:default_config) do
RuboCop::ConfigLoader.load_file('config/default.yml')
Expand Down
2 changes: 2 additions & 0 deletions spec/shared/detects_style_behavior.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec.shared_examples 'detects style' do |source, style, filename: 'x_spec.rb'|
it 'generates a todo based on the detected style' do
inspect_source(source, filename)
Expand Down
2 changes: 2 additions & 0 deletions spec/shared/smoke_test_examples.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec.shared_examples 'smoke test', type: :cop_spec do
context 'with default configuration' do
# This is overridden to avoid a number of specs that define `cop_config`
Expand Down
2 changes: 2 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rubocop'

require 'rubocop/rspec/support'
Expand Down
4 changes: 3 additions & 1 deletion spec/support/expect_offense.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# frozen_string_literal: true

# rubocop-rspec gem extension of RuboCop's ExpectOffense module.
#
# This mixin is the same as rubocop's ExpectOffense except the default
# filename ends with `_spec.rb`
module ExpectOffense
include RuboCop::RSpec::ExpectOffense

DEFAULT_FILENAME = 'example_spec.rb'.freeze
DEFAULT_FILENAME = 'example_spec.rb'

def expect_offense(source, filename = DEFAULT_FILENAME)
super
Expand Down
16 changes: 8 additions & 8 deletions tasks/cops_documentation.rake
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ task generate_cops_documentation: :yard_for_generate_documentation do
content = h2(cop.cop_name)
content << properties(config, cop)
content << "#{description}\n"
content << examples(examples_objects) if examples_objects.count > 0
content << examples(examples_objects) if examples_objects.count.positive?
content << configurations(pars)
content << references(config, cop)
content
Expand All @@ -43,27 +43,27 @@ task generate_cops_documentation: :yard_for_generate_documentation do
end

def h2(title)
content = "\n".dup
content = +"\n"
content << "## #{title}\n"
content << "\n"
content
end

def h3(title)
content = "\n".dup
content = +"\n"
content << "### #{title}\n"
content << "\n"
content
end

def h4(title)
content = "#### #{title}\n".dup
content = +"#### #{title}\n"
content << "\n"
content
end

def code_example(ruby_code)
content = "```ruby\n".dup
content = +"```ruby\n"
content << ruby_code.text
.gsub('@good', '# good')
.gsub('@bad', '# bad').strip
Expand Down Expand Up @@ -157,7 +157,7 @@ task generate_cops_documentation: :yard_for_generate_documentation do
end
return if selected_cops.empty?

content = "# #{department}\n".dup
content = +"# #{department}\n"
selected_cops.each do |cop|
content << print_cop_with_doc(cop, config)
end
Expand Down Expand Up @@ -199,7 +199,7 @@ task generate_cops_documentation: :yard_for_generate_documentation do

type_title = department[0].upcase + department[1..-1]
filename = "cops_#{department.downcase}.md"
content = "#### Department [#{type_title}](#{filename})\n\n".dup
content = +"#### Department [#{type_title}](#{filename})\n\n"
selected_cops.each do |cop|
anchor = cop.cop_name.sub('/', '').downcase
content << "* [#{cop.cop_name}](#{filename}##{anchor})\n"
Expand All @@ -213,7 +213,7 @@ task generate_cops_documentation: :yard_for_generate_documentation do
def print_table_of_contents(cops)
path = "#{Dir.pwd}/manual/cops.md"
original = File.read(path)
content = "<!-- START_COP_LIST -->\n".dup
content = +"<!-- START_COP_LIST -->\n"

content << table_contents(cops)

Expand Down

0 comments on commit e7a99b9

Please sign in to comment.