diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3ea0c6b..ea1b0cd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,11 +12,12 @@ permissions: jobs: build: runs-on: ubuntu-latest + timeout-minutes: 10 name: Ruby ${{ matrix.ruby }} strategy: + fail-fast: false matrix: ruby: - - 3.3 - 3.4 - ruby-head steps: diff --git a/.gitignore b/.gitignore index 1cbe6b0..31e14ba 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,5 @@ # rspec failure tracking .rspec_status + +/Gemfile.lock diff --git a/.rubocop.yml b/.rubocop.yml index 3314cc6..51b091c 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,6 +1,7 @@ +inherit_from: config/eightyfourcodes.yml + plugins: - rubocop-rspec - - rubocop-rake AllCops: NewCops: enable diff --git a/Gemfile b/Gemfile index df36eda..370858f 100644 --- a/Gemfile +++ b/Gemfile @@ -1,15 +1,15 @@ # frozen_string_literal: true -source 'https://rubygems.org' +source "https://rubygems.org" # Specify your gem's dependencies in rubocop-eightyfourcodes.gemspec gemspec group :development, :test do - gem 'rake' - gem 'rspec' - gem 'rubocop' - gem 'rubocop-rake' - gem 'rubocop-rspec' - gem 'yard' + gem "rake" + gem "rspec" + gem "rubocop" + gem "rubocop-rake" + gem "rubocop-rspec" + gem "yard" end diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index 873a6c3..0000000 --- a/Gemfile.lock +++ /dev/null @@ -1,77 +0,0 @@ -PATH - remote: . - specs: - rubocop-eightyfourcodes (0.0.5) - rubocop (>= 1.69.0, < 2) - -GEM - remote: https://rubygems.org/ - specs: - ast (2.4.3) - diff-lcs (1.6.1) - json (2.11.3) - language_server-protocol (3.17.0.4) - lint_roller (1.1.0) - parallel (1.27.0) - parser (3.3.8.0) - ast (~> 2.4.1) - racc - prism (1.4.0) - racc (1.8.1) - rainbow (3.1.1) - rake (13.2.1) - regexp_parser (2.10.0) - rspec (3.13.0) - rspec-core (~> 3.13.0) - rspec-expectations (~> 3.13.0) - rspec-mocks (~> 3.13.0) - rspec-core (3.13.3) - rspec-support (~> 3.13.0) - rspec-expectations (3.13.3) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.13.0) - rspec-mocks (3.13.2) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.13.0) - rspec-support (3.13.2) - rubocop (1.75.4) - json (~> 2.3) - language_server-protocol (~> 3.17.0.2) - lint_roller (~> 1.1.0) - parallel (~> 1.10) - parser (>= 3.3.0.2) - rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 2.9.3, < 3.0) - rubocop-ast (>= 1.44.0, < 2.0) - ruby-progressbar (~> 1.7) - unicode-display_width (>= 2.4.0, < 4.0) - rubocop-ast (1.44.1) - parser (>= 3.3.7.2) - prism (~> 1.4) - rubocop-rake (0.7.1) - lint_roller (~> 1.1) - rubocop (>= 1.72.1) - rubocop-rspec (3.6.0) - lint_roller (~> 1.1) - rubocop (~> 1.72, >= 1.72.1) - ruby-progressbar (1.13.0) - unicode-display_width (3.1.4) - unicode-emoji (~> 4.0, >= 4.0.4) - unicode-emoji (4.0.4) - yard (0.9.37) - -PLATFORMS - arm64-darwin-23 - ruby - -DEPENDENCIES - rake - rspec - rubocop - rubocop-eightyfourcodes! - rubocop-rake - rubocop-rspec - yard - -BUNDLED WITH - 2.6.4 diff --git a/README.md b/README.md index 2b0b860..9813cb0 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,13 @@ require: rubocop-eightyfourcodes Now you can run `rubocop` and it will automatically load the RuboCop eightyfourcodes cops together with the standard cops. +To use the `eightyfourcodes` RuboCop config: + +```yaml +inherit_gem: + rubocop-eightyfourcodes: config/eightyfourcodes.yml +``` + ## Development After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. @@ -36,6 +43,20 @@ Use `bundle exec rake 'new_cop[EightyFourCodes/CommandLiteralInjection]'` to gen The [NodePattern Debugger](https://nodepattern.herokuapp.com/) is a very helpful resource when creating new AST matchers. + +If you need to try out this gem in a project using it, before releasing a new version, you can do the following in the project: + +```ruby +gem "rubocop-eightyfourcodes", **(ENV["LOCAL_RUBOCOP84"] ? { path: ENV["LOCAL_RUBOCOP84"] } : {}) +``` + +Then try it like this: + +```shell +LOCAL_RUBOCOP84=~/repos/rubocop-eightyfourcodes bundle install +LOCAL_RUBOCOP84=~/repos/rubocop-eightyfourcodes bundle exec rubocop +``` + ## Releasing To install this gem onto your local machine, run `bundle exec rake install`. diff --git a/Rakefile b/Rakefile index ec416e1..651018a 100644 --- a/Rakefile +++ b/Rakefile @@ -1,23 +1,23 @@ # frozen_string_literal: true -require 'bundler/gem_tasks' -require 'rspec/core/rake_task' -require 'rubocop/rake_task' +require "bundler/gem_tasks" +require "rspec/core/rake_task" +require "rubocop/rake_task" RuboCop::RakeTask.new task default: %i[spec rubocop] RSpec::Core::RakeTask.new(:spec) do |spec| - spec.pattern = FileList['spec/**/*_spec.rb'] + spec.pattern = FileList["spec/**/*_spec.rb"] end -desc 'Generate a new cop with a template' +desc "Generate a new cop with a template" task :new_cop, [:cop] do |_task, args| - require 'rubocop' + require "rubocop" cop_name = args.fetch(:cop) do - warn 'usage: bundle exec rake new_cop[Department/Name]' + warn "usage: bundle exec rake new_cop[Department/Name]" exit! end @@ -25,8 +25,8 @@ task :new_cop, [:cop] do |_task, args| generator.write_source generator.write_spec - generator.inject_require(root_file_path: 'lib/rubocop/cop/eightyfourcodes_cops.rb') - generator.inject_config(config_file_path: 'config/default.yml') + generator.inject_require(root_file_path: "lib/rubocop/cop/eightyfourcodes_cops.rb") + generator.inject_config(config_file_path: "config/default.yml") puts generator.todo end diff --git a/bin/console b/bin/console index 88084a2..91e6df5 100755 --- a/bin/console +++ b/bin/console @@ -1,8 +1,8 @@ #!/usr/bin/env ruby # frozen_string_literal: true -require 'bundler/setup' -require 'rubocop/eightyfourcodes' +require "bundler/setup" +require "rubocop/eightyfourcodes" # You can add fixtures and/or initialization code here to make experimenting # with your gem easier. You can also use a different console, if you like. @@ -11,5 +11,5 @@ require 'rubocop/eightyfourcodes' # require "pry" # Pry.start -require 'irb' +require "irb" IRB.start(__FILE__) diff --git a/config/eightyfourcodes.yml b/config/eightyfourcodes.yml new file mode 100644 index 0000000..d100151 --- /dev/null +++ b/config/eightyfourcodes.yml @@ -0,0 +1,143 @@ +plugins: + - rubocop-minitest + - rubocop-performance + - rubocop-rake + - rubocop-sequel + +require: + - rubocop-eightyfourcodes + +AllCops: + TargetRubyVersion: 3.4 + NewCops: enable + +### Metrics + +Metrics/ClassLength: + Max: 300 + CountAsOne: ["array", "hash", "heredoc", "method_call"] + +Metrics/ModuleLength: + Max: 300 + CountAsOne: ["array", "hash", "heredoc", "method_call"] + +Metrics/MethodLength: + Max: 50 + CountAsOne: ["array", "hash", "heredoc", "method_call"] + +Metrics/AbcSize: + Max: 40 + +Metrics/CyclomaticComplexity: + Max: 12 + +Metrics/BlockLength: + Max: 200 + AllowedMethods: + - refine + - describe + +Metrics/ParameterLists: + CountKeywordArgs: false + +### Lint + +Lint/DuplicateBranch: + IgnoreDuplicateElseBranch: true + IgnoreLiteralBranches: true + IgnoreConstantBranches: true + +Lint/UselessConstantScoping: + # Increases indirection and reduces readability. We often don't care about constant scoping. + Enabled: false + +### Style + +Style/Documentation: + Enabled: false + +Style/GuardClause: + AllowConsecutiveConditionals: true + +Style/StringLiterals: + EnforcedStyle: double_quotes + +Style/MethodCallWithArgsParentheses: + AllowParenthesesInMultilineCall: true + AllowParenthesesInChaining: true + AllowParenthesesInCamelCaseMethod: true + AllowParenthesesInStringInterpolation: true + AllowedMethods: ["puts", "print"] + AllowedPatterns: ["^assert"] + +Style/ClassVars: + # We use them quite a lot, and the "good" alternative is not so nice. + # Need a targeted effort to refactor our codebase to get rid of them. + Enabled: false + +Style/TrailingCommaInHashLiteral: + EnforcedStyleForMultiline: comma + +Style/TrailingCommaInArrayLiteral: + EnforcedStyleForMultiline: comma + +Style/HashSyntax: + EnforcedShorthandSyntax: always + +### Layout + +Layout/FirstHashElementIndentation: + EnforcedStyle: consistent + +Layout/MultilineMethodCallIndentation: + EnforcedStyle: indented + +Layout/LineLength: + URISchemes: ["http", "https", "amqp", "amqps"] + AllowedPatterns: + - '^\s*puts(\s|\()' + - '^\s*print(\s|\()' + - '^\s*@?log(ger)?[\s\(\.]' + - '^\s*LOG(GER)?[\s\(\.]' + - '^\s*debug[\s\(]' + - '^\s*\#' + +### Performance + +Performance/RedundantMerge: + MaxKeyValuePairs: 1 + +Performance/BigDecimalWithNumericArgument: + Enabled: false + +Performance/ChainArrayAllocation: + Enabled: false + +### Naming + +Naming/MethodParameterName: + MinNameLength: 1 + +Naming/PredicateMethod: + AllowBangMethods: true + +### Security + +GitlabSecurity/JsonSerialization: + Enabled: false + +### Minitest + +Minitest/GlobalExpectations: + EnforcedStyle: _ + +Minitest/MultipleAssertions: + Enabled: true + +# Sequel + +Sequel/SaveChanges: + Enabled: false + +Sequel/IrreversibleMigration: + Enabled: false diff --git a/lib/rubocop-eightyfourcodes.rb b/lib/rubocop-eightyfourcodes.rb index 53c1217..8c3705d 100644 --- a/lib/rubocop-eightyfourcodes.rb +++ b/lib/rubocop-eightyfourcodes.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require 'rubocop' +require "rubocop" -require_relative 'rubocop/eightyfourcodes' -require_relative 'rubocop/eightyfourcodes/version' -require_relative 'rubocop/eightyfourcodes/inject' +require_relative "rubocop/eightyfourcodes" +require_relative "rubocop/eightyfourcodes/version" +require_relative "rubocop/eightyfourcodes/inject" RuboCop::EightyFourCodes::Inject.defaults! -require_relative 'rubocop/cop/eightyfourcodes_cops' +require_relative "rubocop/cop/eightyfourcodes_cops" diff --git a/lib/rubocop/cop/eighty_four_codes/ensure_redirect.rb b/lib/rubocop/cop/eighty_four_codes/ensure_redirect.rb index 7993304..0972721 100644 --- a/lib/rubocop/cop/eighty_four_codes/ensure_redirect.rb +++ b/lib/rubocop/cop/eighty_four_codes/ensure_redirect.rb @@ -33,7 +33,7 @@ module EightyFourCodes # cleanup # end class EnsureRedirect < Base - MSG = 'Do not redirect from an `ensure` block.' + MSG = "Do not redirect from an `ensure` block." def on_ensure(node) # `:send` nodes represent method calls, so we look for send nodes and then check if they are `redirect` diff --git a/lib/rubocop/cop/eighty_four_codes/ruby_version_file.rb b/lib/rubocop/cop/eighty_four_codes/ruby_version_file.rb index 761ad81..3a0f4c1 100644 --- a/lib/rubocop/cop/eighty_four_codes/ruby_version_file.rb +++ b/lib/rubocop/cop/eighty_four_codes/ruby_version_file.rb @@ -28,12 +28,12 @@ class RubyVersionFile < Base PATTERN def on_send(node) - return unless File.basename(processed_source.file_path).eql?('Gemfile') + return unless File.basename(processed_source.file_path).eql?("Gemfile") static_version_found?(node) do |source_node, source| - message = format(MSG, source: source) + message = format(MSG, source:) - add_offense(source_node, message: message) do |corrector| + add_offense(source_node, message:) do |corrector| corrector.replace(source_node, "File.read('.ruby-version')") end end diff --git a/lib/rubocop/cop/eightyfourcodes_cops.rb b/lib/rubocop/cop/eightyfourcodes_cops.rb index 00ec82f..9b7ca6f 100644 --- a/lib/rubocop/cop/eightyfourcodes_cops.rb +++ b/lib/rubocop/cop/eightyfourcodes_cops.rb @@ -1,12 +1,12 @@ # frozen_string_literal: true -require_relative 'eighty_four_codes/command_literal_injection' -require_relative 'eighty_four_codes/ensure_redirect' -require_relative 'eighty_four_codes/ruby_version_file' +require_relative "eighty_four_codes/command_literal_injection" +require_relative "eighty_four_codes/ensure_redirect" +require_relative "eighty_four_codes/ruby_version_file" -require_relative 'gitlab_security/json_serialization' -require_relative 'gitlab_security/public_send' -require_relative 'gitlab_security/redirect_to_params_update' -require_relative 'gitlab_security/send_file_params' -require_relative 'gitlab_security/sql_injection' -require_relative 'gitlab_security/system_command_injection' +require_relative "gitlab_security/json_serialization" +require_relative "gitlab_security/public_send" +require_relative "gitlab_security/redirect_to_params_update" +require_relative "gitlab_security/send_file_params" +require_relative "gitlab_security/sql_injection" +require_relative "gitlab_security/system_command_injection" diff --git a/lib/rubocop/eightyfourcodes.rb b/lib/rubocop/eightyfourcodes.rb index 657980d..89e0a57 100644 --- a/lib/rubocop/eightyfourcodes.rb +++ b/lib/rubocop/eightyfourcodes.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true -require_relative 'eightyfourcodes/version' +require_relative "eightyfourcodes/version" module RuboCop # Namespace for EightyFourCodes cops module EightyFourCodes class Error < StandardError; end PROJECT_ROOT = Pathname.new(__dir__).parent.parent.expand_path.freeze - CONFIG_DEFAULT = PROJECT_ROOT.join('config', 'default.yml').freeze + CONFIG_DEFAULT = PROJECT_ROOT.join("config", "default.yml").freeze CONFIG = YAML.safe_load(CONFIG_DEFAULT.read).freeze private_constant(:CONFIG_DEFAULT, :PROJECT_ROOT) diff --git a/lib/rubocop/eightyfourcodes/inject.rb b/lib/rubocop/eightyfourcodes/inject.rb index 2914a36..6332c3d 100644 --- a/lib/rubocop/eightyfourcodes/inject.rb +++ b/lib/rubocop/eightyfourcodes/inject.rb @@ -9,7 +9,7 @@ module EightyFourCodes module Inject def self.defaults! path = CONFIG_DEFAULT.to_s - hash = ConfigLoader.send(:load_yaml_configuration, path) + hash = ConfigLoader.send(:load_yaml_configuration, path) # rubocop:disable GitlabSecurity/PublicSend config = Config.new(hash, path).tap(&:make_excludes_absolute) puts "configuration from #{path}" if ConfigLoader.debug? config = ConfigLoader.merge_with_default(config, path) diff --git a/lib/rubocop/eightyfourcodes/version.rb b/lib/rubocop/eightyfourcodes/version.rb index f695d9c..cc75ed6 100644 --- a/lib/rubocop/eightyfourcodes/version.rb +++ b/lib/rubocop/eightyfourcodes/version.rb @@ -2,6 +2,6 @@ module RuboCop module EightyFourCodes - VERSION = '0.0.5' + VERSION = "0.0.5" end end diff --git a/rubocop-eightyfourcodes.gemspec b/rubocop-eightyfourcodes.gemspec index 71d632e..e710d2b 100644 --- a/rubocop-eightyfourcodes.gemspec +++ b/rubocop-eightyfourcodes.gemspec @@ -1,34 +1,33 @@ # frozen_string_literal: true -require_relative 'lib/rubocop/eightyfourcodes/version' +require_relative "lib/rubocop/eightyfourcodes/version" Gem::Specification.new do |spec| - spec.name = 'rubocop-eightyfourcodes' + spec.name = "rubocop-eightyfourcodes" spec.version = RuboCop::EightyFourCodes::VERSION - spec.authors = ['Anders Bälter'] - spec.email = ['anders@84codes.com'] + spec.authors = ["84codes"] + spec.email = ["developers@84codes.com"] - spec.summary = 'This is a collection of cops developed and used by 84codes AB.' + spec.summary = "This is a collection of cops developed and used by 84codes AB." spec.description = <<~DESCRIPTION A plugin for the RuboCop code style enforcing & linting tool. DESCRIPTION - spec.homepage = 'https://github.com/84codes/rubocop-eightyfourcodes/' - spec.license = 'MIT' - spec.required_ruby_version = '>= 2.6.0' + spec.homepage = "https://github.com/84codes/rubocop-eightyfourcodes" + spec.license = "MIT" + spec.required_ruby_version = ">= 3.4.0" spec.metadata = { - 'rubygems_mfa_required' => 'true' + "rubygems_mfa_required" => "true", } - # Specify which files should be added to the gem when it is released. - # The `git ls-files -z` loads the files in the RubyGem that have been added into git. - spec.files = Dir.chdir(__dir__) do - `git ls-files -z`.split("\x0").reject do |f| - (File.expand_path(f) == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|circleci)|appveyor)}) - end - end + spec.files = Dir["LICENSE.md", "config/**/*.yml", "lib/**/*.rb"] + spec.require_paths = ["lib"] - spec.require_paths = ['lib'] - spec.add_dependency 'rubocop', ['>= 1.69.0', '< 2'] - spec.extra_rdoc_files = ['LICENSE.md', 'README.md'] + spec.add_dependency "rubocop", [">= 1.69.0", "< 2"] + spec.add_dependency "rubocop-minitest" + spec.add_dependency "rubocop-performance" + spec.add_dependency "rubocop-rake" + spec.add_dependency "rubocop-sequel" + + spec.extra_rdoc_files = ["LICENSE.md", "README.md"] end diff --git a/sig/rubocop/eightyfourcodes.rbs b/sig/rubocop/eightyfourcodes.rbs deleted file mode 100644 index 931c7ae..0000000 --- a/sig/rubocop/eightyfourcodes.rbs +++ /dev/null @@ -1,6 +0,0 @@ -module Rubocop - module EightyFourCodes - VERSION: String - # See the writing guide of rbs: https://github.com/ruby/rbs#guides - end -end diff --git a/spec/rubocop/cop/eighty_four_codes/command_literal_injection_spec.rb b/spec/rubocop/cop/eighty_four_codes/command_literal_injection_spec.rb index d21ec49..25e4f78 100644 --- a/spec/rubocop/cop/eighty_four_codes/command_literal_injection_spec.rb +++ b/spec/rubocop/cop/eighty_four_codes/command_literal_injection_spec.rb @@ -1,16 +1,16 @@ # frozen_string_literal: true -require './spec/spec_helper' +require "./spec/spec_helper" RSpec.describe RuboCop::Cop::EightyFourCodes::CommandLiteralInjection, :config do let(:config) { RuboCop::Config.new } - let(:cop_name) { 'EightyFourCodes/CommandLiteralInjection' } + let(:cop_name) { "EightyFourCodes/CommandLiteralInjection" } let(:cop_message) do "#{cop_name}: Do not include variables command literals. Use parameters \"system(cmd, params)\" or exec() instead" end - describe '%x commands with interpolation' do - it 'registers an offense' do + describe "%x commands with interpolation" do + it "registers an offense" do expect_offense(<<~RUBY) my_var = 1 %x(cat \#{my_var}) @@ -18,7 +18,7 @@ RUBY end - it 'registers an offense if command conitnues' do + it "registers an offense if command conitnues" do expect_offense(<<~RUBY) my_var = 1 %x(cat \#{my_var} | less) @@ -26,7 +26,7 @@ RUBY end - it 'registers an offense if variable is at the beginning' do + it "registers an offense if variable is at the beginning" do expect_offense(<<~RUBY) my_var = 1 %x(\#{my_var} | less) @@ -34,15 +34,15 @@ RUBY end - it 'allows %x without arguments' do + it "allows %x without arguments" do expect_no_offenses(<<-RUBY) %x(cat /var/log/syslog) RUBY end end - describe '`` commands with interpolation' do - it 'registers an offense' do + describe "`` commands with interpolation" do + it "registers an offense" do expect_offense(<<~RUBY) my_var = 1 `cat \#{my_var}` @@ -50,7 +50,7 @@ RUBY end - it 'registers an offense if command conitnues' do + it "registers an offense if command conitnues" do expect_offense(<<~RUBY) my_var = 1 `cat \#{my_var} | less` @@ -58,7 +58,7 @@ RUBY end - it 'registers an offense if variable is at the beginning' do + it "registers an offense if variable is at the beginning" do expect_offense(<<~RUBY) my_var = 1 `\#{my_var} | less` @@ -66,7 +66,7 @@ RUBY end - it 'registers an offense on multiple variables' do + it "registers an offense on multiple variables" do expect_offense(<<~RUBY) my_var = 1 `cat \#{my_var} | less \#{my_var}` @@ -74,7 +74,7 @@ RUBY end - it 'allows %x without arguments' do + it "allows %x without arguments" do expect_no_offenses(<<-RUBY) `cat /var/log/syslog` RUBY diff --git a/spec/rubocop/cop/eighty_four_codes/ensure_redirect_spec.rb b/spec/rubocop/cop/eighty_four_codes/ensure_redirect_spec.rb index 40ec512..e546e26 100644 --- a/spec/rubocop/cop/eighty_four_codes/ensure_redirect_spec.rb +++ b/spec/rubocop/cop/eighty_four_codes/ensure_redirect_spec.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true -require './spec/spec_helper' +require "./spec/spec_helper" RSpec.describe RuboCop::Cop::EightyFourCodes::EnsureRedirect, :config do let(:config) { RuboCop::Config.new } - let(:cop_name) { 'EightyFourCodes/EnsureRedirect' } + let(:cop_name) { "EightyFourCodes/EnsureRedirect" } let(:cop_message) { "#{cop_name}: Do not redirect from an `ensure` block." } - it 'registers an offense and corrects for redirect in ensure' do + it "registers an offense and corrects for redirect in ensure" do expect_offense(<<~RUBY) begin something @@ -21,7 +21,7 @@ expect_no_corrections end - it 'registers an offense and corrects for redirect with argument in ensure' do + it "registers an offense and corrects for redirect with argument in ensure" do expect_offense(<<~RUBY) begin foo @@ -34,7 +34,7 @@ expect_no_corrections end - it 'registers an offense when redirecting multiple values in `ensure`' do + it "registers an offense when redirecting multiple values in `ensure`" do expect_offense(<<~RUBY) begin something @@ -48,7 +48,7 @@ expect_no_corrections end - it 'does not register an offense for redirect outside ensure' do + it "does not register an offense for redirect outside ensure" do expect_no_offenses(<<~RUBY) begin something @@ -59,7 +59,7 @@ RUBY end - it 'does not check when ensure block has no body' do + it "does not check when ensure block has no body" do expect_no_offenses(<<~RUBY) begin something diff --git a/spec/rubocop/cop/eighty_four_codes/ruby_version_file_spec.rb b/spec/rubocop/cop/eighty_four_codes/ruby_version_file_spec.rb index dbd70e4..e256bb3 100644 --- a/spec/rubocop/cop/eighty_four_codes/ruby_version_file_spec.rb +++ b/spec/rubocop/cop/eighty_four_codes/ruby_version_file_spec.rb @@ -1,16 +1,16 @@ # frozen_string_literal: true -require './spec/spec_helper' +require "./spec/spec_helper" RSpec.describe RuboCop::Cop::EightyFourCodes::RubyVersionFile, :config do let(:config) { RuboCop::Config.new } - let(:cop_name) { 'EightyFourCodes/RubyVersionFile' } + let(:cop_name) { "EightyFourCodes/RubyVersionFile" } let(:cop_message) do "#{cop_name}: Control Ruby version via .ruby-version, fix by replacing with File.read('.ruby-version')" end - it 'registers an offense defined with double quotes' do - expect_offense(<<~RUBY, 'Gemfile') + it "registers an offense defined with double quotes" do + expect_offense(<<~RUBY, "Gemfile") ruby "2.6.6" ^^^^^^^ #{cop_message} RUBY @@ -20,8 +20,8 @@ RUBY end - it 'registers an offense defined with single quotes' do - expect_offense(<<~RUBY, 'Gemfile') + it "registers an offense defined with single quotes" do + expect_offense(<<~RUBY, "Gemfile") ruby '2.1.0' ^^^^^^^ #{cop_message} RUBY @@ -31,14 +31,14 @@ RUBY end - it 'does not register an offense when not in Gemfile' do - expect_no_offenses(<<~RUBY, 'test.rb') + it "does not register an offense when not in Gemfile" do + expect_no_offenses(<<~RUBY, "test.rb") ruby '2.1.0' RUBY end - it 'does not register an offense when reading .ruby-version' do - expect_no_offenses(<<~RUBY, 'Gemfile') + it "does not register an offense when reading .ruby-version" do + expect_no_offenses(<<~RUBY, "Gemfile") ruby File.read('.ruby-version') RUBY end diff --git a/spec/rubocop/eighty_four_codes_spec.rb b/spec/rubocop/eighty_four_codes_spec.rb index 1779f4f..20e977f 100644 --- a/spec/rubocop/eighty_four_codes_spec.rb +++ b/spec/rubocop/eighty_four_codes_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -require './spec/spec_helper' +require "./spec/spec_helper" RSpec.describe RuboCop::EightyFourCodes do - it 'has a version number' do + it "has a version number" do expect(RuboCop::EightyFourCodes::VERSION).not_to be_nil end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 0a96064..30fcef4 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -require 'rubocop-eightyfourcodes' -require 'rspec' -require 'rubocop/rspec/support' +require "rubocop-eightyfourcodes" +require "rspec" +require "rubocop/rspec/support" RSpec.configure do |config| config.include RuboCop::RSpec::ExpectOffense @@ -19,5 +19,5 @@ meta[:type] = :cop_spec end - config.include_context 'config', type: :cop_spec + config.include_context "config", type: :cop_spec end