diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 32835f70..8e1d66d1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -48,6 +48,10 @@ jobs: uses: ruby/setup-ruby@v1 with: ruby-version: 2.7 + - run: bundle install && bundle exec rubocop + name: "Run RuboCop" + env: + RUBOCOP: yes - run: bundle install && bundle exec rake test:rails env: RAILS: 5.2.8 diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 00000000..cee0b4d4 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,17 @@ +inherit_from: .rubocop_todo.yml + +# The behavior of RuboCop can be controlled via the .rubocop.yml +# configuration file. It makes it possible to enable/disable +# certain cops (checks) and to alter their behavior if they accept +# any parameters. The file can be placed either in your home +# directory or in some project directory. +# +# RuboCop will start looking for the configuration file in the directory +# where the inspected file is and continue its way up to the root directory. +# +# See https://docs.rubocop.org/rubocop/configuration +AllCops: + DisabledByDefault: true + TargetRubyVersion: 2.5 +Security: + Enabled: true diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 00000000..7cfc3644 --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,20 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2023-10-05 22:09:56 UTC using RuboCop version 1.56.4. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# Offense count: 5 +Security/Eval: + Exclude: + - 'lib/slim/command.rb' + - 'lib/slim/translator.rb' + - 'test/literate/run.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Security/YAMLLoad: + Exclude: + - 'lib/slim/command.rb' diff --git a/Gemfile b/Gemfile index 93300652..fbbedaea 100644 --- a/Gemfile +++ b/Gemfile @@ -41,3 +41,8 @@ if ENV['SINATRA'] gem 'sinatra', tag: "v#{ENV['SINATRA']}" end end + +if ENV['RUBOCOP'] + gem 'rubocop' + gem 'rubocop-rails' +end