Skip to content

Commit bb9dcad

Browse files
[ELITERT-1198] Add action to run Ruby linters
The action runs the Ruby linters (Rubocop and Reek) on Pull Requests. * A test file with a fest for the linters! 😋
1 parent 7f5b7ab commit bb9dcad

File tree

4 files changed

+102
-0
lines changed

4 files changed

+102
-0
lines changed

.github/workflows/ruby-linters.yml

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

.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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# frozen_string_literal: true
2+
3+
source 'https://rubygems.org'
4+
5+
gem 'panolint', '~> 0'

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+
# A class to test the linters
4+
class MyClass
5+
# rubocop:disable Metrics/AbcSize
6+
# rubocop:disable Metrics/CyclomaticComplexity
7+
# rubocop:disable Metrics/MethodLength
8+
# rubocop:disable Metrics/PerceivedComplexity
9+
# rubocop:disable Metrics/ParameterLists
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, e)
21+
when 'sync'
22+
do_another_thing_with('m', seven)
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+
next unless seven.start_with?('r')
33+
34+
download(seven)
35+
upload(siv, seven) if six.start_wuth?('w')
36+
end
37+
end
38+
39+
result
40+
end
41+
# rubocop:enable Metrics/AbcSize
42+
# rubocop:enable Metrics/CyclomaticComplexity
43+
# rubocop:enable Metrics/MethodLength
44+
# rubocop:enable Metrics/PerceivedComplexity
45+
# rubocop:enable Metrics/ParameterLists
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)