diff --git a/.github/workflows/specs.yml b/.github/workflows/specs.yml index 2eab4dc..28913eb 100644 --- a/.github/workflows/specs.yml +++ b/.github/workflows/specs.yml @@ -17,10 +17,19 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 + - name: Set up Ruby uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} - bundler-cache: true # runs 'bundle install' and caches installed gems automatically + bundler-cache: true + - name: Run tests run: bundle exec rake + + - name: Archive screenshots for failed tests + uses: actions/upload-artifact@v2 + if: failure() + with: + name: test-failed-screenshots + path: spec/dummy/tmp/screenshots diff --git a/.reek.yml b/.reek.yml new file mode 100644 index 0000000..60ec1c7 --- /dev/null +++ b/.reek.yml @@ -0,0 +1,11 @@ +--- +exclude_paths: + - spec/dummy + - vendor + +detectors: + IrresponsibleModule: + enabled: false + TooManyStatements: + # default 5 + max_statements: 10 diff --git a/.rubocop.yml b/.rubocop.yml index 6bcb7ad..0042f74 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,6 +1,12 @@ inherit_from: - https://relaxed.ruby.style/rubocop.yml +require: + - rubocop-packaging + - rubocop-performance + - rubocop-rails + - rubocop-rspec + AllCops: Exclude: - bin/* @@ -17,6 +23,14 @@ Layout/LineLength: Enabled: true Max: 120 +RSpec/ExampleLength: + # default 5 + Max: 12 + +RSpec/MultipleExpectations: + # default 1 + Max: 4 + Style/HashEachMethods: Enabled: true diff --git a/Gemfile b/Gemfile index ca9563c..43e4de0 100644 --- a/Gemfile +++ b/Gemfile @@ -4,13 +4,22 @@ source 'https://rubygems.org' gemspec +# Linters +gem 'brakeman' +gem 'fasterer' +gem 'reek' +gem 'rubocop' +gem 'rubocop-packaging' +gem 'rubocop-performance' +gem 'rubocop-rails' +gem 'rubocop-rspec' + group :development, :test do gem 'activestorage', '~> 6.0' gem 'capybara', '~> 3.33' gem 'puma', '~> 4.3' gem 'rspec_junit_formatter', '~> 0.4' gem 'rspec-rails', '~> 4.0' - gem 'rubocop', '~> 1.0' gem 'selenium-webdriver', '~> 3.142' gem 'sprockets-rails', '~> 3.2' gem 'sqlite3', '~> 1.4' diff --git a/bin/brakeman b/bin/brakeman new file mode 100755 index 0000000..4b79003 --- /dev/null +++ b/bin/brakeman @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'brakeman' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require "pathname" +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +bundle_binstub = File.expand_path("../bundle", __FILE__) + +if File.file?(bundle_binstub) + if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ + load(bundle_binstub) + else + abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. +Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") + end +end + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("brakeman", "brakeman") diff --git a/bin/code_climate_reek b/bin/code_climate_reek new file mode 100755 index 0000000..9bb9536 --- /dev/null +++ b/bin/code_climate_reek @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'code_climate_reek' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require "pathname" +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +bundle_binstub = File.expand_path("../bundle", __FILE__) + +if File.file?(bundle_binstub) + if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ + load(bundle_binstub) + else + abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. +Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") + end +end + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("reek", "code_climate_reek") diff --git a/bin/fasterer b/bin/fasterer new file mode 100755 index 0000000..b87e7ae --- /dev/null +++ b/bin/fasterer @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'fasterer' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require "pathname" +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +bundle_binstub = File.expand_path("../bundle", __FILE__) + +if File.file?(bundle_binstub) + if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ + load(bundle_binstub) + else + abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. +Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") + end +end + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("fasterer", "fasterer") diff --git a/bin/reek b/bin/reek new file mode 100755 index 0000000..cafe88d --- /dev/null +++ b/bin/reek @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'reek' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require "pathname" +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +bundle_binstub = File.expand_path("../bundle", __FILE__) + +if File.file?(bundle_binstub) + if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ + load(bundle_binstub) + else + abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. +Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") + end +end + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("reek", "reek") diff --git a/examples/upload_plugin_using_activestorage/app/admin/posts.rb b/examples/upload_plugin_using_activestorage/app/admin/posts.rb index 869860f..cda7a25 100644 --- a/examples/upload_plugin_using_activestorage/app/admin/posts.rb +++ b/examples/upload_plugin_using_activestorage/app/admin/posts.rb @@ -41,7 +41,7 @@ ActiveAdmin.register Post do row :images do |resurce| resurce.images.each do |image| div do - link_to image.filename, image, target: '_blank' + link_to image.filename, image, target: '_blank', rel: 'noopener' end end nil