Skip to content

Commit c2ebbf7

Browse files
[ELITERT-1198] Add action to run Ruby linters
The action runs Rubocop on Pull Requests.
1 parent 7f5b7ab commit c2ebbf7

File tree

4 files changed

+106
-0
lines changed

4 files changed

+106
-0
lines changed

.github/workflows/ruby-linters.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# This workflow runs Rubocop on the Pull Requests to make sure no linter warnings slip by.
2+
3+
name: Ruby Linters
4+
5+
on:
6+
pull_request:
7+
branches: [ "master" ]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
lint:
14+
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
ruby-version: ['2.7']
19+
20+
env:
21+
BUNDLE_GEMFILE: Gemfile.lint
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
- name: Set up Ruby
26+
uses: ruby/setup-ruby@v1
27+
with:
28+
ruby-version: ${{ matrix.ruby-version }}
29+
- name: Install Gems
30+
run: |
31+
bundler install
32+
- name: Run Rubocop
33+
uses: reviewdog/[email protected]
34+
with:
35+
skip_install: true
36+
rubocop_version: gemfile
37+
rubocop_extensions: rubocop-rspec:gemfile
38+
use_bundler: true
39+
- name: reek
40+
uses: reviewdog/action-reek@v1
41+
with:
42+
reek_version: gemfile
43+
fail_on_error: true

.rubocop.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
AllCops:
22
Exclude:
3+
- vendor/**/*
34
- spec/spec_helper.rb
45
Metrics/BlockLength:
56
Exclude:

Gemfile.lint

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# frozen_string_literal: true
2+
3+
source 'https://rubygems.org'
4+
5+
gem 'rubocop', '~> 1'
6+
gem 'rubocop-rspec', '~> 3'
7+
gem 'reek', '~> 6'

lib/something.rb

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# frozen_string_literal: true
2+
3+
# Class to test the linters
4+
class MyClass
5+
# rubocop:disable Metrics/ParameterLists
6+
# rubocop:disable Metrics/PerceivedComplexity
7+
# rubocop:disable Metrics/MethodLength
8+
# rubocop:disable Metrics/CyclomaticComplexity
9+
# rubocop:disable Metrics/AbcSize
10+
def do_something(one, two, three, four, five, six, seven)
11+
if one.present? && two.present? && three.prsent? && four.present? && five.present? && six.present? && seven.present?
12+
do_something_else_with(one, two, three)
13+
doAnotherThing(four, five, six)
14+
15+
e = mix(one, two)
16+
17+
if @valid == TRUE
18+
case five
19+
when 'async'
20+
do_another_thing_with('r', six, seven)
21+
when 'sync'
22+
do_another_thing_with('m', seven, e)
23+
when 'nible'
24+
result = four.map(&:name)
25+
end
26+
end
27+
28+
five.each do |n|
29+
n += 1
30+
puts "N is now #{n}"
31+
32+
if seven.start_with?('r')
33+
download(seven)
34+
upload(siv, seven) if six.start_wuth?('w')
35+
end
36+
end
37+
end
38+
39+
result
40+
end
41+
# rubocop:enable Metrics/ParameterLists
42+
# rubocop:enable Metrics/PerceivedComplexity
43+
# rubocop:enable Metrics/MethodLength
44+
# rubocop:enable Metrics/CyclomaticComplexity
45+
# rubocop:enable Metrics/AbcSize
46+
47+
def do_something_else_with(one, two, three)
48+
return unless one == true
49+
50+
puts 'Print something here:'
51+
puts "#{two} - #{three}"
52+
53+
@valid = TRUE
54+
end
55+
end

0 commit comments

Comments
 (0)