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 to Github CI #117

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions .github/workflows/ruby-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ jobs:
run: |
gem install selenium-webdriver

- name: Run rubocop
run: |
bundle exec rubocop

- name: Run Tests
env:
PGHOST: localhost
Expand Down
18 changes: 18 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require:
- rubocop-rails
Style/Documentation:
Enabled: false
Layout/LineLength:
Enabled: false
Metrics/BlockLength:
IgnoredMethods:
- test
- configure
Metrics/MethodLength:
Max: 40
Rails/BulkChangeTable:
Enabled: false
Rails/HasManyOrHasOneDependent:
Enabled: false
Rails/HasAndBelongsToMany:
Enabled: false
51 changes: 28 additions & 23 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,49 +1,51 @@
source "https://rubygems.org"
# frozen_string_literal: true

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

ruby "3.0.2"
ruby '3.0.2'
Copy link
Collaborator

Choose a reason for hiding this comment

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

I generally like to minimize the number of diffs when we're introducing rubocop to a repo at first. If we want to go with single quotes, we can create a PR afterwards that introduces that single rule change so that reviewing the diff is very simple.


# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 7.0.2.2"
gem 'rails', '~> 7.0.2.2'

# The traditional bundling and transpiling asset pipeline for Rails.
gem "sprockets-rails", ">= 2.0.0"
gem 'sprockets-rails', '>= 2.0.0'

# Use the Puma web server [https://github.com/puma/puma]
gem "puma", "~> 5.6.4"
gem 'puma', '~> 5.6.4'

# Bundle and transpile JavaScript [https://github.com/rails/jsbundling-rails]
gem "jsbundling-rails", "~> 1.0.3"
gem 'jsbundling-rails', '~> 1.0.3'

# Easy React view integration
gem "react-rails", "~> 2.6.1"
gem 'react-rails', '~> 2.6.1'

# Upgrade partials to allow for defining slots
gem "nice_partials"
gem 'nice_partials'

# Bundle and process CSS [https://github.com/rails/cssbundling-rails]
gem "cssbundling-rails", ">= 1.1.1"
gem 'cssbundling-rails', '>= 1.1.1'

# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails]
gem "importmap-rails", ">= 1.1.2"
gem 'importmap-rails', '>= 1.1.2'

# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
gem "turbo-rails", ">= 1.1.1"
gem 'turbo-rails', '>= 1.1.1'

# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
gem "stimulus-rails", ">= 1.0.4"
gem 'stimulus-rails', '>= 1.0.4'

# Build JSON APIs with ease [https://github.com/rails/jbuilder]
gem "jbuilder", "~> 2.11.5"
gem 'jbuilder', '~> 2.11.5'

# Use Redis adapter to run Action Cable in production
# gem "redis", "~> 4.0"

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]

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

# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
# gem "bcrypt", "~> 3.1.7"
Expand All @@ -53,12 +55,12 @@ gem "bootsnap", ">= 1.12.0", require: false

group :development, :test do
# Start debugger with binding.b [https://github.com/ruby/debug]
gem "debug", ">= 1.5.0", platforms: %i[ mri mingw x64_mingw ]
gem 'debug', '>= 1.5.0', platforms: %i[mri mingw x64_mingw]
end

group :development do
# Use console on exceptions pages [https://github.com/rails/web-console]
gem "web-console", ">= 4.2.0"
gem 'web-console', '>= 4.2.0'

# Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler]
# gem "rack-mini-profiler", ">= 2.3.3"
Expand All @@ -69,10 +71,10 @@ end

group :test do
# Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
gem "capybara", ">= 3.37.1"
gem "selenium-webdriver", ">= 4.1.0"
gem "webdrivers", "5.0.0"
gem 'capybara', '>= 3.37.1'
gem 'rexml', '~> 3.2.5'
gem 'selenium-webdriver', '>= 4.1.0'
gem 'webdrivers', '5.0.0'

# Provides extra assertions and matchers for testing controllers and views
gem 'rails-controller-testing'
Expand All @@ -83,7 +85,10 @@ group :test do
end

gem 'devise'
gem "passwordless", "~> 0.10.0"
gem "rolify"
gem 'passwordless', '~> 0.10.0'
gem 'rolify'

gem 'pg', '~> 1.4.1'

gem "pg", "~> 1.4.1"
gem 'rubocop'
gem 'rubocop-rails'
26 changes: 26 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ GEM
tzinfo (~> 2.0)
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
ast (2.4.2)
babel-source (5.8.35)
babel-transpiler (0.7.0)
babel-source (>= 4.0, < 6)
Expand Down Expand Up @@ -119,6 +120,7 @@ GEM
activesupport (>= 5.0.0)
jsbundling-rails (1.0.3)
railties (>= 6.0.0)
json (2.6.2)
loofah (2.18.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
Expand Down Expand Up @@ -156,6 +158,9 @@ GEM
nokogiri (1.13.6-x86_64-darwin)
racc (~> 1.4)
orm_adapter (0.5.0)
parallel (1.22.1)
parser (3.1.2.1)
ast (~> 2.4.1)
passwordless (0.10.0)
bcrypt (~> 3.1.11)
rails (>= 5.1.4)
Expand Down Expand Up @@ -197,6 +202,7 @@ GEM
rake (>= 12.2)
thor (~> 1.0)
zeitwerk (~> 2.5)
rainbow (3.1.1)
rake (13.0.6)
react-rails (2.6.2)
babel-transpiler (>= 0.7.0)
Expand All @@ -212,6 +218,23 @@ GEM
railties (>= 5.0)
rexml (3.2.5)
rolify (6.0.0)
rubocop (1.36.0)
json (~> 2.3)
parallel (~> 1.10)
parser (>= 3.1.2.1)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.20.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.21.0)
parser (>= 3.1.1.0)
rubocop-rails (2.16.1)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
ruby-progressbar (1.11.0)
rubyzip (2.3.2)
selenium-webdriver (4.3.0)
childprocess (>= 0.5, < 5.0)
Expand Down Expand Up @@ -243,6 +266,7 @@ GEM
railties (>= 6.0.0)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
unicode-display_width (2.3.0)
warden (1.2.9)
rack (>= 2.0.9)
web-console (4.2.0)
Expand Down Expand Up @@ -285,6 +309,8 @@ DEPENDENCIES
react-rails (~> 2.6.1)
rexml (~> 3.2.5)
rolify
rubocop
rubocop-rails
selenium-webdriver (>= 4.1.0)
shoulda
shoulda-matchers
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
52 changes: 27 additions & 25 deletions app/controllers/admin/passwords_controller.rb
Original file line number Diff line number Diff line change
@@ -1,34 +1,36 @@
# frozen_string_literal: true

class Admin::PasswordsController < Devise::PasswordsController
# GET /resource/password/new
# def new
# super
# end
module Admin
class PasswordsController < Devise::PasswordsController
# GET /resource/password/new
# def new
# super
# end

# POST /resource/password
# def create
# super
# end
# POST /resource/password
# def create
# super
# end

# GET /resource/password/edit?reset_password_token=abcdef
# def edit
# super
# end
# GET /resource/password/edit?reset_password_token=abcdef
# def edit
# super
# end

# PUT /resource/password
# def update
# super
# end
# PUT /resource/password
# def update
# super
# end

# protected
# protected

# def after_resetting_password_path_for(resource)
# super(resource)
# end
# def after_resetting_password_path_for(resource)
# super(resource)
# end

# The path used after sending reset password instructions
# def after_sending_reset_password_instructions_path_for(resource_name)
# super(resource_name)
# end
# The path used after sending reset password instructions
# def after_sending_reset_password_instructions_path_for(resource_name)
# super(resource_name)
# end
end
end
52 changes: 27 additions & 25 deletions app/controllers/admin/sessions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
# frozen_string_literal: true

class Admin::SessionsController < Devise::SessionsController
# before_action :configure_sign_in_params, only: [:create]
module Admin
class SessionsController < Devise::SessionsController
# before_action :configure_sign_in_params, only: [:create]

# GET /resource/sign_in
# def new
# super
# end
# GET /resource/sign_in
# def new
# super
# end

# POST /resource/sign_in
def create
super
@current_person ||= PresentablePerson.build(resource, view_context)
after_sign_in_path_for(resource)
end
# POST /resource/sign_in
def create
super
@current_person ||= PresentablePerson.build(resource, view_context)
after_sign_in_path_for(resource)
end

# DELETE /resource/sign_out
# def destroy
# super
# end
# DELETE /resource/sign_out
# def destroy
# super
# end

protected
protected

def after_sign_in_path_for(resource)
people_path
end
def after_sign_in_path_for(_resource)
people_path
end

# If you have extra params to permit, append them to the sanitizer.
# def configure_sign_in_params
# devise_parameter_sanitizer.permit(:sign_in, keys: [:attribute])
# end
end
# If you have extra params to permit, append them to the sanitizer.
# def configure_sign_in_params
# devise_parameter_sanitizer.permit(:sign_in, keys: [:attribute])
# end
end
end
Loading