diff --git a/.github/workflows/brakeman-audit.yaml b/.github/workflows/brakeman-audit.yaml new file mode 100644 index 0000000..96d07c4 --- /dev/null +++ b/.github/workflows/brakeman-audit.yaml @@ -0,0 +1,18 @@ +# .github/workflows/brakeman-audit.yaml +name: 'Brakeman Audit' +run-name: Brakeman Audit of ${{ github.ref_name }} by @${{ github.actor }} +on: + workflow_dispatch: + inputs: + debug_enabled: + type: boolean + description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)' + required: false + default: false + +jobs: + brakeman-audit: + uses: scientist-softserv/actions/.github/workflows/brakeman-audit.yaml@v0.0.14 + with: + webTarget: web + tag: latest \ No newline at end of file diff --git a/.github/workflows/build-test-lint.yaml b/.github/workflows/build-test-lint.yaml index 8513e0d..3c48fec 100644 --- a/.github/workflows/build-test-lint.yaml +++ b/.github/workflows/build-test-lint.yaml @@ -27,10 +27,10 @@ jobs: # needs: build # uses: scientist-softserv/actions/.github/workflows/test.yaml@v0.0.14 # with: - # webTarget: + # webTarget: web - # lint: - # needs: build - # uses: scientist-softserv/actions/.github/workflows/lint.yaml@v0.0.14 - # with: - # webTarget: \ No newline at end of file + lint: + needs: build + uses: scientist-softserv/actions/.github/workflows/lint.yaml@v0.0.14 + with: + webTarget: web \ No newline at end of file diff --git a/.github/workflows/bundler-audit.yaml b/.github/workflows/bundler-audit.yaml new file mode 100644 index 0000000..16e55d4 --- /dev/null +++ b/.github/workflows/bundler-audit.yaml @@ -0,0 +1,18 @@ +# .github/workflows/bundler-audit.yaml +name: 'Bundler Audit' +run-name: Bundler Audit of ${{ github.ref_name }} by @${{ github.actor }} +on: + workflow_dispatch: + inputs: + debug_enabled: + type: boolean + description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)' + required: false + default: false + +jobs: + bundler-audit: + uses: scientist-softserv/actions/.github/workflows/bundler-audit.yaml@v0.0.14 + with: + webTarget: web + tag: latest diff --git a/.gitignore b/.gitignore index 0cbf4c2..5885f3e 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,4 @@ # Ignore node_modules /node_modules *.~undo-tree~ +*-deploy.yaml \ No newline at end of file diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..cc32da4 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1 @@ +inherit_from: .rubocop_todo.yml diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 0000000..1a8f4ec --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,59 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2023-10-24 21:54:37 UTC using RuboCop version 1.57.1. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# Offense count: 2 +# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. +# AllowedMethods: refine +Metrics/BlockLength: + Max: 41 + +# Offense count: 1 +# Configuration parameters: AllowedMethods, AllowedPatterns. +Metrics/CyclomaticComplexity: + Max: 9 + +# Offense count: 4 +# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. +Metrics/MethodLength: + Max: 62 + +# Offense count: 1 +# Configuration parameters: AllowedMethods, AllowedPatterns. +Metrics/PerceivedComplexity: + Max: 9 + +# Offense count: 11 +# Configuration parameters: AllowedConstants. +Style/Documentation: + Exclude: + - 'spec/**/*' + - 'test/**/*' + - 'app/api/api.rb' + - 'app/controllers/application_controller.rb' + - 'app/controllers/groups_controller.rb' + - 'app/controllers/members_controller.rb' + - 'app/mailers/application_mailer.rb' + - 'app/models/application_record.rb' + - 'app/models/group.rb' + - 'app/models/member.rb' + - 'config/application.rb' + - 'db/migrate/20230623173103_create_groups.rb' + - 'db/migrate/20230623180851_create_members.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Style/IfUnlessModifier: + Exclude: + - 'bin/bundle' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. +# URISchemes: http, https +Layout/LineLength: + Max: 198 diff --git a/Gemfile b/Gemfile index 4269f1a..146754c 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } @@ -6,9 +8,10 @@ ruby '3.1.3' # Load env variables gem 'dotenv-rails', '~> 2.7', require: 'dotenv/rails-now' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem 'rails', '~> 7.0.4' +gem 'rails', '~> 7.0.7', '>= 7.0.7.1' + # Use Puma as the app server -gem 'puma', '~> 6.0.1' +gem 'puma', '~> 6.3', '>= 6.3.1' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder # gem 'jbuilder', '~> 2.7' # Use Redis adapter to run Action Cable in production @@ -26,11 +29,11 @@ gem 'activerecord', '~> 7.0.4', require: 'active_record' gem 'otr-activerecord' gem 'pg' -gem 'slack-ruby-bot-server-events' gem 'pagy_cursor' +gem 'slack-ruby-bot-server-events' 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: %i[mri mingw x64_mingw] end group :development do @@ -42,3 +45,11 @@ end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem # gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] + +# globalid: Upgrade Version: 1.0.1, Vulnerabilities: ReDoS based DoS vulnerability in GlobalID +gem 'globalid', '>= 1.0.1' + +# nokogiri: Upgrade Version: 1.14.3, Vulnerabilities: Multiple CVEs addressed by updating packaged libxml2 to v2.10.4 +gem 'nokogiri', '>= 1.14.3' + +gem 'rubocop', require: false diff --git a/Gemfile.lock b/Gemfile.lock index 4ff396b..ed993f2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,82 +1,84 @@ GEM remote: https://rubygems.org/ specs: - actioncable (7.0.4) - actionpack (= 7.0.4) - activesupport (= 7.0.4) + actioncable (7.0.8) + actionpack (= 7.0.8) + activesupport (= 7.0.8) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.4) - actionpack (= 7.0.4) - activejob (= 7.0.4) - activerecord (= 7.0.4) - activestorage (= 7.0.4) - activesupport (= 7.0.4) + actionmailbox (7.0.8) + actionpack (= 7.0.8) + activejob (= 7.0.8) + activerecord (= 7.0.8) + activestorage (= 7.0.8) + activesupport (= 7.0.8) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.4) - actionpack (= 7.0.4) - actionview (= 7.0.4) - activejob (= 7.0.4) - activesupport (= 7.0.4) + actionmailer (7.0.8) + actionpack (= 7.0.8) + actionview (= 7.0.8) + activejob (= 7.0.8) + activesupport (= 7.0.8) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp rails-dom-testing (~> 2.0) - actionpack (7.0.4) - actionview (= 7.0.4) - activesupport (= 7.0.4) - rack (~> 2.0, >= 2.2.0) + actionpack (7.0.8) + actionview (= 7.0.8) + activesupport (= 7.0.8) + rack (~> 2.0, >= 2.2.4) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.4) - actionpack (= 7.0.4) - activerecord (= 7.0.4) - activestorage (= 7.0.4) - activesupport (= 7.0.4) + actiontext (7.0.8) + actionpack (= 7.0.8) + activerecord (= 7.0.8) + activestorage (= 7.0.8) + activesupport (= 7.0.8) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.4) - activesupport (= 7.0.4) + actionview (7.0.8) + activesupport (= 7.0.8) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (7.0.4) - activesupport (= 7.0.4) + activejob (7.0.8) + activesupport (= 7.0.8) globalid (>= 0.3.6) - activemodel (7.0.4) - activesupport (= 7.0.4) - activerecord (7.0.4) - activemodel (= 7.0.4) - activesupport (= 7.0.4) - activestorage (7.0.4) - actionpack (= 7.0.4) - activejob (= 7.0.4) - activerecord (= 7.0.4) - activesupport (= 7.0.4) + activemodel (7.0.8) + activesupport (= 7.0.8) + activerecord (7.0.8) + activemodel (= 7.0.8) + activesupport (= 7.0.8) + activestorage (7.0.8) + actionpack (= 7.0.8) + activejob (= 7.0.8) + activerecord (= 7.0.8) + activesupport (= 7.0.8) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (7.0.4) + activesupport (7.0.8) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) - async (2.6.2) + ast (2.4.2) + async (2.6.4) console (~> 1.10) fiber-annotation io-event (~> 1.1) timers (~> 4.1) - bootsnap (1.15.0) + base64 (0.1.1) + bootsnap (1.16.0) msgpack (~> 1.2) builder (3.2.4) byebug (11.1.3) concurrent-ruby (1.2.2) - console (1.17.2) + console (1.23.2) fiber-annotation fiber-local crass (1.0.6) @@ -86,7 +88,7 @@ GEM dotenv-rails (2.8.1) dotenv (= 2.8.1) railties (>= 3.2) - dry-core (1.0.0) + dry-core (1.0.1) concurrent-ruby (~> 1.0) zeitwerk (~> 2.6) dry-inflector (1.0.0) @@ -101,7 +103,8 @@ GEM dry-logic (~> 1.4) zeitwerk (~> 2.6) erubi (1.12.0) - faraday (2.7.7) + faraday (2.7.11) + base64 faraday-net_http (>= 2.0, < 3.1) ruby2_keywords (>= 0.0.4) faraday-mashify (0.1.1) @@ -110,19 +113,19 @@ GEM faraday-multipart (1.0.4) multipart-post (~> 2) faraday-net_http (3.0.2) - ffi (1.15.5) + ffi (1.16.3) fiber-annotation (0.2.0) fiber-local (1.0.0) foreman (0.87.2) - gli (2.21.0) - globalid (1.0.0) - activesupport (>= 5.0) - grape (1.7.1) - activesupport + gli (2.21.1) + globalid (1.2.1) + activesupport (>= 6.1) + grape (1.8.0) + activesupport (>= 5) builder dry-types (>= 1.1) mustermann-grape (~> 1.0.0) - rack (>= 1.3.0, < 3) + rack (>= 1.3.0) rack-accept grape-roar (0.4.1) grape @@ -135,59 +138,65 @@ GEM hashie (>= 3.0) i18n (1.14.1) concurrent-ruby (~> 1.0) - io-event (1.2.2) + io-event (1.3.3) + json (2.6.3) kaminari-core (1.2.2) kaminari-grape (1.0.1) grape kaminari-core (~> 1.0) - listen (3.7.1) + language_server-protocol (3.17.0.3) + listen (3.8.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - loofah (2.19.1) + loofah (2.21.4) crass (~> 1.0.2) - nokogiri (>= 1.5.9) - mail (2.8.0) + nokogiri (>= 1.12.0) + mail (2.8.1) mini_mime (>= 0.1.1) net-imap net-pop net-smtp marcel (1.0.2) method_source (1.0.0) - mini_mime (1.1.2) - mini_portile2 (2.8.0) - minitest (5.18.1) - msgpack (1.6.0) + mini_mime (1.1.5) + mini_portile2 (2.8.5) + minitest (5.20.0) + msgpack (1.7.2) multi_json (1.15.0) multipart-post (2.3.0) mustermann (3.0.0) ruby2_keywords (~> 0.0.1) mustermann-grape (1.0.2) mustermann (>= 1.0.0) - net-imap (0.3.4) + net-imap (0.4.2) date net-protocol net-pop (0.1.2) net-protocol net-protocol (0.2.1) timeout - net-smtp (0.3.3) + net-smtp (0.4.0) net-protocol - nio4r (2.5.8) - nokogiri (1.13.10) - mini_portile2 (~> 2.8.0) + nio4r (2.5.9) + nokogiri (1.15.4) + mini_portile2 (~> 2.8.2) racc (~> 1.4) - otr-activerecord (2.1.1) - activerecord (>= 4.0, < 7.1) + otr-activerecord (2.2.0) + activerecord (>= 4.0, < 7.2) hashie-forbidden_attributes (~> 0.1) - pagy (6.0.4) - pagy_cursor (0.6.0) + pagy (6.1.0) + pagy_cursor (0.6.1) activerecord (>= 5) pagy (>= 6, < 7) - pg (1.4.5) - puma (6.0.1) + parallel (1.23.0) + parser (3.2.2.4) + ast (~> 2.4.1) + racc + pg (1.5.4) + puma (6.4.0) nio4r (~> 2.0) - racc (1.6.2) - rack (2.2.7) + racc (1.7.1) + rack (2.2.8) rack-accept (0.4.5) rack (>= 0.4) rack-cors (2.0.1) @@ -195,46 +204,66 @@ GEM rack-rewrite (1.5.1) rack-server-pages (0.1.0) rack - rack-test (2.0.2) + rack-test (2.1.0) rack (>= 1.3) - rails (7.0.4) - actioncable (= 7.0.4) - actionmailbox (= 7.0.4) - actionmailer (= 7.0.4) - actionpack (= 7.0.4) - actiontext (= 7.0.4) - actionview (= 7.0.4) - activejob (= 7.0.4) - activemodel (= 7.0.4) - activerecord (= 7.0.4) - activestorage (= 7.0.4) - activesupport (= 7.0.4) + rails (7.0.8) + actioncable (= 7.0.8) + actionmailbox (= 7.0.8) + actionmailer (= 7.0.8) + actionpack (= 7.0.8) + actiontext (= 7.0.8) + actionview (= 7.0.8) + activejob (= 7.0.8) + activemodel (= 7.0.8) + activerecord (= 7.0.8) + activestorage (= 7.0.8) + activesupport (= 7.0.8) bundler (>= 1.15.0) - railties (= 7.0.4) - rails-dom-testing (2.0.3) - activesupport (>= 4.2.0) + railties (= 7.0.8) + rails-dom-testing (2.2.0) + activesupport (>= 5.0.0) + minitest nokogiri (>= 1.6) - rails-html-sanitizer (1.4.4) - loofah (~> 2.19, >= 2.19.1) - railties (7.0.4) - actionpack (= 7.0.4) - activesupport (= 7.0.4) + rails-html-sanitizer (1.6.0) + loofah (~> 2.21) + nokogiri (~> 1.14) + railties (7.0.8) + actionpack (= 7.0.8) + activesupport (= 7.0.8) method_source rake (>= 12.2) thor (~> 1.0) zeitwerk (~> 2.5) + rainbow (3.1.1) rake (13.0.6) rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) + regexp_parser (2.8.2) representable (3.2.0) declarative (< 0.1.0) trailblazer-option (>= 0.1.1, < 0.2.0) uber (< 0.2.0) + rexml (3.2.6) roar (1.1.1) representable (~> 3.0) + rubocop (1.57.1) + base64 (~> 0.1.1) + json (~> 2.3) + language_server-protocol (>= 3.17.0) + parallel (~> 1.10) + parser (>= 3.2.2.4) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.28.1, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.29.0) + parser (>= 3.2.1.0) + ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) - slack-ruby-bot-server (2.1.0) + slack-ruby-bot-server (2.1.1) async foreman grape @@ -247,7 +276,7 @@ GEM slack-ruby-client slack-ruby-bot-server-events (0.3.2) slack-ruby-bot-server (>= 0.12.0) - slack-ruby-client (2.1.0) + slack-ruby-client (2.2.0) faraday (>= 2.0) faraday-mashify faraday-multipart @@ -257,17 +286,18 @@ GEM spring-watcher-listen (2.0.1) listen (>= 2.7, < 4.0) spring (>= 1.2, < 3.0) - thor (1.2.1) - timeout (0.3.1) + thor (1.3.0) + timeout (0.4.0) timers (4.3.5) trailblazer-option (0.1.2) tzinfo (2.0.6) concurrent-ruby (~> 1.0) uber (0.1.0) - websocket-driver (0.7.5) + unicode-display_width (2.5.0) + websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) - zeitwerk (2.6.8) + zeitwerk (2.6.12) PLATFORMS ruby @@ -277,12 +307,15 @@ DEPENDENCIES bootsnap (>= 1.15.0) byebug dotenv-rails (~> 2.7) + globalid (>= 1.0.1) listen (~> 3.2) + nokogiri (>= 1.14.3) otr-activerecord pagy_cursor pg - puma (~> 6.0.1) - rails (~> 7.0.4) + puma (~> 6.3, >= 6.3.1) + rails (~> 7.0.7, >= 7.0.7.1) + rubocop slack-ruby-bot-server-events spring spring-watcher-listen (~> 2.0.0) diff --git a/Rakefile b/Rakefile index e85f913..488c551 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,5 @@ +# 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. diff --git a/app/api/api.rb b/app/api/api.rb index 6fd82f0..fee5f9c 100644 --- a/app/api/api.rb +++ b/app/api/api.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Api < Grape::API prefix 'api' format :json @@ -7,7 +9,7 @@ class Api < Grape::API http_basic do |username, password| username == ENV.fetch('ADMIN_USER', 'scientist') && password == ENV.fetch('ADMIN_PASSWORD', 'softserv') end - resource :groups do + resource :groups do get do Group.all end @@ -30,25 +32,23 @@ class Api < Grape::API team = Team.find_by!(team_id: params[:team_id]) slack_client = Slack::Web::Client.new(token: team.token) slack_client.conversations_invite(channel: params[:channel_id], users: params[:user_id]) - rescue => e - if e.message == "already_in_channel" - return { status: 200, ok: true} - end + rescue StandardError => e + return { status: 200, ok: true } if e.message == 'already_in_channel' + { status: 500, error: e.message } else - { status: 200, ok: true} + { status: 200, ok: true } end post :leave do team = Team.find_by!(team_id: params[:team_id]) slack_client = Slack::Web::Client.new(token: team.token) slack_client.conversations_kick(channel: params[:channel_id], user: params[:user_id]) - rescue => e - if e.message == "already_in_channel" - return { status: 200, ok: true} - end + rescue StandardError => e + return { status: 200, ok: true } if e.message == 'already_in_channel' + { status: 500, error: e.message } else - { status: 200, ok: true} + { status: 200, ok: true } end end end diff --git a/app/channels/application_cable/channel.rb b/app/channels/application_cable/channel.rb index d672697..9aec230 100644 --- a/app/channels/application_cable/channel.rb +++ b/app/channels/application_cable/channel.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module ApplicationCable class Channel < ActionCable::Channel::Base end diff --git a/app/channels/application_cable/connection.rb b/app/channels/application_cable/connection.rb index 0ff5442..8d6c2a1 100644 --- a/app/channels/application_cable/connection.rb +++ b/app/channels/application_cable/connection.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module ApplicationCable class Connection < ActionCable::Connection::Base end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 36f56d1..0c04b0b 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,4 +1,6 @@ +# frozen_string_literal: true + class ApplicationController < ActionController::API include ActionController::HttpAuthentication::Basic::ControllerMethods - http_basic_authenticate_with name: "scientist", password: ENV.fetch("HTTP_BASIC_PASSWORD", 'softserv') + http_basic_authenticate_with name: 'scientist', password: ENV.fetch('HTTP_BASIC_PASSWORD', 'softserv') end diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index ea7ec9e..4926ba8 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true + class GroupsController < ApplicationController - before_action :set_group, only: %i[ show update destroy ] + before_action :set_group, only: %i[show update destroy] # GET /groups def index @@ -39,13 +41,14 @@ def destroy end private - # Use callbacks to share common setup or constraints between actions. - def set_group - @group = Group.find(params[:id]) - end - # Only allow a list of trusted parameters through. - def group_params - params.require(:group).permit(:name, :description) - end + # Use callbacks to share common setup or constraints between actions. + def set_group + @group = Group.find(params[:id]) + end + + # Only allow a list of trusted parameters through. + def group_params + params.require(:group).permit(:name, :description) + end end diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 1198055..7db651f 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true + class MembersController < ApplicationController - before_action :set_member, only: %i[ show update destroy ] + before_action :set_member, only: %i[show update destroy] # GET /members def index @@ -39,13 +41,14 @@ def destroy end private - # Use callbacks to share common setup or constraints between actions. - def set_member - @member = Member.find(params[:id]) - end - # Only allow a list of trusted parameters through. - def member_params - params.require(:member).permit(:name, :handle, :member_id, :group_id) - end + # Use callbacks to share common setup or constraints between actions. + def set_member + @member = Member.find(params[:id]) + end + + # Only allow a list of trusted parameters through. + def member_params + params.require(:member).permit(:name, :handle, :member_id, :group_id) + end end diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb index d394c3d..bef3959 100644 --- a/app/jobs/application_job.rb +++ b/app/jobs/application_job.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ApplicationJob < ActiveJob::Base # Automatically retry jobs that encountered a deadlock # retry_on ActiveRecord::Deadlocked diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 286b223..d84cb6e 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ApplicationMailer < ActionMailer::Base default from: 'from@example.com' layout 'mailer' diff --git a/app/models/application_record.rb b/app/models/application_record.rb index 10a4cba..71fbba5 100644 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ApplicationRecord < ActiveRecord::Base self.abstract_class = true end diff --git a/app/models/group.rb b/app/models/group.rb index f0a33c2..2ae04d0 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Group < ApplicationRecord has_many :members end diff --git a/app/models/member.rb b/app/models/member.rb index 3b5fd28..c2d7aec 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Member < ApplicationRecord belongs_to :group end diff --git a/bin/bundle b/bin/bundle index a71368e..73ec947 100755 --- a/bin/bundle +++ b/bin/bundle @@ -8,46 +8,46 @@ # this file is here to facilitate running it. # -require "rubygems" +require 'rubygems' m = Module.new do module_function def invoked_as_script? - File.expand_path($0) == File.expand_path(__FILE__) + File.expand_path($PROGRAM_NAME) == File.expand_path(__FILE__) end def env_var_version - ENV["BUNDLER_VERSION"] + ENV['BUNDLER_VERSION'] end def cli_arg_version return unless invoked_as_script? # don't want to hijack other binstubs - return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update` + return unless 'update'.start_with?(ARGV.first || ' ') # must be running `bundle update` + bundler_version = nil update_index = nil ARGV.each_with_index do |a, i| - if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN - bundler_version = a - end + bundler_version = a if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/ - bundler_version = $1 + + bundler_version = Regexp.last_match(1) update_index = i end bundler_version end def gemfile - gemfile = ENV["BUNDLE_GEMFILE"] + gemfile = ENV['BUNDLE_GEMFILE'] return gemfile if gemfile && !gemfile.empty? - File.expand_path("../../Gemfile", __FILE__) + File.expand_path('../Gemfile', __dir__) end def lockfile lockfile = case File.basename(gemfile) - when "gems.rb" then gemfile.sub(/\.rb$/, gemfile) + when 'gems.rb' then gemfile.sub(/\.rb$/, gemfile) else "#{gemfile}.lock" end File.expand_path(lockfile) @@ -55,15 +55,17 @@ m = Module.new do def lockfile_version return unless File.file?(lockfile) + lockfile_contents = File.read(lockfile) return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/ + Regexp.last_match(1) end def bundler_version @bundler_version ||= env_var_version || cli_arg_version || - lockfile_version + lockfile_version end def bundler_requirement @@ -73,28 +75,32 @@ m = Module.new do requirement = bundler_gem_version.approximate_recommendation - return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.7.0") + return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new('2.7.0') - requirement += ".a" if bundler_gem_version.prerelease? + requirement += '.a' if bundler_gem_version.prerelease? requirement end def load_bundler! - ENV["BUNDLE_GEMFILE"] ||= gemfile + ENV['BUNDLE_GEMFILE'] ||= gemfile activate_bundler end def activate_bundler gem_error = activation_error_handling do - gem "bundler", bundler_requirement + gem 'bundler', bundler_requirement end return if gem_error.nil? + require_error = activation_error_handling do - require "bundler/version" + require 'bundler/version' + end + if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION)) + return end - return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION)) + warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`" exit 42 end @@ -109,6 +115,4 @@ end m.load_bundler! -if m.invoked_as_script? - load Gem.bin_path("bundler", "bundle") -end +load Gem.bin_path('bundler', 'bundle') if m.invoked_as_script? diff --git a/bin/rails b/bin/rails index efc0377..a31728a 100755 --- a/bin/rails +++ b/bin/rails @@ -1,4 +1,6 @@ #!/usr/bin/env ruby -APP_PATH = File.expand_path("../config/application", __dir__) -require_relative "../config/boot" -require "rails/commands" +# frozen_string_literal: true + +APP_PATH = File.expand_path('../config/application', __dir__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/bin/rake b/bin/rake index 4fbf10b..c199955 100755 --- a/bin/rake +++ b/bin/rake @@ -1,4 +1,6 @@ #!/usr/bin/env ruby -require_relative "../config/boot" -require "rake" +# frozen_string_literal: true + +require_relative '../config/boot' +require 'rake' Rake.application.run diff --git a/bin/setup b/bin/setup index cb2baa8..bc36007 100755 --- a/bin/setup +++ b/bin/setup @@ -1,8 +1,10 @@ #!/usr/bin/env ruby -require "fileutils" +# frozen_string_literal: true + +require 'fileutils' # path to your application root. -APP_ROOT = File.expand_path("..", __dir__) +APP_ROOT = File.expand_path('..', __dir__) def system!(*args) system(*args) || abort("\n== Command #{args} failed ==") @@ -13,16 +15,16 @@ FileUtils.chdir APP_ROOT do # This script is idempotent, so that you can run it at any time and get an expectable outcome. # Add necessary setup steps to this file. - puts "== Installing dependencies ==" - system! "gem install bundler --conservative" - system("bundle check") || system!("bundle install") + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') puts "\n== Preparing database ==" system! 'bin/rails db:prepare' puts "\n== Removing old logs and tempfiles ==" - system! "bin/rails log:clear tmp:clear" + system! 'bin/rails log:clear tmp:clear' puts "\n== Restarting application server ==" - system! "bin/rails restart" + system! 'bin/rails restart' end diff --git a/bin/spring b/bin/spring index d89ee49..1c6eabf 100755 --- a/bin/spring +++ b/bin/spring @@ -1,4 +1,5 @@ #!/usr/bin/env ruby +# frozen_string_literal: true # This file loads Spring without using Bundler, in order to be fast. # It gets overwritten when you run the `spring binstub` command. diff --git a/bot/actions.rb b/bot/actions.rb index 261ae50..aff2117 100644 --- a/bot/actions.rb +++ b/bot/actions.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative 'actions/default' require_relative 'actions/quiz' require_relative 'actions/modal' diff --git a/bot/actions/default.rb b/bot/actions/default.rb index 4dfb3c5..5bd01c9 100644 --- a/bot/actions/default.rb +++ b/bot/actions/default.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + SlackRubyBotServer::Events.configure do |config| config.on :action do |action| action.logger.info "Received #{action[:payload][:type]}." diff --git a/bot/actions/modal.rb b/bot/actions/modal.rb index dc55905..6f3c539 100644 --- a/bot/actions/modal.rb +++ b/bot/actions/modal.rb @@ -1,13 +1,15 @@ +# frozen_string_literal: true + SlackRubyBotServer::Events.configure do |config| config.on :action, 'view_submission' do |action| payload = action[:payload] - team_id = payload["team"]["id"] - username = payload["user"]["username"] - trigger_id = payload["trigger_id"] + team_id = payload['team']['id'] + username = payload['user']['username'] + payload['trigger_id'] action.logger.info "User #{username} has submitted a demo modal form" - team = Team.find_by(team_id: team_id) - slack_client = Slack::Web::Client.new(token: team.token) - form_values = payload["view"]["state"]["values"] + team = Team.find_by(team_id:) + Slack::Web::Client.new(token: team.token) + form_values = payload['view']['state']['values'] p form_values nil end diff --git a/bot/actions/quiz.rb b/bot/actions/quiz.rb index 3ad25b9..a4a9878 100644 --- a/bot/actions/quiz.rb +++ b/bot/actions/quiz.rb @@ -1,16 +1,18 @@ +# frozen_string_literal: true + SlackRubyBotServer::Events.configure do |config| config.on :action, 'block_actions' do |action| payload = action[:payload] - action_id = payload["actions"][0]["action_id"] - channel_id = payload["channel"]["id"] - team_id = payload["team"]["id"] + action_id = payload['actions'][0]['action_id'] + channel_id = payload['channel']['id'] + team_id = payload['team']['id'] action.logger.info "Action #{action_id} has been processed in channel #{channel_id}" - team = Team.find_by(team_id: team_id) + team = Team.find_by(team_id:) slack_client = Slack::Web::Client.new(token: team.token) if action_id == 'reply_yes' - slack_client.chat_postMessage(channel: channel_id, text: "Great! I also think so! :thumbsup:") + slack_client.chat_postMessage(channel: channel_id, text: 'Great! I also think so! :thumbsup:') elsif action_id == 'reply_no' - slack_client.chat_postMessage(channel: channel_id, text: "Oops! Try to google it... :thumbsdown:") + slack_client.chat_postMessage(channel: channel_id, text: 'Oops! Try to google it... :thumbsdown:') end # Do not send text message any more nil diff --git a/bot/events.rb b/bot/events.rb index 7c912e7..604f5c1 100644 --- a/bot/events.rb +++ b/bot/events.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative 'events/default' require_relative 'events/member_joined_channel' require_relative 'events/mentions' diff --git a/bot/events/default.rb b/bot/events/default.rb index 5a7ae88..bc2bb96 100644 --- a/bot/events/default.rb +++ b/bot/events/default.rb @@ -1,8 +1,9 @@ +# frozen_string_literal: true SlackRubyBotServer::Events.configure do |config| config.on :event do |event| event.logger.info "Received #{event[:type]}, #{event[:event][:type]}." - event.logger.debug "#{event.inspect}" + event.logger.debug event.inspect.to_s { ok: true } end end diff --git a/bot/events/member_joined_channel.rb b/bot/events/member_joined_channel.rb index a29afdb..ea1a963 100644 --- a/bot/events/member_joined_channel.rb +++ b/bot/events/member_joined_channel.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + SlackRubyBotServer::Events.configure do |config| config.on :event, ['event_callback', 'member_joined_channel'] do |event| team = Team.find_by(team_id: event[:event][:team]) || raise("Cannot find team with ID #{event[:event][:team]}.") diff --git a/bot/events/mentions.rb b/bot/events/mentions.rb index 89b2e5b..7da0d9a 100644 --- a/bot/events/mentions.rb +++ b/bot/events/mentions.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + SlackRubyBotServer::Events.configure do |config| config.on :event, ['event_callback', 'app_mention'] do |event| team = Team.find_by(team_id: event[:event][:team]) || raise("Cannot find team with ID #{event[:event][:team]}.") @@ -12,7 +14,8 @@ group = Group.find_by(name: group_name) if group_name if group message = group.members.map { |m| "<@#{m.member_id || m.handle}>" }.join(', ') - slack_client.chat_postMessage(channel: event[:event][:channel], text: "^ #{message}", thread_ts: event[:event][:ts]) + slack_client.chat_postMessage(channel: event[:event][:channel], text: "^ #{message}", + thread_ts: event[:event][:ts]) end { ok: true } end diff --git a/bot/slash_commands.rb b/bot/slash_commands.rb index 222ed28..8061db3 100644 --- a/bot/slash_commands.rb +++ b/bot/slash_commands.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative 'slash_commands/default' require_relative 'slash_commands/ping' require_relative 'slash_commands/quiz' diff --git a/bot/slash_commands/default.rb b/bot/slash_commands/default.rb index a99ca2b..7f39c23 100644 --- a/bot/slash_commands/default.rb +++ b/bot/slash_commands/default.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + SlackRubyBotServer::Events.configure do |config| config.on :command do |command| command.logger.info "Received #{command[:command]}." diff --git a/bot/slash_commands/modal.rb b/bot/slash_commands/modal.rb index 0f11b4f..9c03330 100644 --- a/bot/slash_commands/modal.rb +++ b/bot/slash_commands/modal.rb @@ -1,61 +1,63 @@ +# frozen_string_literal: true + def modal_payload(trigger_id) { - trigger_id: trigger_id, + trigger_id:, view: { - type: "modal", + type: 'modal', title: { - type: "plain_text", - text: "Demo Modal Form", + type: 'plain_text', + text: 'Demo Modal Form', emoji: true }, submit: { - type: "plain_text", - text: "Submit", + type: 'plain_text', + text: 'Submit', emoji: true }, close: { - type: "plain_text", - text: "Cancel", + type: 'plain_text', + text: 'Cancel', emoji: true }, blocks: [ { - type: "input", + type: 'input', element: { - type: "plain_text_input", - action_id: "sl_input", + type: 'plain_text_input', + action_id: 'sl_input', placeholder: { - type: "plain_text", - text: "Placeholder text for single-line input" + type: 'plain_text', + text: 'Placeholder text for single-line input' } }, label: { - type: "plain_text", - text: "Subject" + type: 'plain_text', + text: 'Subject' }, hint: { - type: "plain_text", - text: "Short description or subject line" + type: 'plain_text', + text: 'Short description or subject line' } }, { - type: "input", + type: 'input', element: { - type: "plain_text_input", - action_id: "ml_input", + type: 'plain_text_input', + action_id: 'ml_input', multiline: true, placeholder: { - type: "plain_text", - text: "Placeholder text for multi-line input" + type: 'plain_text', + text: 'Placeholder text for multi-line input' } }, label: { - type: "plain_text", - text: "Details" + type: 'plain_text', + text: 'Details' }, hint: { - type: "plain_text", - text: "Long description" + type: 'plain_text', + text: 'Long description' } } ] @@ -69,9 +71,9 @@ def modal_payload(trigger_id) team_id = command[:team_id] trigger_id = command[:trigger_id] command.logger.info "Opening a modal with trigger_id: #{trigger_id}." - team = Team.find_by(team_id: team_id) + team = Team.find_by(team_id:) slack_client = Slack::Web::Client.new(token: team.token) - slack_client.views_open(modal_payload trigger_id) + slack_client.views_open(modal_payload(trigger_id)) nil end end diff --git a/bot/slash_commands/ping.rb b/bot/slash_commands/ping.rb index 368c117..ce3d1ea 100644 --- a/bot/slash_commands/ping.rb +++ b/bot/slash_commands/ping.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + SlackRubyBotServer::Events.configure do |config| config.on :command, '/ping' do |command| command.logger.info 'Received a ping, responding with pong.' diff --git a/bot/slash_commands/quiz.rb b/bot/slash_commands/quiz.rb index 6cbbc46..285c269 100644 --- a/bot/slash_commands/quiz.rb +++ b/bot/slash_commands/quiz.rb @@ -1,37 +1,39 @@ +# frozen_string_literal: true + def quiz_message(question, channel_id) { channel: channel_id, "blocks": [ { - "type": "section", + "type": 'section', "text": { - "type": "plain_text", + "type": 'plain_text', "text": question, "emoji": true } }, { - "type": "actions", + "type": 'actions', "elements": [ { - "type": "button", + "type": 'button', "text": { - "type": "plain_text", - "text": "Yes", + "type": 'plain_text', + "text": 'Yes', "emoji": true }, - "value": "reply_yes", - "action_id": "reply_yes" + "value": 'reply_yes', + "action_id": 'reply_yes' }, { - "type": "button", + "type": 'button', "text": { - "type": "plain_text", - "text": "No", + "type": 'plain_text', + "text": 'No', "emoji": true }, - "value": "reply_no", - "action_id": "reply_no" + "value": 'reply_no', + "action_id": 'reply_no' } ] } @@ -45,10 +47,10 @@ def quiz_message(question, channel_id) team_id = command[:team_id] channel_id = command[:channel_id] command.logger.info "Someone started a quiz in channel #{channel_id}." - question = "Can octopuses change their color? :octopus:" - team = Team.find_by(team_id: team_id) + question = 'Can octopuses change their color? :octopus:' + team = Team.find_by(team_id:) slack_client = Slack::Web::Client.new(token: team.token) - slack_client.chat_postMessage(quiz_message question, channel_id) + slack_client.chat_postMessage(quiz_message(question, channel_id)) nil end end diff --git a/config.ru b/config.ru index 94f422f..0728875 100644 --- a/config.ru +++ b/config.ru @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This file is used by Rack-based servers to start the application. require_relative 'config/environment' diff --git a/config/application.rb b/config/application.rb index 66d4775..5234b18 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,17 +1,19 @@ -require_relative "boot" +# frozen_string_literal: true -require "rails" +require_relative 'boot' + +require 'rails' # Pick the frameworks you want: -require "active_model/railtie" -require "active_job/railtie" -require "active_record/railtie" +require 'active_model/railtie' +require 'active_job/railtie' +require 'active_record/railtie' # require "active_storage/engine" -require "action_controller/railtie" -require "action_mailer/railtie" +require 'action_controller/railtie' +require 'action_mailer/railtie' # require "action_mailbox/engine" # require "action_text/engine" -require "action_view/railtie" -require "action_cable/engine" +require 'action_view/railtie' +require 'action_cable/engine' # require "rails/test_unit/railtie" # Require the gems listed in Gemfile, including any gems diff --git a/config/boot.rb b/config/boot.rb index 988a5dd..c04863f 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,4 +1,6 @@ -ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) +# frozen_string_literal: true -require "bundler/setup" # Set up gems listed in the Gemfile. -require "bootsnap/setup" # Speed up boot time by caching expensive operations. +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) + +require 'bundler/setup' # Set up gems listed in the Gemfile. +require 'bootsnap/setup' # Speed up boot time by caching expensive operations. diff --git a/config/environment.rb b/config/environment.rb index cac5315..d5abe55 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true + # Load the Rails application. -require_relative "application" +require_relative 'application' # Initialize the Rails application. Rails.application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb index aace90a..400bb9c 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,4 +1,6 @@ -require "active_support/core_ext/integer/time" +# frozen_string_literal: true + +require 'active_support/core_ext/integer/time' Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. @@ -19,10 +21,10 @@ # Enable/disable caching. By default caching is disabled. # Run rails dev:cache to toggle caching. - if Rails.root.join("tmp/caching-dev.txt").exist? + if Rails.root.join('tmp/caching-dev.txt').exist? config.cache_store = :memory_store config.public_file_server.headers = { - "Cache-Control" => "public, max-age=#{2.days.to_i}" + 'Cache-Control' => "public, max-age=#{2.days.to_i}" } else config.action_controller.perform_caching = false @@ -50,7 +52,6 @@ # Highlight code that triggered database queries in logs. config.active_record.verbose_query_logs = true - # Raises error for missing translations. # config.i18n.raise_on_missing_translations = true @@ -60,6 +61,6 @@ # Uncomment if you wish to allow Action Cable access from any origin. # config.action_cable.disable_request_forgery_protection = true - config.hosts << %r{.+\.notch8.cloud$} - config.hosts << %r{.+.test} + config.hosts << /.+\.notch8.cloud$/ + config.hosts << /.+.test/ end diff --git a/config/environments/production.rb b/config/environments/production.rb index 017c185..5583c29 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,4 +1,6 @@ -require "active_support/core_ext/integer/time" +# frozen_string_literal: true + +require 'active_support/core_ext/integer/time' Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. @@ -13,7 +15,7 @@ config.eager_load = true # Full error reports are disabled and caching is turned on. - config.consider_all_requests_local = false + config.consider_all_requests_local = false # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). @@ -21,7 +23,7 @@ # Disable serving static files from the `/public` folder by default since # Apache or NGINX already handles this. - config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present? + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? # Enable serving of images, stylesheets, and JavaScripts from an asset server. # config.asset_host = "http://assets.example.com" @@ -36,14 +38,14 @@ # config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ] # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. - # config.force_ssl = true + config.force_ssl = true # Include generic and useful information about system operation, but avoid logging too much # information to avoid inadvertent exposure of personally identifiable information (PII). config.log_level = :info # Prepend all log lines with the following tags. - config.log_tags = [ :request_id ] + config.log_tags = [:request_id] # Use a different cache store in production. # config.cache_store = :mem_cache_store @@ -75,8 +77,8 @@ # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false - if ENV["RAILS_LOG_TO_STDOUT"].present? - logger = ActiveSupport::Logger.new(STDOUT) + if ENV['RAILS_LOG_TO_STDOUT'].present? + logger = ActiveSupport::Logger.new($stdout) logger.formatter = config.log_formatter config.logger = ActiveSupport::TaggedLogging.new(logger) end diff --git a/config/environments/test.rb b/config/environments/test.rb index e57c036..5169eeb 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,4 +1,6 @@ -require "active_support/core_ext/integer/time" +# frozen_string_literal: true + +require 'active_support/core_ext/integer/time' # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that @@ -14,12 +16,12 @@ # Eager loading loads your whole application. When running a single test locally, # this probably isn't necessary. It's a good idea to do in a continuous integration # system, or in some way before deploying your code. - config.eager_load = ENV["CI"].present? + config.eager_load = ENV['CI'].present? # Configure public file server for tests with Cache-Control for performance. config.public_file_server.enabled = true config.public_file_server.headers = { - "Cache-Control" => "public, max-age=#{1.hour.to_i}" + 'Cache-Control' => "public, max-age=#{1.hour.to_i}" } # Show full error reports and disable caching. diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb index 89d2efa..f4556db 100644 --- a/config/initializers/application_controller_renderer.rb +++ b/config/initializers/application_controller_renderer.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # Be sure to restart your server when you modify this file. # ActiveSupport::Reloader.to_prepare do diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb index 59385cd..d0f0d3b 100644 --- a/config/initializers/backtrace_silencers.rb +++ b/config/initializers/backtrace_silencers.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # Be sure to restart your server when you modify this file. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. diff --git a/config/initializers/cors.rb b/config/initializers/cors.rb index e5a82f1..38d411f 100644 --- a/config/initializers/cors.rb +++ b/config/initializers/cors.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # Be sure to restart your server when you modify this file. # Avoid CORS issues when API is called from the frontend app. diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index adc6568..3df77c5 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -1,8 +1,10 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Configure parameters to be filtered from the log file. Use this to limit dissemination of # sensitive information. See the ActiveSupport::ParameterFilter documentation for supported # notations and behaviors. -Rails.application.config.filter_parameters += [ - :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn +Rails.application.config.filter_parameters += %i[ + passw secret token _key crypt salt certificate otp ssn ] diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index 3860f65..6c78420 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # Be sure to restart your server when you modify this file. # Add new inflection rules using the following format. Inflections diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb index dc18996..6e1d16f 100644 --- a/config/initializers/mime_types.rb +++ b/config/initializers/mime_types.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # Be sure to restart your server when you modify this file. # Add new mime types for use in respond_to blocks: diff --git a/config/initializers/slack_ruby_bot_server.rb b/config/initializers/slack_ruby_bot_server.rb index db3937a..d8445cb 100644 --- a/config/initializers/slack_ruby_bot_server.rb +++ b/config/initializers/slack_ruby_bot_server.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + SlackRubyBotServer.configure do |config| config.view_paths << File.expand_path(File.join(__dir__, '../../public')) config.oauth_version = :v2 diff --git a/config/initializers/slack_ruby_bot_server_events.rb b/config/initializers/slack_ruby_bot_server_events.rb index baa56ae..f450d1d 100644 --- a/config/initializers/slack_ruby_bot_server_events.rb +++ b/config/initializers/slack_ruby_bot_server_events.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + SlackRubyBotServer::Events.configure do |config| config.signing_secret ||= ENV['SLACK_SIGNING_SECRET'] config.signature_expires_in ||= 300 diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb index 633c1c8..e7148a3 100644 --- a/config/initializers/wrap_parameters.rb +++ b/config/initializers/wrap_parameters.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. # This file contains settings for ActionController::ParamsWrapper which diff --git a/config/puma.rb b/config/puma.rb index 5ed4437..69e2645 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,23 +1,25 @@ +# frozen_string_literal: true + # Puma can serve each request in a thread from an internal thread pool. # The `threads` method setting takes two numbers: a minimum and maximum. # Any libraries that use thread pools should be configured to match # the maximum value specified for Puma. Default is set to 5 threads for minimum # and maximum; this matches the default thread size of Active Record. # -max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } -min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count } +max_threads_count = ENV.fetch('RAILS_MAX_THREADS', 5) +min_threads_count = ENV.fetch('RAILS_MIN_THREADS') { max_threads_count } threads min_threads_count, max_threads_count # Specifies the `port` that Puma will listen on to receive requests; default is 3000. # -port ENV.fetch("PORT") { 3000 } +port ENV.fetch('PORT', 3000) # Specifies the `environment` that Puma will run in. # -environment ENV.fetch("RAILS_ENV") { "development" } +environment ENV.fetch('RAILS_ENV', 'development') # Specifies the `pidfile` that Puma will use. -pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } +pidfile ENV.fetch('PIDFILE', 'tmp/pids/server.pid') # Specifies the number of `workers` to boot in clustered mode. # Workers are forked web server processes. If using threads and workers together diff --git a/config/routes.rb b/config/routes.rb index fb358f3..640f642 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Rails.application.routes.draw do resources :members resources :groups diff --git a/config/spring.rb b/config/spring.rb index db5bf13..93cd0ff 100644 --- a/config/spring.rb +++ b/config/spring.rb @@ -1,6 +1,8 @@ +# frozen_string_literal: true + Spring.watch( - ".ruby-version", - ".rbenv-vars", - "tmp/restart.txt", - "tmp/caching-dev.txt" + '.ruby-version', + '.rbenv-vars', + 'tmp/restart.txt', + 'tmp/caching-dev.txt' ) diff --git a/db/migrate/20230623173103_create_groups.rb b/db/migrate/20230623173103_create_groups.rb index d27cc23..e3b333c 100644 --- a/db/migrate/20230623173103_create_groups.rb +++ b/db/migrate/20230623173103_create_groups.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateGroups < ActiveRecord::Migration[7.0] def change create_table :groups do |t| diff --git a/db/migrate/20230623180851_create_members.rb b/db/migrate/20230623180851_create_members.rb index f576353..d72a0b0 100644 --- a/db/migrate/20230623180851_create_members.rb +++ b/db/migrate/20230623180851_create_members.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateMembers < ActiveRecord::Migration[7.0] def change create_table :members do |t| diff --git a/db/schema.rb b/db/schema.rb index a7879ed..b8508df 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. @@ -10,41 +12,41 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_06_23_180851) do +ActiveRecord::Schema[7.0].define(version: 20_230_623_180_851) do # These are extensions that must be enabled in order to support this database - enable_extension "plpgsql" + enable_extension 'plpgsql' - create_table "groups", force: :cascade do |t| - t.string "name" - t.text "description" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + create_table 'groups', force: :cascade do |t| + t.string 'name' + t.text 'description' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false end - create_table "members", force: :cascade do |t| - t.string "name" - t.string "handle" - t.string "member_id" - t.bigint "group_id", null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.index ["group_id"], name: "index_members_on_group_id" + create_table 'members', force: :cascade do |t| + t.string 'name' + t.string 'handle' + t.string 'member_id' + t.bigint 'group_id', null: false + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.index ['group_id'], name: 'index_members_on_group_id' end - create_table "teams", force: :cascade do |t| - t.string "team_id" - t.string "name" - t.string "domain" - t.string "token" - t.string "oauth_scope" - t.string "oauth_version", default: "v1", null: false - t.string "bot_user_id" - t.string "activated_user_id" - t.string "activated_user_access_token" - t.boolean "active", default: true - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + create_table 'teams', force: :cascade do |t| + t.string 'team_id' + t.string 'name' + t.string 'domain' + t.string 'token' + t.string 'oauth_scope' + t.string 'oauth_version', default: 'v1', null: false + t.string 'bot_user_id' + t.string 'activated_user_id' + t.string 'activated_user_access_token' + t.boolean 'active', default: true + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false end - add_foreign_key "members", "groups" + add_foreign_key 'members', 'groups' end diff --git a/db/seed.rb b/db/seed.rb index 8e5d735..cf566d0 100644 --- a/db/seed.rb +++ b/db/seed.rb @@ -1,27 +1,29 @@ +# frozen_string_literal: true + Group.find_or_create_by(name: 'devops') do |group| - group.description = "SoftServ DevOps Team" + group.description = 'SoftServ DevOps Team' end Group.find_or_create_by(name: 'gcsupport') do |group| - group.description = "Glass Canvas Support Team" + group.description = 'Glass Canvas Support Team' end Group.find_or_create_by(name: 'gcdev') do |group| - group.description = "Glass Canvas Dev Team" + group.description = 'Glass Canvas Dev Team' end Member.find_or_create_by(handle: 'rob') do |member| - member.name = "Rob Kauufman" + member.name = 'Rob Kauufman' member.group = Group.find_by(name: 'devops') - member.member_id = "U0E347KGF" + member.member_id = 'U0E347KGF' end Member.find_or_create_by(handle: 'crystal') do |member| - member.name = "Crystal Richardson" + member.name = 'Crystal Richardson' member.group = Group.find_by(name: 'devops') end Member.find_or_create_by(handle: 'stefan') do |member| - member.name = "Stefan" + member.name = 'Stefan' member.group = Group.find_by(name: 'gcdev') end diff --git a/db/seeds.rb b/db/seeds.rb index 578c0b5..ca7bcac 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,27 +1,29 @@ +# frozen_string_literal: true + Group.find_or_create_by(name: 'devops') do |group| - group.description = "SoftServ DevOps Team" + group.description = 'SoftServ DevOps Team' end Group.find_or_create_by(name: 'gcsupport') do |group| - group.description = "Glass Canvas Support Team" + group.description = 'Glass Canvas Support Team' end Group.find_or_create_by(name: 'gcdev') do |group| - group.description = "Glass Canvas Dev Team" + group.description = 'Glass Canvas Dev Team' end Member.find_or_create_by(handle: 'rob') do |member| - member.name = "Rob Kaufman" + member.name = 'Rob Kaufman' member.group = Group.find_by(name: 'devops') - member.member_id = "U0E347KGF" + member.member_id = 'U0E347KGF' end Member.find_or_create_by(handle: 'crystal') do |member| - member.name = "Crystal Richardson" + member.name = 'Crystal Richardson' member.group = Group.find_by(name: 'devops') end Member.find_or_create_by(handle: 'stefan') do |member| - member.name = "Stefan" + member.name = 'Stefan' member.group = Group.find_by(name: 'gcdev') end