Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rubocop linter and CI job #579

Merged
merged 2 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ on:
branches: [ main ]

jobs:
# lint:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v4
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

# - name: Set up Ruby
# uses: ruby/setup-ruby@v1
# with:
# ruby-version: .ruby-version
# bundler-cache: true
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: .ruby-version
bundler-cache: true

# - name: Lint code for consistent style
# run: bin/rubocop -f github
- name: Lint code for consistent style
run: bin/rubocop -f github

test:
runs-on: ubuntu-latest
Expand Down
45 changes: 45 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
require:
- rubocop-capybara
- rubocop-minitest
- rubocop-performance
- rubocop-rails
- standard

inherit_gem:
standard: config/base.yml

AllCops:
SuggestExtensions: false
TargetRubyVersion: 3.3
NewCops: enable

Minitest/MultipleAssertions:
Max: 10 # default 3

Style/FrozenStringLiteralComment:
Enabled: true

# These below cops are good practice going forward, but due to legacy we exclude some migrations
Rails/CreateTableWithTimestamps:
Exclude:
- db/migrate/20181101154531_create_cms.rb
- db/migrate/20220603215833_create_active_storage_variant_records.active_storage.rb

Rails/SkipsModelValidations:
Exclude:
- db/migrate/20220603215832_add_service_name_to_active_storage_blobs.active_storage.rb

Rails/BulkChangeTable:
Exclude:
- db/migrate/20181101154602_create_friendly_id_slugs.rb
- db/migrate/20181101154832_add_slug_to_profiles.rb

Rails/ThreeStateBooleanColumn:
Exclude:
- db/migrate/20181101154627_create_profiles.rb

# Below are cops that are currently disabled, where we should fix in the future
# TODO: Fix ProfilesController so we don't need to use global vars
Style/GlobalVars:
Exclude:
- app/controllers/profiles_controller.rb
54 changes: 32 additions & 22 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,59 +1,69 @@
source 'https://rubygems.org'
# frozen_string_literal: true

source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '3.1.4'
ruby "3.1.4"

gem 'rails', '~> 7.1.3'
gem "rails", "~> 7.1.3"

gem 'mysql2', '~> 0.5.6'
gem "mysql2", "~> 0.5.6"
# Use Puma as the app server
gem 'puma', '~> 6.4'
gem "puma", "~> 6.4"

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
gem "uglifier", ">= 1.3.0"

gem 'rollbar'
gem "rollbar"

# See https://github.com/rails/execjs#readme for more supported runtimes
gem 'execjs'
gem "execjs"

# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.12'
gem "jbuilder", "~> 2.12"

# Use ActiveStorage variant
gem 'image_processing', '~> 1.12', '>= 1.12.2'
gem "image_processing", "~> 1.12", ">= 1.12.2"

gem 'comfortable_mexican_sofa', github: 'restarone/comfortable-mexican-sofa', tag: '3.5'
gem "comfortable_mexican_sofa", github: "restarone/comfortable-mexican-sofa", tag: "3.5"

gem 'friendly_id'
gem "friendly_id"

gem 'htmlentities'
gem "htmlentities"
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.2', require: false
gem "bootsnap", ">= 1.4.2", require: false

gem 'webpacker', '~> 5.4'
gem "webpacker", "~> 5.4"

gem "rdoc", ">= 6.6.3.1"

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem "byebug", platforms: [:mri, :mingw, :x64_mingw]

# Linters
gem "rubocop", require: false
gem "rubocop-capybara", require: false
gem "rubocop-minitest", require: false
gem "rubocop-performance", require: false
gem "rubocop-rails", require: false
gem "standard", ">= 1.35.1", require: false
end

group :development do
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem "web-console", ">= 3.3.0"

gem 'listen', '>= 3.0.5', '< 3.10'
gem "listen", ">= 3.0.5", "< 3.10"
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring', '>= 3.0'
gem "spring", ">= 3.0"
end

group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '>= 2.15'
gem 'selenium-webdriver'
gem "capybara", ">= 2.15"
gem "selenium-webdriver"
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby]
76 changes: 72 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ GEM
tzinfo (~> 2.0)
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
ast (2.4.2)
base64 (0.2.0)
bigdecimal (3.1.8)
bindex (0.8.1)
Expand Down Expand Up @@ -154,8 +155,11 @@ GEM
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (2.7.2)
kramdown (2.4.0)
rexml
language_server-protocol (3.17.0.3)
lint_roller (1.1.0)
listen (3.9.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
Expand All @@ -174,7 +178,6 @@ GEM
rake
mini_magick (4.12.0)
mini_mime (1.1.5)
mini_portile2 (2.8.7)
minitest (5.23.1)
msgpack (1.7.2)
mutex_m (0.2.0)
Expand All @@ -189,9 +192,22 @@ GEM
net-smtp (0.5.0)
net-protocol
nio4r (2.7.3)
nokogiri (1.16.5)
mini_portile2 (~> 2.8.2)
nokogiri (1.16.5-aarch64-linux)
racc (~> 1.4)
nokogiri (1.16.5-arm-linux)
racc (~> 1.4)
nokogiri (1.16.5-arm64-darwin)
racc (~> 1.4)
nokogiri (1.16.5-x86-linux)
racc (~> 1.4)
nokogiri (1.16.5-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.16.5-x86_64-linux)
racc (~> 1.4)
parallel (1.24.0)
parser (3.3.1.0)
ast (~> 2.4.1)
racc
psych (5.1.2)
stringio
public_suffix (5.0.4)
Expand Down Expand Up @@ -240,6 +256,7 @@ GEM
rake (>= 12.2)
thor (~> 1.0, >= 1.2.2)
zeitwerk (~> 2.6)
rainbow (3.1.1)
rake (13.2.1)
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
Expand All @@ -252,6 +269,33 @@ GEM
rexml (3.2.8)
strscan (>= 3.0.9)
rollbar (3.5.2)
rubocop (1.63.5)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.31.3)
parser (>= 3.3.1.0)
rubocop-capybara (2.20.0)
rubocop (~> 1.41)
rubocop-minitest (0.35.0)
rubocop (>= 1.61, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-performance (1.21.0)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rails (2.25.0)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (1.13.0)
ruby-vips (2.1.4)
ffi (~> 1.12)
rubyzip (2.3.2)
Expand All @@ -277,6 +321,18 @@ GEM
actionpack (>= 5.2)
activesupport (>= 5.2)
sprockets (>= 3.0.0)
standard (1.36.0)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.63.0)
standard-custom (~> 1.0.0)
standard-performance (~> 1.4)
standard-custom (1.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.50)
standard-performance (1.4.0)
lint_roller (~> 1.1)
rubocop-performance (~> 1.21.0)
stringio (3.1.0)
strscan (3.1.0)
temple (0.10.3)
Expand All @@ -287,6 +343,7 @@ GEM
concurrent-ruby (~> 1.0)
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
unicode-display_width (2.5.0)
web-console (4.2.1)
actionview (>= 6.0.0)
activemodel (>= 6.0.0)
Expand All @@ -307,7 +364,12 @@ GEM
zeitwerk (2.6.15)

PLATFORMS
ruby
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wasn't working for me with Github Actions. Believe you don't use ruby anymore and instead break it down by individual platforms like so (this is what a newly generated Rails app will do it appears)

aarch64-linux
arm-linux
arm64-darwin
x86-linux
x86_64-darwin
x86_64-linux

DEPENDENCIES
bootsnap (>= 1.4.2)
Expand All @@ -325,8 +387,14 @@ DEPENDENCIES
rails (~> 7.1.3)
rdoc (>= 6.6.3.1)
rollbar
rubocop
rubocop-capybara
rubocop-minitest
rubocop-performance
rubocop-rails
selenium-webdriver
spring (>= 3.0)
standard (>= 1.35.1)
tzinfo-data
uglifier (>= 1.3.0)
web-console (>= 3.3.0)
Expand Down
4 changes: 3 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true

# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require_relative 'config/application'
require_relative "config/application"

Rails.application.load_tasks
2 changes: 2 additions & 0 deletions app/channels/application_cable/channel.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ApplicationCable
class Channel < ActionCable::Channel::Base
end
Expand Down
2 changes: 2 additions & 0 deletions app/channels/application_cable/connection.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ApplicationCable
class Connection < ActionCable::Connection::Base
end
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

class ApplicationController < ActionController::Base
end
2 changes: 2 additions & 0 deletions app/controllers/errors_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ErrorsController < ApplicationController
def file_not_found
end
Expand Down
Loading
Loading