Skip to content

Commit

Permalink
add rubocop github ci
Browse files Browse the repository at this point in the history
  • Loading branch information
SirineMhedhbi committed Jan 31, 2024
1 parent 053a989 commit 44fc8d3
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: RuboCop linting

on:
push:
pull_request:
types: [ opened, reopened ]

jobs:
rubocop:
runs-on: ubuntu-latest
strategy:
fail-fast: false

steps:
- name: Checkout repository
uses: actions/checkout@v3

# If running on a self-hosted runner, check it meets the requirements
# listed at https://github.com/ruby/setup-ruby#using-self-hosted-runners
- name: Set up Ruby
uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0
with:
ruby-version: 2.7.8

# This step is not necessary if you add the gem to your Gemfile
- name: Install Code Scanning integration
run: bundle add code-scanning-rubocop --version 0.3.0 --skip-install

- name: Install dependencies
run: bundle install

- name: Rubocop run
run: |
bash -c "
bundle exec rubocop --require code_scanning --format sarif -o rubocop.sarif
[[ $? -ne 2 ]]
"
- name: Upload Sarif output
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: rubocop.sarif
64 changes: 64 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
AllCops:
Exclude:
- db/migrate/**/*
- db/schema.rb
- config/**/*
- script/**/*
- bin/**/*
- test/**/*
- app/admin/**/*
- app/channels/**/*
- app/jobs/**/*
- node_modules/**/*
- Gemfile
- Rakefile
- config.ru

require:
- rubocop-rails

Style/Encoding:
Enabled: false

Style/Documentation:
Description: 'Document classes and non-namespace modules.'
Enabled: false

Style/InlineComment:
Description: 'Avoid inline comments.'
Enabled: false

Layout/LineLength:
Description: 'Limit lines to 100 characters. (Default is 80)'
Max: 100

Style/FrozenStringLiteralComment:
Description: To help transition from Ruby 2.3.0 to Ruby 3.0.
Enabled: false

Style/WordArray:
Description: 'Use %w or %W for arrays of words.'
Enabled: false

# Defaults all strings to double quotes. Less performant, but
# nicer for consistency, and for adding interpolation later.
Style/StringLiterals:
EnforcedStyle: double_quotes

# Prettier hashes.
Layout/HashAlignment:
EnforcedHashRocketStyle: table
EnforcedColonStyle: table

# No auto-correct for unused block arguments,
# but will still warn.
Lint/UnusedBlockArgument:
AutoCorrect: false

# No auto-correct for unused method arguments,
# but will still warn.
Lint/UnusedMethodArgument:
AutoCorrect: false

Rails/HasAndBelongsToMany:
Enabled: false
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ group :development do
# static code analysis
gem 'brakeman', require: false
gem 'rubocop', require: false
gem 'rubocop-rails'
# gem 'i18n-debug'
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem 'debug', platforms: %i[ mri mingw x64_mingw ]
Expand Down
6 changes: 6 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,11 @@ GEM
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.30.0)
parser (>= 3.2.1.0)
rubocop-rails (2.23.1)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
rubocop-ast (>= 1.30.0, < 2.0)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
ruby_dig (0.0.2)
Expand Down Expand Up @@ -623,6 +628,7 @@ DEPENDENCIES
rest-client
rspec-rails
rubocop
rubocop-rails
sassc-rails
selenium-webdriver
simplecov
Expand Down

0 comments on commit 44fc8d3

Please sign in to comment.