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

Rails rubocop omakase #1641

Merged
merged 4 commits into from
Jan 23, 2025
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
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
inherit_gem:
rubocop-rails-omakase: rubocop.yml

require:
- rubocop-rspec

Expand Down
141 changes: 71 additions & 70 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,78 +1,79 @@
source 'https://rubygems.org'
ruby '3.3.6'
source "https://rubygems.org"
ruby "3.3.6"

gem 'pg'
gem 'rails', '~> 7.2.x'
gem "pg"
gem "rails", "~> 7.2.x"

gem 'amazing_print'
gem 'apipie-rails'
gem 'aws-sdk-s3'
gem 'bootsnap', require: false
gem 'browser'
gem 'cancancan'
gem 'country_select'
gem 'dalli'
gem 'devise'
gem 'devise-encryptable'
gem 'dotenv'
gem 'exception_notification'
gem 'geocoder'
gem 'haml-rails'
gem 'has_scope'
gem 'inherited_resources'
gem 'kaminari'
gem 'kt-paperclip'
gem 'pagy'
gem 'paper_trail'
gem 'paper_trail-association_tracking'
gem 'phonelib'
gem 'puma'
gem 'rack'
gem 'rack-attack'
gem 'rails_admin'
gem 'rails_autolink'
gem 'rails_semantic_logger'
gem 'rake'
gem 'sanitize'
gem 'sassc-rails'
gem 'scout_apm'
gem 'simple_form'
gem 'simple_token_authentication'
gem 'solid_cache', '~> 1.0'
gem 'sprockets-rails'
gem 'strip_attributes'
gem 'tzinfo-data'
gem 'uglifier'
gem 'webrick'
gem "amazing_print"
gem "apipie-rails"
gem "aws-sdk-s3"
gem "bootsnap", require: false
gem "browser"
gem "cancancan"
gem "country_select"
gem "dalli"
gem "devise"
gem "devise-encryptable"
gem "dotenv"
gem "exception_notification"
gem "geocoder"
gem "haml-rails"
gem "has_scope"
gem "inherited_resources"
gem "kaminari"
gem "kt-paperclip"
gem "pagy"
gem "paper_trail"
gem "paper_trail-association_tracking"
gem "phonelib"
gem "puma"
gem "rack"
gem "rack-attack"
gem "rails_admin"
gem "rails_autolink"
gem "rails_semantic_logger"
gem "rake"
gem "sanitize"
gem "sassc-rails"
gem "scout_apm"
gem "simple_form"
gem "simple_token_authentication"
gem "solid_cache", "~> 1.0"
gem "sprockets-rails"
gem "strip_attributes"
gem "tzinfo-data"
gem "uglifier"
gem "webrick"

group :test do
gem 'capybara'
gem 'capybara-screenshot'
gem 'factory_bot_rails'
gem 'launchy'
gem 'rails-controller-testing'
gem 'rspec-rails'
gem 'rspec-retry'
gem 'rubocop'
gem 'rubocop-performance', require: false
gem 'rubocop-rspec'
gem 'selenium-webdriver'
gem 'simplecov'
gem 'simplecov-cobertura'
gem 'spork'
gem 'timecop'
gem "capybara"
gem "capybara-screenshot"
gem "factory_bot_rails"
gem "launchy"
gem "rails-controller-testing"
gem "rspec-rails"
gem "rspec-retry"
gem "rubocop"
gem "rubocop-performance", require: false
gem "rubocop-rspec"
gem "selenium-webdriver"
gem "simplecov"
gem "simplecov-cobertura"
gem "spork"
gem "timecop"
end

group :development, :test do
gem 'brakeman'
gem 'bullet'
gem 'bundler-audit'
gem 'database_cleaner'
gem 'debug', require: false
gem 'derailed_benchmarks'
gem 'email_spec'
gem 'listen'
gem 'ostruct' # suppress deprecation warning for pry
gem 'pry'
gem 'rails_real_favicon'
gem "brakeman"
gem "bullet"
gem "bundler-audit"
gem "database_cleaner"
gem "debug", require: false
gem "derailed_benchmarks"
gem "email_spec"
gem "listen"
gem "ostruct" # suppress deprecation warning for pry
gem "rubocop-rails-omakase", require: false
gem "pry"
gem "rails_real_favicon"
end
14 changes: 14 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -419,9 +419,22 @@ GEM
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.37.0)
parser (>= 3.3.1.0)
rubocop-minitest (0.36.0)
rubocop (>= 1.61, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-performance (1.21.1)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rails (2.28.0)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.52.0, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rails-omakase (1.0.0)
rubocop
rubocop-minitest
rubocop-performance
rubocop-rails
rubocop-rspec (3.0.5)
rubocop (~> 1.61)
ruby-progressbar (1.13.0)
Expand Down Expand Up @@ -566,6 +579,7 @@ DEPENDENCIES
rspec-retry
rubocop
rubocop-performance
rubocop-rails-omakase
rubocop-rspec
sanitize
sassc-rails
Expand Down
14 changes: 7 additions & 7 deletions app/controllers/api/v1/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ class EventsController < InheritedResources::Base
respond_to :json
has_scope :region

api :GET, '/api/v1/region/:region/events.json', 'Get all events for a single region'
param :region, String, desc: 'Name of the Region you want to see events for', required: true
param :sorted, String, desc: 'If value is present, sort/group by event category', required: false
formats ['json']
api :GET, "/api/v1/region/:region/events.json", "Get all events for a single region"
param :region, String, desc: "Name of the Region you want to see events for", required: true
param :sorted, String, desc: "If value is present, sort/group by event category", required: false
formats [ "json" ]
def index
events = apply_scopes(Event)
events.select!(&:active?)
Expand All @@ -30,18 +30,18 @@ def apply_regular_sort_and_respond(events)
x.start_date ? -1 : 1
end
end
return_response(events, 'events')
return_response(events, "events")
end

def apply_special_sort_and_respond(events)
sorted_events = {}

events.each do |e|
category = e.category.presence || 'General'
category = e.category.presence || "General"
(sorted_events[category] ||= []) << e
end

return_response([sorted_events], 'events')
return_response([ sorted_events ], "events")
end
end
end
Expand Down
Loading
Loading