diff --git a/.rubocop.yml b/.rubocop.yml index c76d6ad7..10fbbd9b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -2,7 +2,7 @@ require: rubocop-rspec AllCops: DisplayCopNames: true - TargetRubyVersion: 2.2 + TargetRubyVersion: 2.3 Exclude: - 'vendor/**/*' - 'spec/fixtures/**/*' diff --git a/CHANGELOG.md b/CHANGELOG.md index a267225a..4ce567c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/Gemfile b/Gemfile index 7a1348f1..515dec7c 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + source 'https://rubygems.org' gemspec diff --git a/Rakefile b/Rakefile index 0ea57573..4bea106c 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'open3' require 'bundler' diff --git a/lib/rubocop-rspec_rails.rb b/lib/rubocop-rspec_rails.rb index 475619a0..b3a550fe 100644 --- a/lib/rubocop-rspec_rails.rb +++ b/lib/rubocop-rspec_rails.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'pathname' require 'yaml' diff --git a/lib/rubocop/cop/rspec_rails/http_status.rb b/lib/rubocop/cop/rspec_rails/http_status.rb index 897496a2..9941df49 100644 --- a/lib/rubocop/cop/rspec_rails/http_status.rb +++ b/lib/rubocop/cop/rspec_rails/http_status.rb @@ -67,7 +67,7 @@ def checker_class # :nodoc: class SymbolicStyleChecker MSG = 'Prefer `%s` over `%s` ' \ - 'to describe HTTP status code.'.freeze + 'to describe HTTP status code.' attr_reader :node def initialize(node) @@ -105,7 +105,7 @@ def custom_http_status_code? # :nodoc: class NumericStyleChecker MSG = 'Prefer `%s` over `%s` ' \ - 'to describe HTTP status code.'.freeze + 'to describe HTTP status code.' WHITELIST_STATUS = %i[error success missing redirect].freeze diff --git a/lib/rubocop/cop/rspec_rails_cops.rb b/lib/rubocop/cop/rspec_rails_cops.rb index af75f325..927d0465 100644 --- a/lib/rubocop/cop/rspec_rails_cops.rb +++ b/lib/rubocop/cop/rspec_rails_cops.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative 'rspec/capybara/current_path_expectation' require_relative 'rspec/capybara/feature_methods' diff --git a/lib/rubocop/rspec_rails/config_formatter.rb b/lib/rubocop/rspec_rails/config_formatter.rb index 8a7e767d..ae863059 100644 --- a/lib/rubocop/rspec_rails/config_formatter.rb +++ b/lib/rubocop/rspec_rails/config_formatter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'yaml' module RuboCop @@ -5,7 +7,7 @@ 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 diff --git a/lib/rubocop/rspec_rails/description_extractor.rb b/lib/rubocop/rspec_rails/description_extractor.rb index ed48ce20..ad1e0a79 100644 --- a/lib/rubocop/rspec_rails/description_extractor.rb +++ b/lib/rubocop/rspec_rails/description_extractor.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module RuboCop module RSpec # Extracts cop descriptions from YARD docstrings @@ -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 diff --git a/lib/rubocop/rspec_rails/version.rb b/lib/rubocop/rspec_rails/version.rb index 30412de4..27fd82b1 100644 --- a/lib/rubocop/rspec_rails/version.rb +++ b/lib/rubocop/rspec_rails/version.rb @@ -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 diff --git a/rubocop-rspec_rails.gemspec b/rubocop-rspec_rails.gemspec index 147b8b88..57f40cd0 100644 --- a/rubocop-rspec_rails.gemspec +++ b/rubocop-rspec_rails.gemspec @@ -1,3 +1,5 @@ +# frozen_string_literal: true + $LOAD_PATH.unshift File.expand_path('lib', __dir__) require 'rubocop/rspec/version' @@ -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[ diff --git a/spec/project/changelog_spec.rb b/spec/project/changelog_spec.rb index 628d1a04..32f4cfbe 100644 --- a/spec/project/changelog_spec.rb +++ b/spec/project/changelog_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe 'CHANGELOG.md' do subject(:changelog) { SpecHelper::ROOT.join('CHANGELOG.md').read } diff --git a/spec/project/default_config_spec.rb b/spec/project/default_config_spec.rb index 4e0f9c00..ea832569 100644 --- a/spec/project/default_config_spec.rb +++ b/spec/project/default_config_spec.rb @@ -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') diff --git a/spec/shared/detects_style_behavior.rb b/spec/shared/detects_style_behavior.rb index e9022b0c..90eb699a 100644 --- a/spec/shared/detects_style_behavior.rb +++ b/spec/shared/detects_style_behavior.rb @@ -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) diff --git a/spec/shared/smoke_test_examples.rb b/spec/shared/smoke_test_examples.rb index 61f30e76..85591467 100644 --- a/spec/shared/smoke_test_examples.rb +++ b/spec/shared/smoke_test_examples.rb @@ -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` diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 8bc1180a..c15f55c7 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rubocop' require 'rubocop/rspec/support' diff --git a/spec/support/expect_offense.rb b/spec/support/expect_offense.rb index 984ed1ee..a05f2b0d 100644 --- a/spec/support/expect_offense.rb +++ b/spec/support/expect_offense.rb @@ -1,3 +1,5 @@ +# 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 @@ -5,7 +7,7 @@ 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 diff --git a/tasks/cops_documentation.rake b/tasks/cops_documentation.rake index 8c50e6fc..b826d110 100644 --- a/tasks/cops_documentation.rake +++ b/tasks/cops_documentation.rake @@ -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 @@ -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 @@ -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 @@ -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" @@ -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 = "\n".dup + content = +"\n" content << table_contents(cops)