Corrections auto avec standardrb

This commit is contained in:
Jérémy Lecour 2023-02-26 15:09:08 +01:00 committed by Jérémy Lecour
parent b27a63ba9c
commit 2dc085be6f
33 changed files with 142 additions and 162 deletions

View file

@ -53,7 +53,7 @@ gem "heroicon"
# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
# gem "image_processing", "~> 1.2"
gem 'pundit', "~> 2.1.1"
gem "pundit", "~> 2.1.1"
gem "ransack", "~> 2.5.0"
gem "kaminari", "~> 1.2.2"
@ -77,15 +77,14 @@ group :development do
gem "capistrano", "~> 3.16", require: false
gem "capistrano-rails", require: false
gem "capistrano-rbenv", require: false
gem 'capistrano3-puma', require: false
gem "capistrano3-puma", require: false
# Necessary for elliptic curve SSH keys
# gem 'rbnacl', ">= 3.2", "<5.0"
# gem 'rbnacl-libsodium'
gem 'bcrypt_pbkdf', ">= 1.0", "<2.0"
gem 'ed25519', ">= 1.2", "< 2.0"
gem "bcrypt_pbkdf", ">= 1.0", "<2.0"
gem "ed25519", ">= 1.2", "< 2.0"
gem "openssl", "< 3.0.0"
end
group :test do

View file

@ -1,8 +1,6 @@
class Api::V1::CheckReportsController < Api::V1::BaseController
# POST /check-reports or /check-reports.json
def create
@check_report = CheckReport.new(check_report_params)
if @check_report.checks.empty?
@ -35,5 +33,4 @@ class Api::V1::CheckReportsController < Api::V1::BaseController
def check_report_params
params.require(:check_report).permit(:hostname, :date, {checks: [:name, :description]})
end
end

View file

@ -49,6 +49,7 @@ class ChecksController < AuthenticatedController
end
private
# Use callbacks to share common setup or constraints between actions.
def set_check
@check = Check.find(params[:id])

View file

@ -10,12 +10,12 @@ module ApiKeyAuthentication
# Use this to raise an error and automatically respond with a 401 HTTP status
# code when API key authentication fails
def authenticate_with_api_key!
@current_bearer = authenticate_or_request_with_http_token &method(:authenticator)
@current_bearer = authenticate_or_request_with_http_token(&method(:authenticator))
end
# Use this for optional API key authentication
def authenticate_with_api_key
@current_bearer = authenticate_with_http_token &method(:authenticator)
@current_bearer = authenticate_with_http_token(&method(:authenticator))
end
private

View file

@ -25,5 +25,4 @@ class ConfirmationsController < ApplicationController
def new
@user = User.new
end
end

View file

@ -71,6 +71,7 @@ class UsersController < ApplicationController
end
private
# Use callbacks to share common setup or constraints between actions.
def set_user
@user = User.find(params[:id])

View file

@ -1,7 +1,6 @@
module ApplicationHelper
def colored_pill_tag(content_or_options_with_block = nil, options = nil, &block)
if block_given?
if block
options = content_or_options_with_block if content_or_options_with_block.is_a?(Hash)
end
@ -18,11 +17,10 @@ module ApplicationHelper
classes = "px-2 inline-flex text-xs leading-5 font-semibold rounded-full #{color_classes}"
if block_given?
if block
content_tag(:span, class: classes, &block)
else
content_tag(:span, content_or_options_with_block, class: classes)
end
end
end

View file

@ -1,8 +1,8 @@
module UsersHelper
def user_gravatar(user, options = {})
options = {:alt => 'avatar', :class => 'avatar', :size => 80}.merge! options
id = Digest::MD5::hexdigest(user.email.strip.downcase)
url = 'http://www.gravatar.com/avatar/' + id + '.jpg?s=' + options[:size].to_s
options = {alt: "avatar", class: "avatar", size: 80}.merge! options
id = Digest::MD5.hexdigest(user.email.strip.downcase)
url = "http://www.gravatar.com/avatar/" + id + ".jpg?s=" + options[:size].to_s
options.delete :size
image_tag(url, options)

View file

@ -26,8 +26,8 @@ set :repo_url, "git@gitea.evolix.org:evolix/evodata.git"
# Default value for linked_dirs is []
# append :linked_dirs, "log", "tmp/pids", "tmp/cache", "tmp/sockets", "public/system"
append :linked_dirs, 'log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', '.bundle', 'public/system', 'public/uploads'
append :linked_files, 'config/master.key'
append :linked_dirs, "log", "tmp/pids", "tmp/cache", "tmp/sockets", "vendor/bundle", ".bundle", "public/system", "public/uploads"
append :linked_files, "config/master.key"
# Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }

View file

@ -1,4 +1,4 @@
config = YAML::load_file(File.join(__dir__, 'config.yml')).fetch("production")
config = YAML.load_file(File.join(__dir__, "config.yml")).fetch("production")
config.fetch("servers").each do |sc|
server sc.fetch("host"), user: sc.fetch("user"), roles: sc.fetch("roles")
@ -11,7 +11,6 @@ if config.has_key?(:keep_releases)
set :keep_releases, config.fetch("keep_releases").to_i
end
# server-based syntax
# ======================
# Defines a single server with a list of roles and multiple properties.
@ -21,8 +20,6 @@ end
# server "example.com", user: "deploy", roles: %w{app web}, other_property: :other_value
# server "db.example.com", user: "deploy", roles: %w{db}
# role-based syntax
# ==================
@ -35,8 +32,6 @@ end
# role :web, %w{user1@primary.com user2@additional.com}, other_property: :other_value
# role :db, %w{deploy@example.com}
# Configuration
# =============
# You can set any configuration variable like in config/deploy.rb
@ -45,8 +40,6 @@ end
# http://capistranorb.com/documentation/getting-started/configuration/
# Feel free to add new variables to customise your setup.
# Custom SSH Options
# ==================
# You may pass any option but keep in mind that net/ssh understands a

View file

@ -1,4 +1,4 @@
config = YAML::load_file(File.join(__dir__, 'config.yml')).fetch("staging")
config = YAML.load_file(File.join(__dir__, "config.yml")).fetch("staging")
config.fetch("servers").each do |sc|
server sc.fetch("host"), user: sc.fetch("user"), roles: sc.fetch("roles")
@ -11,12 +11,10 @@ if config.has_key?("keep_releases")
set :keep_releases, config.fetch("keep_releases").to_i
end
if config.has_key?("tmp_dir")
set :tmp_dir, config.fetch("tmp_dir")
end
# server-based syntax
# ======================
# Defines a single server with a list of roles and multiple properties.
@ -38,8 +36,6 @@ end
# role :web, %w{user1@primary.com user2@additional.com}, other_property: :other_value
# role :db, %w{deploy@example.com}
# Configuration
# =============
# You can set any configuration variable like in config/deploy.rb
@ -48,8 +44,6 @@ end
# http://capistranorb.com/documentation/getting-started/configuration/
# Feel free to add new variables to customise your setup.
# Custom SSH Options
# ==================
# You may pass any option but keep in mind that net/ssh understands a

View file

@ -41,7 +41,7 @@ Rails.application.configure do
config.action_mailer.perform_caching = false
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
config.action_mailer.default_url_options = {host: "localhost", port: 3000}
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log

View file

@ -64,7 +64,7 @@ Rails.application.configure do
config.action_mailer.perform_caching = false
config.action_mailer.default_url_options = { host: 'evocheck-web.evolix.org' }
config.action_mailer.default_url_options = {host: "evocheck-web.evolix.org"}
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
@ -85,7 +85,7 @@ Rails.application.configure do
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name")
if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger = ActiveSupport::Logger.new($stdout)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end

View file

@ -64,7 +64,7 @@ Rails.application.configure do
config.action_mailer.perform_caching = false
config.action_mailer.default_url_options = { host: 'staging.evodata.evolix.eu' }
config.action_mailer.default_url_options = {host: "staging.evodata.evolix.eu"}
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
@ -85,7 +85,7 @@ Rails.application.configure do
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name")
if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger = ActiveSupport::Logger.new($stdout)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end

View file

@ -4,7 +4,7 @@
# 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 }
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
@ -15,7 +15,7 @@ worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"
# 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.
#

View file

@ -1,9 +1,8 @@
Rails.application.routes.draw do
namespace :api do
namespace :v1 do
defaults format: :json do
get '/ping', to: 'base#ping'
get "/ping", to: "base#ping"
resources :check_reports, path: "check-reports", only: [:create]
end
end

View file

@ -1,4 +1,3 @@
# Preview all emails at http://localhost:3000/rails/mailers/user_mailer
class UserMailerPreview < ActionMailer::Preview
end