diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4ef9ab5..3963d08 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: ruby: - - '2.6' + - '2.7' steps: - uses: actions/checkout@v2 diff --git a/.gitignore b/.gitignore index b04a8c8..4936e10 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,6 @@ /pkg/ /spec/reports/ /tmp/ - +vendor/ # rspec failure tracking .rspec_status diff --git a/.rubocop.yml b/.rubocop.yml index fbbc036..8cbb45e 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,9 +1,9 @@ -AllCops: - NewCops: enable - SuggestExtensions: false - TargetRubyVersion: 2.6 +inherit_gem: + rubocop-github: + - config/default.yml + - config/rails.yml Naming/FileName: Enabled: true Exclude: - - "rubocop-rails-accessibility.gemspec" \ No newline at end of file + - "rubocop-rails-accessibility.gemspec" diff --git a/Gemfile b/Gemfile index fbfb8dc..fb446d7 100644 --- a/Gemfile +++ b/Gemfile @@ -1,10 +1,6 @@ # frozen_string_literal: true -source 'https://rubygems.org' +source "https://rubygems.org" # Specify your gem's dependencies in rubocop-rails-accessibility.gemspec gemspec - -gem 'rake', '~> 13.0' -gem 'rspec', '~> 3.0' -gem 'rubocop', '~> 1.21' diff --git a/Gemfile.lock b/Gemfile.lock index 64ba245..ecc1cb7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,7 +2,7 @@ PATH remote: . specs: rubocop-rails-accessibility (0.1.0) - rubocop + rubocop (>= 1.0.0) GEM remote: https://rubygems.org/ @@ -31,12 +31,15 @@ GEM crass (~> 1.0.2) nokogiri (>= 1.5.9) minitest (5.16.3) + nokogiri (1.13.8-x86_64-darwin) + racc (~> 1.4) nokogiri (1.13.8-x86_64-linux) racc (~> 1.4) parallel (1.22.1) parser (3.1.2.0) ast (~> 2.4.1) racc (1.6.0) + rack (2.2.4) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) @@ -71,12 +74,24 @@ GEM unicode-display_width (>= 1.4.0, < 3.0) rubocop-ast (1.19.1) parser (>= 3.1.1.0) + rubocop-github (0.18.0) + rubocop (>= 1.0.0) + rubocop-performance + rubocop-rails + rubocop-performance (1.14.3) + rubocop (>= 1.7.0, < 2.0) + rubocop-ast (>= 0.4.0) + rubocop-rails (2.15.2) + activesupport (>= 4.2.0) + rack (>= 1.1) + rubocop (>= 1.7.0, < 2.0) ruby-progressbar (1.11.0) tzinfo (2.0.5) concurrent-ruby (~> 1.0) unicode-display_width (2.2.0) PLATFORMS + x86_64-darwin-19 x86_64-linux DEPENDENCIES @@ -84,7 +99,9 @@ DEPENDENCIES minitest rake (~> 13.0) rspec (~> 3.0) - rubocop (~> 1.21) + rubocop-github + rubocop-performance + rubocop-rails rubocop-rails-accessibility! BUNDLED WITH diff --git a/Rakefile b/Rakefile index 1956e2e..10da0ea 100644 --- a/Rakefile +++ b/Rakefile @@ -1,22 +1,22 @@ # frozen_string_literal: true -require 'bundler/gem_tasks' -require 'rake/testtask' -require 'rspec/core/rake_task' +require "bundler/gem_tasks" +require "rake/testtask" +require "rspec/core/rake_task" Rake::TestTask.new RSpec::Core::RakeTask.new(:spec) -require 'rubocop/rake_task' +require "rubocop/rake_task" RuboCop::RakeTask.new task default: %i[test rubocop] -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]'" @@ -27,8 +27,8 @@ task :new_cop, [:cop] do |_task, args| generator.write_source generator.write_spec - generator.inject_require(root_file_path: 'lib/rubocop-rails-accessibility.rb') - generator.inject_config(config_file_path: 'config/default.yml') + generator.inject_require(root_file_path: "lib/rubocop-rails-accessibility.rb") + generator.inject_config(config_file_path: "config/default.yml") puts generator.todo end diff --git a/config/default.yml b/config/default.yml index ba92bf2..c5cbbd3 100644 --- a/config/default.yml +++ b/config/default.yml @@ -1,6 +1,5 @@ require: - rubocop/cop/rubocop_rails_accessibility_cops - - rubocop-performance AllCops: DisabledByDefault: true diff --git a/lib/rubocop/cop/inject.rb b/lib/rubocop/cop/inject.rb index ee0f10c..77ccd2e 100644 --- a/lib/rubocop/cop/inject.rb +++ b/lib/rubocop/cop/inject.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'rubocop' +require "rubocop" # The original code is from https://github.com/rubocop/rubocop-rspec/blob/main/lib/rubocop/rspec/inject.rb # See https://github.com/rubocop/rubocop-rspec/blob/main/MIT-LICENSE.md diff --git a/lib/rubocop/cop/rubocop-rails-accessibility/image_has_alt.rb b/lib/rubocop/cop/rubocop-rails-accessibility/image_has_alt.rb index 7b987f4..0558fd6 100644 --- a/lib/rubocop/cop/rubocop-rails-accessibility/image_has_alt.rb +++ b/lib/rubocop/cop/rubocop-rails-accessibility/image_has_alt.rb @@ -1,14 +1,14 @@ # frozen_string_literal: true -require 'rubocop' +require "rubocop" module RuboCop module Cop module RubocopRailsAccessibility class ImageHasAlt < Base - MSG = 'Images should have an alt prop with meaningful text or an empty string for decorative images' + MSG = "Images should have an alt prop with meaningful text or an empty string for decorative images" - def_node_search :has_alt_attribute?, '(sym :alt)' + def_node_search :has_alt_attribute?, "(sym :alt)" def on_send(node) receiver, method_name, = *node diff --git a/lib/rubocop/cop/rubocop-rails-accessibility/link_has_href.rb b/lib/rubocop/cop/rubocop-rails-accessibility/link_has_href.rb index 3fcab22..44537d4 100644 --- a/lib/rubocop/cop/rubocop-rails-accessibility/link_has_href.rb +++ b/lib/rubocop/cop/rubocop-rails-accessibility/link_has_href.rb @@ -1,19 +1,19 @@ # frozen_string_literal: true -require 'rubocop' +require "rubocop" module RuboCop module Cop module RubocopRailsAccessibility class LinkHasHref < Base - MSG = 'Links should go somewhere, you probably want to use a `