Skip to content

Commit

Permalink
Auto lint and some minor manual updates
Browse files Browse the repository at this point in the history
  • Loading branch information
schneems committed Oct 28, 2023
1 parent c309157 commit d8945dd
Show file tree
Hide file tree
Showing 147 changed files with 1,216 additions and 1,189 deletions.
152 changes: 76 additions & 76 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

source 'https://rubygems.org'
source "https://rubygems.org"

git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
Expand All @@ -14,125 +14,125 @@ git_source :github do |name|
end

# Core
if ENV["RAILS_MASTER"] == '1'
gem 'rails', git: 'https://github.com/rails/rails.git'
if ENV["RAILS_MASTER"] == "1"
gem "rails", git: "https://github.com/rails/rails.git"
else
gem 'rails', '7.0.8'
gem "rails", "7.0.8"
end

# API & Networking
gem 'git_hub_bub'
gem "git_hub_bub"

# Application server & middleware
gem 'puma'
gem 'puma_worker_killer'
gem 'rack-timeout'
gem 'rack-canonical-host'
gem "puma"
gem "puma_worker_killer"
gem "rack-timeout"
gem "rack-canonical-host"

# Assets
gem 'autoprefixer-rails'
gem 'babel-transpiler'
gem 'bourbon'
gem 'coffee-rails', '~> 5.0.0'
gem 'neat', '~> 1.7'
gem 'normalize-rails'
gem 'sassc'
gem 'sassc-rails'
gem 'slim-rails'
gem 'sprockets'
gem 'sprockets-rails'
gem 'uglifier', '>= 1.0.3'
gem "autoprefixer-rails"
gem "babel-transpiler"
gem "bourbon"
gem "coffee-rails", "~> 5.0.0"
gem "neat", "~> 1.7"
gem "normalize-rails"
gem "sassc"
gem "sassc-rails"
gem "slim-rails"
gem "sprockets"
gem "sprockets-rails"
gem "uglifier", ">= 1.0.3"

# Authentication & Authorization
gem 'devise'
gem 'omniauth'
gem 'omniauth-rails_csrf_protection'
gem 'omniauth-github'
gem "devise"
gem "omniauth"
gem "omniauth-rails_csrf_protection"
gem "omniauth-github"

# Backgroud jobs
gem 'sidekiq'
gem 'sinatra'
gem "sidekiq"
gem "sinatra"

# Caching
gem 'dalli'
gem "dalli"

# Database
gem 'pg'
gem "pg"

# Email
gem 'mail', require: ['mail', 'mail/utilities', 'mail/parsers'] # parsers is used by `valid_email` and may be causing https://github.com/mikel/mail/issues/912#issuecomment-170121429
gem 'premailer-rails'
gem 'valid_email'
gem "mail", require: ["mail", "mail/utilities", "mail/parsers"] # parsers is used by `valid_email` and may be causing https://github.com/mikel/mail/issues/912#issuecomment-170121429
gem "premailer-rails"
gem "valid_email"

# File Handling & Data Processing
gem 'mime-types', require: 'mime/types/columnar'
gem "mime-types", require: "mime/types/columnar"

# JavaScript
gem 'jquery-rails'
gem 'render_async'
gem "jquery-rails"
gem "render_async"

# JSON
gem 'oj'
gem "oj"

# Views
gem 'bluecloth'
gem 'local_time'
gem 'maildown'
gem 'wicked'
gem "bluecloth"
gem "local_time"
gem "maildown"
gem "wicked"

# Pagination
gem 'will_paginate'
gem "will_paginate"

# Performance & Monitoring
gem 'bootsnap', require: false
gem 'flamegraph'
gem 'matrix'
gem 'prawn'
gem 'rack-mini-profiler'
gem 'rails-autoscale-web'
gem 'rbtrace'
gem 'sentry-raven'
gem 'scout_apm'
gem 'skylight'
gem 'stackprof'
gem "bootsnap", require: false
gem "flamegraph"
gem "matrix"
gem "prawn"
gem "rack-mini-profiler"
gem "rails-autoscale-web"
gem "rbtrace"
gem "sentry-raven"
gem "scout_apm"
gem "skylight"
gem "stackprof"

# SEO & Sitemaps
gem 'sitemap_generator'
gem "sitemap_generator"

# Storage
gem 'aws-sdk-s3'
gem "aws-sdk-s3"

# Utilities
gem 'rake'
gem 'rrrretry'
gem "rake"
gem "rrrretry"

# Parse Ruby documentation
gem 'yard', '~> 0.9.28'
gem "yard", "~> 0.9.28"

group :development do
gem 'foreman'
gem 'listen'
gem 'memory_profiler'
gem 'web-console'
gem "foreman"
gem "listen"
gem "memory_profiler"
gem "web-console"
end

group :test do
gem 'capybara'
gem 'launchy' # Not essential but helpful for save_and_open_page
gem 'minitest'
gem 'mocha', require: false
gem 'rails-controller-testing'
gem 'simplecov', require: false
gem 'test-prof'
gem 'vcr'
gem 'webmock'
gem "capybara"
gem "launchy" # Not essential but helpful for save_and_open_page
gem "minitest"
gem "mocha", require: false
gem "rails-controller-testing"
gem "simplecov", require: false
gem "test-prof"
gem "vcr"
gem "webmock"
end

group :development, :test do
gem 'derailed_benchmarks'
gem 'dotenv-rails'
gem 'faker', require: false
gem 'pry'
gem 'standardrb', require: false
gem 'rubocop-performance'
gem "derailed_benchmarks"
gem "dotenv-rails"
gem "faker", require: false
gem "pry"
gem "standardrb", require: false
gem "rubocop-performance"
end
9 changes: 6 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,21 @@ if ENV["DEADLOCK_DEBUG"]
puts
puts "## Deadlock Debug"
puts
Thread.list.each { |t| puts "=" * 80; puts t.backtrace }
Thread.list.each { |t|
puts "=" * 80
puts t.backtrace
}
end
end
end

require File.expand_path('../config/application', __FILE__)
require File.expand_path("../config/application", __FILE__)

begin
require "rubocop/rake_task"

RuboCop::RakeTask.new(:rubocop) do |task|
task.options = ['--display-cop-names']
task.options = ["--display-cop-names"]
end
rescue LoadError
# We are in the production environment, where Rubocop is not required.
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api_info_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class ApiInfoController < RepoBasedController
include ActionView::Helpers::DateHelper

def show
@repo = find_repo(params)
@repo = find_repo(params)
added_by = @repo.subscribers.where(private: false).order(:created_at).first&.github
count = @repo.subscribers_count
count = 0 if added_by.nil?
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class ApplicationController < ActionController::Base
protect_from_forgery

before_action do
if current_user && current_user.admin?
if current_user&.admin?
Rack::MiniProfiler.authorize_request
end
end
Expand All @@ -29,6 +29,6 @@ def authenticate_user!
end

def after_sign_in_path_for(resource)
request.env['omniauth.origin'] || stored_location_for(resource) || root_path
request.env["omniauth.origin"] || stored_location_for(resource) || root_path
end
end
15 changes: 7 additions & 8 deletions app/controllers/badges_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
class BadgesController < ApplicationController
def show
repo = Repo.where(full_name: permitted[:full_name])
.select(:subscribers_count, :issues_count, :updated_at)
.first
raise ActionController::RoutingError.new('Not Found') if repo.blank?
.select(:subscribers_count, :issues_count, :updated_at)
.first
raise ActionController::RoutingError.new("Not Found") if repo.blank?

case permitted[:badge_type]
when "users"
count = repo.subscribers_count
svg = make_shield(name: "code helpers", count: count, color_b: repo.color)
svg = make_shield(name: "code helpers", count: count, color_b: repo.color)
else
raise ActionController::RoutingError.new('Not Found')
raise ActionController::RoutingError.new("Not Found")
end

# Set Cache-Control header
Expand Down Expand Up @@ -59,10 +59,10 @@ def width_of(string)
end

def make_shield(name:, count:, color_a: "555", color_b: "4c1", logo_width: 0, logo_padding: 0)
name_width = (width_of(name) + 10).to_f
name_width = (width_of(name) + 10).to_f
count_width = (width_of(count) + 10).to_f
total_width = name_width + count_width
svg = <<~EOS
<<~EOS
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="#{total_width}" height="20">
<linearGradient id="smooth" x2="0" y2="100%">
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
Expand All @@ -87,7 +87,6 @@ def make_shield(name:, count:, color_a: "555", color_b: "4c1", logo_width: 0, lo
</g>
</svg>
EOS
return svg
end

def permitted
Expand Down
22 changes: 11 additions & 11 deletions app/controllers/doc_methods_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@

class DocMethodsController < ApplicationController
def show
@doc = DocMethod.where(id: params[:id])
.select(:id, :repo_id, :path, :line, :file, :doc_comments_count)
.includes(:repo)
.first!
@doc = DocMethod.where(id: params[:id])
.select(:id, :repo_id, :path, :line, :file, :doc_comments_count)
.includes(:repo)
.first!
@comment = @doc.doc_comments.select(:comment).first
@repo = @doc.repo
@repo = @doc.repo
@username = current_user.present? ? current_user.github : "<your name>"
@branch = GitBranchnameGenerator.new(username: @username, doc_path: @doc.path).branchname
@branch = GitBranchnameGenerator.new(username: @username, doc_path: @doc.path).branchname

set_title("Help Writing docs #{@doc.path} - #{@repo.full_name} #{@repo.language}")
set_description("#{@doc.missing_docs? ? 'Write' : 'Read'} docs for #{@repo.name} starting with #{@doc.path}.")
set_description("#{@doc.missing_docs? ? "Write" : "Read"} docs for #{@repo.name} starting with #{@doc.path}.")
end

def click_method_redirect
doc = DocMethod.find(params[:id])
sub = RepoSubscription.where(user_id: params[:user_id], repo: doc.repo).first
doc = DocMethod.find(params[:id])
sub = RepoSubscription.where(user_id: params[:user_id], repo: doc.repo).first
assignment = DocAssignment.where(doc_method_id: doc.id, repo_subscription_id: sub.id).first

if assignment&.user&.id.to_s == params[:user_id]
Expand All @@ -34,8 +34,8 @@ def click_method_redirect
end

def click_source_redirect
doc = DocMethod.find(params[:id])
sub = RepoSubscription.find_by!(user_id: params[:user_id], repo: doc.repo)
doc = DocMethod.find(params[:id])
sub = RepoSubscription.find_by!(user_id: params[:user_id], repo: doc.repo)
assignment = DocAssignment.find_by!(doc_method_id: doc.id, repo_subscription_id: sub.id)

if assignment&.user&.id.to_s == params[:user_id]
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/issue_assignments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class IssueAssignmentsController < ApplicationController
def create
repo_sub = current_user.repo_subscriptions.find(params[:id])
SendSingleTriageEmailJob.perform_later(repo_sub.id)
redirect_to repo_path(repo_sub.repo), notice: 'You will receive an email with your new issue shortly'
redirect_to repo_path(repo_sub.repo), notice: "You will receive an email with your new issue shortly"
end

# get "/issue_assignments/:id/users/:user_id/click/:created_at", to: "issue_assignments#click"
Expand Down
10 changes: 5 additions & 5 deletions app/controllers/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def index
@covid_repos = get_covid_repos

@repos = Repo.with_some_issues
.select(:id, :updated_at, :issues_count, :language, :full_name, :name, :description)
.select(:id, :updated_at, :issues_count, :language, :full_name, :name, :description)
if (language = valid_params[:language] || current_user.try(:favorite_languages))
@repos = @repos.where(language: language)
end
Expand All @@ -45,17 +45,17 @@ def index
respond_to do |format|
format.html {}
format.json do
htmlForPage = render_to_string(partial: "repos_with_pagination", locals: { repos: @repos }, formats: ['html'])
render json: { html: htmlForPage }.to_json
html_for_page = render_to_string(partial: "repos_with_pagination", locals: {repos: @repos}, formats: ["html"])
render json: {html: html_for_page}.to_json
end
end
end

private def description
Rails.cache.fetch("pages#index/description", expires_in: 1.hour) do
"Discover the easiest way to get started contributing to open source. " \
"Over #{number_with_delimiter(User.count, delimiter: ',')} devs are " \
"helping #{number_with_delimiter(Repo.count, delimiter: ',')} projects " \
"Over #{number_with_delimiter(User.count, delimiter: ",")} devs are " \
"helping #{number_with_delimiter(Repo.count, delimiter: ",")} projects " \
"with our free, community developed tools"
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/repo_based_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class RepoBasedController < ApplicationController
protected

def name_from_params(options)
[options[:name], options[:format]].compact.join('.')
[options[:name], options[:format]].compact.join(".")
end

def find_repo(options, only_active: true)
Expand Down
Loading

0 comments on commit d8945dd

Please sign in to comment.